-
configurable 与 writable 和delete/getter/setter/修改属性便签的环境中的关系。查看全部
-
javascript 有六种数据类型,五种原始数据,number,sring,null,unidefind 还有一个对象object查看全部
-
中间有三个等号的是严格等于查看全部
-
应该截图这个查看全部
-
1种对象类型,5种原始类型,6种类型查看全部
-
JS严格模式 VS 一般模式查看全部
-
JS隐式转换的具体规则。查看全部
-
JS数据类型,5种原始类型,1种对象类型。总共6种数据类型。查看全部
-
序列化查看全部
-
属性标签查看全部
-
原始数据类型查看全部
-
使用Object.prototype上的原生toString()方法判断数据类型,使用方法如下: Object.prototype.toString.call(value) 1.判断基本类型: Object.prototype.toString.call(null);//”[object Null]” Object.prototype.toString.call(undefined);//”[object Undefined]” 2.判断原生引用类型: 函数类型 Function fn(){console.log(“test”);} Object.prototype.toString.call(fn);//”[object Function]” 日期类型 var date = new Date(); Object.prototype.toString.call(date);//”[object Date]” 数组类型 var arr = [1,2,3]; Object.prototype.toString.call(arr);//”[object Array]” 正则表达式 var reg = /[hbc]at/gi; Object.prototype.toString.call(arr);//”[object Array]” 自定义类型 function Person(name, age) {this.name = name;this.age = age;} var person = new Person("Rose", 18); Object.prototype.toString.call(arr); //”[object Object]” 很明显这种方法不能准确判断person是Person类的实例,而只能用instanceof 操作符来进行判断,如下所示: console.log(person instanceof Person);//输出结果为true 3.判断原生JSON对象: var isNativeJSON = window.JSON && Object.prototype.toString.call(JSON); console.log(isNativeJSON);//输出结果为”[object JSON]”说明JSON是原生的,否则不是;查看全部
-
typeof 判断基本类型(number,boolean,function,string,undefined) instanceof 判断相关对象类型(new object, new Date) Object.prototype.toString.call(element) 判断基本所有的类型。。查看全部
-
if("number" == typeof element){ type = "Number"; }else if ("boolean" == typeof element){ type = "Boolean"; }else if("function" == typeof element){ type = "function"; }else if("string" == typeof element){ type = "String"; }else if ("undefined" == typeof element){ type = "undefined"; }else if (element === null ){ type = "null"; }else if (element instanceof Date){ type = "date"; }else if (Object.prototype.toString.call(element) == "[object global]"){ type = "window"; }else if (Object.prototype.toString.call(element) == "[object Object]"){ type = "Object"; }查看全部
-
当需要一层一层的访问 某些数据的时候,我们就可以使用 with ,这样会比较方便很多 但是,JS已经不怎么采用了 原因:JS引擎优化更难 可读性差 可被变量定义代替 严格模式下被禁用查看全部
举报
0/150
提交
取消