To break it down.
.toUpperCase()
is a method ofString.prototype
'a'
is a primitive value, but gets converted into its Object representation- We have two possible notations to access object properties/methods, dot and bracket notation
So
'a'['toUpperCase'];
is the access via bracket notation on the property toUpperCase
, from String.prototype
. Since this property references a method, we can invoke it by attaching ()
'a'['toUpperCase']();