JavaScript隐式转换

来源:互联网 发布:中印软件产业园 编辑:程序博客网 时间:2024/05/20 10:13

JavaScript隐式转换

+和-

"37"-7 // 30  字符串变数字"37"+7 //377"100"-0 //100 字符串变数字100+"" // "100" 数字变字符串

a==b(弱等于)

"1.23"==1.230==falsenull==undefinednew Object()==new Object()[1,2]==[1,2]

a===b(严格等于)
1.类型不同,返回false
类型相同:

null===null undefined===undefinedNaN!=NaNnew Object !=new Object

类型检测

typeofinstanceofObject.prototype.toStringconstructorduck type

特殊运算符

名称 运算符 条件运算符 c?a:b 逗号运算符 a,b delete delete obj.x in “document” in window instanceof obj instanceof Func new new ClsName() this return this; typeof typeof 100 void void 0
原创粉丝点击