估计是凉凉,伤心。
- this指针指向问题,关注setTimeout中,this应该是指向window的
function A() {
A.prototype.start=function() {
const a = setTimeout(()=>{
console.log(this);
},0)
const b = setTimeout(function() {
console.log(this);
},0)
}
}
let i = new A();
i.start();
A{} Window
- Promise 调用的题
const p = new Promise((resolve)=>{
throw new Error("Oops");
console.log("1");
resolve();
})
抛出异常
Cookie和localStorage区别
Cookie的是一个文本字段,用来存储少量数据(4kb)是服务器发给客户端的,但是在每次的http请求都会带上cookie。localStorage是一个持久的数据存储,保存在本地,能够在多个页面共享数据。sesseionStorage只在每个会话中产生,当标签页关闭或者浏览器关闭时,但是刷新时不会被清空,会被自动清空,不能够在多个页面中共享。协同缓存和强缓存 字段 304
304是协同缓存服务器发送的确认字段,协同的报头有etag>last-modified,强缓存的报头有cache-control(max-age)>expires表明缓存资源是否过期。