EN
JavaScript - object property access: dot notation vs brackets notation
3
points
In this article, we would like to show you the difference between dot notation and brackets notation working with object property access in JavaScript.
Simple comparison
| Dot notation | Brackets notation |
|---|---|
|
Syntax:
|
Syntax:
|
| The most popular way to access the property of an object. | Is used when we can't access object property using dot notation. |
|
Practical example:
|
Practical example:
|
|
Benefits: Makes code more readable. |
Benefits: Variables can be used to access property values. |