Couldn't have put that in a better way myself. Yes, after the introduction of Symbols in ES6, an object key can be either a string or a Symbol. Also, all keys in the square bracket notation are converted to string unless they're Symbols. Since this post was targeted to an audience who've just started with JS, I was trying not to get into Symbols for now :)
Couldn't have put that in a better way myself. Yes, after the introduction of Symbols in ES6, an object key can be either a string or a Symbol. Also, all keys in the square bracket notation are converted to string unless they're Symbols. Since this post was targeted to an audience who've just started with JS, I was trying not to get into Symbols for now :)
Let's consider x[0].
Here 0 probably actually won't be converted to a string, at least until you try to look at it in a way that requires presenting it as a string.
So, I think it's worth distinguishing between "X is Y" and "X is presented as Y in some situations." :)