When checking out the length property on a string I made a mistake and forgot the quotes around length. Instead of an error, one of the characters appeared from the string.
const string = 'name'
s[length]
>> "a"
I have done other combinations and usually get the second letter returned. So is the word length being converted into a Boolean, which is then converted to a number? Or, is something else going on?
Update. this is all I did:
const a = [1,2,3]
>> undefined
a["length"]
>> 3
const s = 'name'
>> undefined
s[length]
>> "a"
s['length']
>> 4
length
>> 1
a[length]
>> 2
lengthanywhere else in your code?("name")[undefined] = 'n'because it cast undefined to0