字节前端社招面经

问项目
组件封装有哪些原则?
虚拟 DOM 的原理
*/
// setTimeout异步
// 当同步任务执行完毕,将task队列取出异步任务放入执行栈
// Last - Modified 表示本地文件最后修改日期
// etag类似文件指纹,值通常是使用内容的哈希值或最后修改时间戳的哈希值
const name = 'window'
const test = {
name: 'bill',
show1: function () {
console.log(this.name)//bill
},
show2: () => {
console.log(this.name) //undefined 箭头函数没有this
},
show3: () => {
function inner() {
console.log(this.name)//undefined 1、不是闭包:因为并未返回匿名函数 2 this指向show3
}
inner()
},
show4: function () {
return function () {
return this.name //window 此处是闭包,this指向window
}
},
}
test.show1
test.show2
test.show3
// 区别:for...in循环读取键名,for...of循环读取键值
// 使用的范围:数组、Set 和 Map 结构 、字符串。 因为他们有iterator属性,就被视为具有 iterator 接口
var arr = ['a', 'b', 'c', 'd'];
for (let a in arr) {
console.log(a); // 0 1 2 3
}
for (let a of arr) {
console.log(a); // a b c d
}
// Iterator 的作用:供for...of消费
// Iterator 的遍历过程:
var it = makeIterator(['a', 'b']);
it.next() // { value: "a", done: false }
it.next() // { value: "b", done: false }
it.next() // { value: undefined, done: true }
new Promise(() => {
throw new Error("throw");
}).catch(() => {
console.log('catch')//catch返回的内容会被resolve包裹成promise
}).then(() => {
console.log('then')
})
// 输出:
// catch
// then
let n = 0
// setState(n:this.n+1)
// setState(n:this.n+1)
setTimeout(() => {
// setState(n: this.n + 1)
// setState(n: this.n + 1)
}, 0);
// plugin 和loader区别
#笔经##字节跳动##社招#
全部评论
这是社招机试?
点赞
送花
回复
分享
发布于 2022-02-22 12:43

相关推荐

点赞 23 评论
分享
牛客网
牛客企业服务