标签:eof lin func asc 方法 null 其他 eal world
1. ttypeof
对于基本类型,除了null类型其他类型都能判断正确。
JS 中分为七种内置类型,七种内置类型又分为两大类型:基本类型和对象(Object)(引用类型)。
基本类型有六种: null,undefined,boolean,number,string,symbol。
1 var up="he is a super man"; 2 var output=up.charAt(5); 3 console.log(output);//a
当执行 第二行代码时后台会 var up=new String("he is a super man");
找到对应的包装对象,包装成一个和up值相等的对象返 回
var output=up.charAt(5);
调用方法返回给output,
up=null; 然后销毁
2.Object.prototype.toString
JavaScript里使用typeof判断数据类型,只能区分基本类型,即:number、string、undefined、boolean、object。null、array、function、object来说,使用typeof都会统一返回object字符串。typeof是不行的。在JS中,可以通过Object.prototype.toString方法,判断某个对象之属于哪种内置类型。1 var up="he is a super man"; 2 var x = Object.prototype.toString.call(up); 3 console.log(x); //[object String]
标签:eof lin func asc 方法 null 其他 eal world
原文地址:https://www.cnblogs.com/fangshu/p/10630940.html