Is Space Before Bracket Notation Allowed in JavaScript?

A space before bracket notation is allowed in JavaScript (when setting or getting an object property). For example, the following is valid:

const prop = 'foo';
const obj = { baz: 'qux' };

obj [prop] = 'bar';

console.log(obj [prop]); // 'bar'

This is purely a stylistic preference, and is valid JavaScript syntax.

Hope you found this post useful. It was published . Please show your love and support by sharing this post.