I just bumped into this. Anyone have insight as to why this works?
const a = {b: 2};
console.log( a[['b']] );
// Result: 2
I just bumped into this. Anyone have insight as to why this works?
const a = {b: 2};
console.log( a[['b']] );
// Result: 2
For further actions, you may consider blocking this person and/or reporting abuse
Nozibul Islam -
Said MOUNAIM -
reverse Ch -
Saleh Mubashar -
Top comments (3)
Index(es) needs to be string and JS will automatically convert anything used as object's index to a string.
['b'].toString()
happens to be equal to 'b' (its same as['b'].join(',')
).Looks like it.
not sure if that's related but [['b']] appears to be equal to 'b'