Coding Ninjas Logo

Home > JavaScript Questions > Does JavaScript support automatic type conversion?

Does JavaScript support automatic type conversion?



Answer: Yes JavaScript does support automatic type conversion, Javascript provide two type of conversion 1-Automatic type(When some operations are needed on different datatype, javascipt convert it and perform)

Example:


console.log( 2 + '2' ); // 22 2-Explicit Type(We can convert datatype using javascript in built function)

Example:


var str = '180px';
var num = parseInt(str);
console.log( num ); // 180


Similar Questions