一、js中的数据类型json
js中有5中简单数据类型(也称为基本数据类型): Undefined、Null、Boolean、Number和String。一种复杂类型:Object
二、js变量按照存储类型分为值类型和引用类型数组
值类型: string number boolean undefined 引用类型: Object Array Function //数组和函数本质上也是对象 区别 值类型 引用类型 var a = 100; var a = {age: 100,name: '张三'} var b = a; var b = a; a = 200; a.age = 200; console.log(b) // 100 console.log(b) // Object {age: 200, name: "张三"}
三、变量计算-强制类型转化函数
· 字符串拼接 100 + '' // '100' · == 运算 null == undefined // true · if语句 · 逻辑运算 if语句 var a = true; if(a){ //.. } var b = ''; if(b){ //... } var c = 100; if(c){ //... } 其中b、c都转化为了布尔值 逻辑运算 console.log(10 && 0); // 0 console.log( '' || 'abc'); // 'abc' console.log(!window.abc) //true // 判断一个变量会被当作true仍是false var a = 100; console.log(!!a); // true
四、js中使用typeof能获得的类型code
typeof undefined // undefined typeof 'abc' // string typeof 123 // number typeof true // boolean typeof {} // object tyoepf [] // object typeof null //object typeof console.log //function
五、js中有哪些内置函数-数据封装类对象对象
Object Array Boolean Number String Function Date RegExp Error
六、如何理解JSON字符串
//json 是一个js内置对象,相似Math // json也是一种数据格式 JSON.stringify({a:10,b:100}); js对象转json JSON.parse('{"a":10,"b":100}'); json转js对象