Computer >> Computer tutorials >  >> Programming >> Javascript

How and why does 'z'['toUpperCase']() in JavaScript work?


The toUpperCase() method in JavaScript is used to convert a string in uppercase. Here, a is a primitive value. You can use it as the following −

'z'['toUpperCase'];

Or use the following via bracket notation −

'z'['toUpperCase']();

The code snippet is the same as the following to convert to upper case −

alert('z'.toUpperCase())