JS Coding Questions Logo
JS Coding Questions
#383💼 Interview💻 Code

What are wrapper objects

Advertisement

728x90

Primitive Values like string,number and boolean don't have properties and methods but they are temporarily converted or coerced to an object(Wrapper object) when you try to perform actions on them. For example, if you apply toUpperCase() method on a primitive string value, it does not throw an error but returns uppercase of the string.

javascript
1let name = "john";
2
3console.log(name.toUpperCase()); // Behind the scenes treated as console.log(new String(name).toUpperCase());

i.e, Every primitive except null and undefined have Wrapper Objects and the list of wrapper objects are String,Number,Boolean,Symbol and BigInt.

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 41

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
383of476