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
advanced
variables
04var_primitiveToObject.js
04var_primitiveToObject.js
/** * Converting primitive data types: string, number and bool * into object data type */ //converting string into object var name = 'John'; var name_obj = new String(name); var type1 = typeof name; var type2 = typeof name_obj; console.log('name data type: '+type1+' - '+name); console.log('name_obj data type: '+type2+' - '+name_obj); //converting number into object var year = 1971; var year_obj = new Number(year); var type1 = typeof year; var type2 = typeof year_obj; console.log('year data type: '+type1+' - '+year); console.log('year_obj data type: '+type2+' - '+year_obj);
Reload page
Preview
W3C validation
Edit Code
JS Console