-
常见函数的四种类型
匿名函数-定义时候没有任何变量引用的函数
匿名函数自调:如果函数只执行一次
(function(a,b){
console.log('a = ', + a)
console.log('b = ', + b)
})(1, 2);
回调函数
递归函数
构造函数
查看全部 -
BOM浏览器对象模型
history 栈
window.history属性指向 History 对象,表示当前窗口的浏览历史 www.baidu.com
History.back()、 History.forward()、 History.go()
History.pushState(), History.replaceState()
Location 对象window.location和document.location属性 可以拿到这个对象
location.herf 整个UIRL
Location.protocol 当前URL的协议 包括冒号(:)和端口
Location.port 端口号
Location.pathname URL 的路劲部分,从根路劲开始
Location.search 查询字符串部分 从问号?开始
Location.hash 片段字符串部分 从#开始
Location.username 域名前面的密码
Location.origin URL 的协议、主机名和端口
查看全部 -
// 事件委托
var obj2 = document.getElementById('demo2')
obj2.addEventListener('click', function(e){
var e = e || window.event;
if(e.target.nodeName.toLowerCase() == 'li' { // IE8: e.srcElement
alert(e.targe.innerHTML);
}
}, false);
查看全部 -
堆就是在栈中存储一个地址 通过地址找到对应的数据
栈就是原始类型的数据存储 就像鸭子弹一样
查看全部 -
闭包是指有权访问另一个函数作用域中的变量的函数。——《JavaScript高级程序设计》
查看全部 -

1.关于typeof null,机器码后三位000(与对象完全一样)
2. typeof function 为什么是function而不是object,在于是否存在call方法
查看全部 -
// 什么是栈:计算机为原始类型开辟的一块内存空间 string number ...
// 什么是堆:计算机为引用类型开辟的一块内存空间 object
var a = 'MOOC';
var b = a;
console.log(a, b); // MOOC MOOC2
var c = {key: 1};
var d = c;
d.key = 2;
console.log(c, d); // 2, 2
// ['MOOC', 'MOOC2']
// c d ['x00000018', 'x00000018'] -> { {key: 1} }
// c d x00000018 -> {key: 2}
查看全部 -
// instanceof 检测 bool: true false
// A instanceof B
console.log([] instanceof Array); // true
console.log({} instanceof Object); // true
console.log(new Date instanceof Date); // true
function Person(){};
console.log(new Person() instanceof Person); // true
console.log([] instanceof Object); // true
console.log(new Date instanceof Object); // true
console.log(new Person() instanceof Object); // true
// instanceof 原型链 A instanceof B true, B instanceof C true
// 儿子 爸爸 爷爷
if(typeof(val) !== undefined) {}
console.log(Object.prototype.toString.call('1')); // string
console.log(Object.prototype.toString.call([])); // Array
查看全部 -
// typeof 检测 返回的是对应的数据类型
console.log(typeof(123)); // number
console.log(typeof(true)); // boolean
console.log(typeof('MOOC')); // string
console.log(typeof(undefined)); // undefined
console.log(typeof(null)); // object 为什么不null
// 计算机typeof 返回的数据类型 机器码 01011: 000 => object
// null 000000...000 => object
// js bug
console.log(typeof([])); // object // 引用
console.log(typeof(new Date())); // object
console.log(typeof({})); // object
console.log(typeof(function(){})); // function
console.log(typeof(Array)); // function 为什么不是object
// typeof 引用类型 object: object function
// object 定义一个[[call]] 如果已经定义了call方法就是 function 不是 object
var str = 'MOOC';
console.log(typeof(str)); // string
var str1 = new String('MOOC'); // 实例化后的对象
console.log(str1); // {} key : value 0:M 1:O ....
console.log(typeof(str1)); // object
查看全部 -

浅拷贝两种方式:遍历 和 Object.create()
查看全部 -
console.log(Object.prototype.toString.call('1') console.log(Object.prototype.toString.call('[]')查看全部 -
todo 没看懂
查看全部 -
包装对象:String Number Boolean
查看全部 -
JS中this的用法
代指当前调用这个对象
4中绑定规则:默认绑定、隐式绑定、显示绑定、new绑定。优先级从低到高。

改变this指向:call apply bind

手写一个bind方法

查看全部
举报