let flag1 = true; let flag2 = false; //True False TRUE FALSE都是错误的 console.log(flag1); let flag3 = "true" console.log(flag3)
c.numbr-数字型,示例如下:
let age = 18; let date = "0306"; console.log(age) console.log(date) console.log(Number.MAX_VALUE)//最大值 console.log(Number.MAX_VALUE*2)//无穷大 Infinity var a = 3-"b" console.log(a);//NaN (Not a Number) NaN也属于数字类型 //isNaN判断是否是一个非数字 //如果是数字类型则为false //如果是非数字类型则为true console.log(isNaN(a));//true console.log(isNaN(111));//false console.log(isNaN("abc"));//true console.log(isNaN(Infinity));//false console.log(isNaN("false"));//tc.string-字符串,示例如下:
let demo1 = "字符串" let demo2 = '字符串' let demo3 = `字符串` let demo4 = "'字符串'" console.log(demo1) console.log(demo2) console.log(demo3) console.log(demo4) console.log("111\'22d.undefined-未定义型,示例如下:
// 表面声明变量还未赋值 let grade=undefined; console.log(grade);//undefined
console.log(1 + "1");//11 console.log(1 + "null");//1null console.log(null + "undefined");//nullundefined var name = "张三"; var age = 18 ; console.log(name+"的年龄是"+age); 隐式转换:当两个数据类型不同时,JS会按照既定的规则进行转换