JavaScript入門–文字列とオブジェクトを変換する

サンプルコード
var str1 = new String(“koma");
var str2 = “koma";
console.log(str1 == str2);//true
console.log(str1 === str2);//false
console.log(typeof str1); //object
console.log(typeof str2); //string

var n1 = new Number(22);
var n2 = 22;
console.log(n1 == n2);//true
console.log(n1 === n2);//false
console.log(typeof n1); //object
console.log(typeof n2); //number

var b1 = new Boolean(false);
var b2 = false;
console.log(b1 == b2);//true
console.log(b1 === b2);//false
console.log(typeof b1); //object
console.log(typeof b2); //boolean

JavaScript

Posted by arkgame