Is there a difference between String(x) and ''

后端 未结 4 420
陌清茗
陌清茗 2021-01-22 20:44

Is there a difference? Will string 2 inherit different object prototypes?

var s1 = 1234 + \'\';
var s2 = String(1234);

//s1.someNewFunc();   error?
//s2.someNew         


        
4条回答
  •  梦毁少年i
    2021-01-22 20:50

    Same thing!

    var s1 = 1234 + '';
    var s2 = String(1234);
    
    typeof s1   //string
    typeof s2   //string
    

提交回复
热议问题