js数据类型

一.基本数据类型:String, Number, Boolean,Null,undefined
复杂数据类型:Object(object,array,function)
二.
typeof Number—>function
typeof 123–> number

typeof String–>function
typeof ‘123’–>string

typeof null—> object
typeof undefined–>undefined

typeof object—>function
typeof window—>object

var arr =[1,2,3]
typeof arr—> object

function fun(){}
typeof fun—>function

<mark>var str = “123abc”;
alert(typeof str++); —>typeof NaN—>number</mark>
console.log(typeof undefined == typeof NULL); —> true (NULL未定义 不是null)

var result2 = “NaN” - 1+“abc”; —> NaNabc
var result3 =“3”+ 5 - 3; —> 32

规定:console.log(undefined==undefined) true

console.log(3!==“3”) //类型不同 true
console.log(null == 0); false

<mark>注:null和undefined属于无值类型,和其他任意类型比较均为false,但是null和undefined比较为true</mark>

3.var h5course = false;
var result = h5course / 0;
if(result){
console.log(result * 2 + ‘2’ + 4);
}else{
console.log(!result * 2 + ‘2’ + 4); 224
} // !NaN 为true —>1

全部评论

相关推荐

01-16 18:34
四川大学 Java
欢迎加入AI:没有啥稳定不稳定,一切都源于业务快速发展还是收缩。我当年一开始去的央企,业务不赚钱,也贼卷,慢慢就开始优化了。。。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务