随笔分类 - 面试题
摘要:webpack是开发工具,面试考点重点在配置和使用,原理理解不需要太深。 webpack 本质上是一个函数,它接受一个配置信息作为参数,执行后返回一个 compiler 对象,调用 compiler 对象中的 run 方法就会启动编译。run 方法接受一个回调,可以用来查看编译过程中的错误信息或编译
阅读全文
摘要:防抖debounce: 防抖是在定义N的时间范围内,如果没有触发事件则执行,如果触发了时间重置进行下一轮判断。 使用场景例如一个输入框有搜索功能,当键盘输入停止了一段时间,判定用户结束或暂停输入,然后再进行接口搜索,避免每次输入都进行一次接口调用。 手写防抖函数: <input type="text
阅读全文
摘要:class jQuery { constructor(selector) { const result = document.querySelectorAll(selector) console.log(result) const length = result.length for (let i
阅读全文
摘要:Class的使用: // 父类 class People { constructor(name) { this.name = name } eat() { console.log(`${this.name} eat`) } } // 子类 class Student extends People {
阅读全文
摘要:const obj = { a: 100, b: { b1: [1, 2, 3], b2: 'string' }, c: ['a', 'b', 'c'] } /* * 没做深拷贝的效果 const obj2 = obj obj2.a = 200 obj2.b.b2 = 'abc123' obj2.c
阅读全文
摘要:var arr = [1,2,3,4,5] console.log(arr.slice(1,4)) console.log(arr) Function.prototype.bind1 = function(){ // arguments是个列表不是数组,将参数拆解为数组 const args = A
阅读全文
摘要:什么是闭包,闭包的表现形式: // 作用域应用的特殊情况,有两种表现: // 函数作为参数被传递 // 函数作为返回值被返回 // 函数作为返回值 function create() { let a = 100 return function () { console.log(a) } } let
阅读全文
摘要:// 一个对象里面,属性名不能重复,属性名一般是字符串,数字属性名==字符串属性名 /* let a={},b='0',c=0; a[b]='abc'; a[c]='123' console.log(a[b]) */ //考点进一步深入提问:对象和数组的区别 /* let a={},b=Symbol
阅读全文
摘要:下列代码的输出值: function A() { console.log(1) } function fn() { A = function () { console.log(2) } return this } fn.A=A fn.prototype = { A: () => { console.
阅读全文
摘要://拆分字符串形式 function queryToObj() { const res = {} const search = location.search.substr(1);//去掉前面的“?” search.split('&').forEach(paramStr => { const arr
阅读全文
摘要:// flatern 是摊平数组 function flat(arr) { const isDeep = arr.some(item => item instanceof Array) if(!isDeep){ return arr } const result = Array.prototype.
阅读全文
摘要:下面代码输出打印值顺序: async function async1(){ console.log('async1 start'); await async2(); console.log('async1 end'); } async function async2(){ console.log('
阅读全文
摘要:下列代码输出打印值: function Foo() { getName = function () { console.log(1); } return this; } Foo.getName = function () { console.log(2) } Foo.prototype.getNam
阅读全文
摘要:// 传统方式,遍历元素比较 function unique(arr) { const res = [] arr.forEach(item => { if (res.indexOf(item) < 0) { res.push(item) } }) return res } console.log(u
阅读全文
摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>手写ajax</title> </head> <body> <script> const xhr = new XMLHttpRequest(); xhr.ope
阅读全文
摘要:VUE2.0和3.0数据双向绑定的原理,并说出其区别。 代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>vue2.0/3.0双向数据绑定原理</title> </head> <body> 姓名:<sp
阅读全文
摘要:常见值类型: let a; //undefined let s = 'abc'; let n = 100; let b = true; let sb = Symbol('s'); let nn = NaN 常见引用类型: const obj = {x: 100}; const arr = [1, 2
阅读全文
摘要:如何理解语义化: 对应的内容是用相应意思的标签,增加开发者和机器爬虫对代码的可读性。 块状元素和内联元素: 块状元素有:display:block/table;有div h1 h2 table ul ol p等,这些元素特点是独占一行。 内联元素:display:inline/inline-bloc
阅读全文