Toggle navigation
Genres
Frontend (2)
JavaScript (6)
Database (2)
Linux Server (3)
Web Apps (4)
Misc (4)
Search
List
New Tutorials
Last Modified Tutorials
</>
Code examples
code
smiko
javascript
basic
057wrapper_object.js
057wrapper_object.js
/** This code demonstrates that strings, numbers, and boolean values behave like objects when you try to read the value of a property (or method) from them. But if you attempt to set the value of a property, that attempt is silently ignored: the change is made on a temporary object and does not persist. The temporary objects created when you access a property of a string, number, or boolean are known as wrapper objects, and it may occasionally be necessary to distin- guish a string value from a String object or a number or boolean value from a Number or Boolean object. */ var s = "test"; //this is string s.len = 4; //setting a property doesn't take effect var t = s.len; console.log(t); //returns undefined because s.len=4 doent work
Reload page
Preview
W3C validation
Edit Code
JS Console