JS 中使用typeof 得到哪些类型
考点:JS 变量类型
undefiend number boolean string object function
何时使用 === 和 ==?
考点: 强制类型转换
if (obj.a == null ){ // obj.a === null || obj.a === undefined 简写形式 // jquery 源码 }
window.onload 和DOMContentLoaded 区别
考点: 浏览器渲染过程
用JS 创建 10个 -< a >- 标签,点击时候弹出来对应序号
考点: 作用域
如何实现模块加载器,实现类似require.js 基本功能
考点:JS 模块化
实现数组的随机排序
考点: JS 基础算法
JS 中有哪些内置函数 (9)---数据封装类对象
- Object
- Array
- Boolean
- Number
- String
- Function
- Date
- RegExp
- Error
JS 变量按照存储方式分为那些类型,并描述其特点
- 值类型 vs 引用类型
如何理解JSON : 是一个JS 对象
-JSON.stringify({a:10, b: 20}); -JSON.parse('{"a":10, "b": 20}')
1、变量类型
值类型 vs 引用类型(对象、数组、函数)
var a = 100
var b = a
a = 200;
console.log(b) // 100
var a = { age: 20};
var b = a;
b.age = 21;
console.log(b) // 21
** 无限制扩展属性
typeof 运算符详解 (6种)
typeof undefined ; undefined
typeof 'abc'; string
typeof 122; number
typeof true; boolean
typeof {}; object
typeof []; object
typeof null; object
typeof console.log; function
* 只能区分值类型 *
2、变量计算
-
字符串拼接
var a = 10 + 10; // 20 var b = 10 + '10' // 1010 -
== 运算符
100 == '100'; // true ----字符串100 0 == '' // true --->转 false null == undefined; // true ---转 false -
if 语句
var c = ''; if(c) {...} -
逻辑运算 console.log(20 && 0) // 0 ---->10 >true ; 0 --> false console.log( '' || 'abc'); // 'abc' console.log(! window.abc) // true
// 判断 一个变量会被当作 true 还是false var a = 100; console.log(!!a);