剖断字符串

 1 var str1=new String('str1');
 2 var str2='str2';
 3 console.log(typeof str1);//object
 4 console.log(typeof str2);//string
 5 console.log(str1 instanceof String);//true
 6 console.log(str2 instanceof String);//false
 7 console.log(str1.constructor==String);//true
 8 console.log(str2.constructor==String);//true
 9 
10 var a = ['hello','world'];
11 console.log(typeof a);//object
12 console.log(a.toString());//hello,world
13 console.log(Object.prototype.toString.call(a));//[object Array]
14 console.log(Array.prototype.isPrototypeOf(a));//true
15 console.log(Array.isArray(a));//true
16 console.log(a instanceof Array);//true
17 console.log(a instanceof Object);//true
18 console.log(a.constructor==Array);//true
19 console.log(a.constructor==Object);//false
20 
21 var b = {'hello':'world'};
22 console.log(typeof b);//object
23 console.log(b.toString());//[object Object]
24 console.log(Object.prototype.toString.call(b));//[object Object]
25 console.log(Object.prototype.isPrototypeOf(b));//true
26 console.log(b instanceof Object);//true
27 console.log(b.constructor==Object);//true

澳门葡京,剖断字符串。 

This entry was posted in 未分类. Bookmark the permalink.

相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

*
*
Website