JavaScriptEasy
Explain the difference between dot notation and bracket notation for accessing object properties
By FrontendPro Editorial Team Updated 8/8/2026
#JavaScript
Answer
Dot notation and bracket notation are two ways to access properties of an object in JavaScript. Dot notation is more concise and readable but can only be used with valid JavaScript identifiers. Bracket notation is more flexible and can be used with property names that are not valid identifiers, such as those containing spaces or special characters.
js
const obj = { name: "Alice", "favorite color": "blue" };
// Dot notation
console.log(obj.name); // Alice
// Bracket notation
console.log(obj["favorite color"]); // blue
