webpack编译后文件是怎么执行的
文件的相互依赖引用是怎么执行的
哔哩哔哩哔哩......
SplitChunksPlugin都什么作用
- chunks all async initial
- minSize: 30000,
- minChunks: 1,
- maxAsyncRequests: 5,
- maxInitialRequests: 3,
- automaticNameDelimiter: '~',
- name: true,
loader 和 plugin执行机制,如何编写
// loader
function (source) {
...do something
callback(source) // 同步的模式
callback = this.async
callback(source) // 异步的模式
}
// plugin
class TestPlugin {
apply (compiler) {
compiler.hooks.compile.tap('', () => {})
}
}
webpack是如何清缓存的
- contentHash
- chunkHash
- hash
Web Components
哔哩哔哩哔哩......不会
http 和 httpr
哔哩哔哩哔哩......不会
http缓存说一下
哔哩哔哩哔哩......
跨域操作
- cors用过么, 哦,是这个咯Access-Control-Allow-Origin
- 浏览器请求的method有哪几种,GET,POST,PUT,DELETE,OPTIONS
前端安全相关
哔哩哔哩哔哩......好吧,我又不会,就说了些egg的csrf
vue双向绑定实现
function Vue (options) {
this.data = options.data
defineProperty(this)
new Watcher(this.data, 'a', () => {
console.log('监听')
})
}
function defineProperty (target) {
const dep = new Dep()
Object.keys(target.data).forEach(key => {
Object.defineProperty(target, key, {
configurable: true,
enumerable: true,
get: function () {
if (Dep.target) {
dep.depend()
}
return target.data[key]
},
set: function (v) {
target.data[key] = v;
dep.notify()
}
})
})
}
function Dep () {
this.subs = [];
}
Dep.prototype.addSub = function (sub) {
this.subs.push(sub);
}
Dep.prototype.notify = function () {
const { subs } = this;
const len = subs.length;
let index = -1;
while (++index < len) {
subs[index].update();
}
}
Dep.prototype.depend = function () {
if (Dep.target) {
Dep.target.addDep(this);
}
}
Dep.target = null;
function Watcher (vm, key, cb) {
this.vm = vm;
this.cb = cb
this.get()
this.oldV = vm[key]
}
Watcher.prototype.get = function () {
Dep.target = this;
}
Watcher.prototype.addDep = function (dep) {
dep.addSub(this)
}
Watcher.prototype.update = function () {
this.cb()
}
const vm = new Vue({
data: {
a: 1,
b: 2
}
})
Promise实现
哔哩哔哩哔哩......就这样
for of 和 for in 的区别
for of 不能遍历对象,那么怎么操作可以让for of 去遍历对象
for of 不能遍历对象,那么怎么操作可以让for of 去遍历对象
原型与继承
- 有几种继承的方式
- __proto__与prototype的关系
哔哩哔哩哔哩......
es6了解么?
- async await怎么实现的?
哔哩哔哩哔哩......
node做过什么
哔哩哔哩哔哩......
rxjs使用过么,了解么
哔哩哔哩哔哩......没用过,好久之前看过一点
eslint 代码规范怎么做的
写过eslint插件么?
哔哩哔哩哔哩......只用过常规的rules
nginx 配置相关
哔哩哔哩哔哩......
闭包的概念
函数与对其状态即词法环境(lexical environment)的引用共同构成闭包(closure)。也就是说,闭包可以让你从内部函数访问外部函数作用域。在JavaScript,函数在每次创建时生成闭包。
.....剪不断理还乱,词法作用域,我举了下面这个例子,反正没说清
// 可以访问函数内部变量
var name = '华为全球'
function init() {
var name = '华为杭州'; // name 是一个被 init 创建的局部变量
function displayName() { // displayName() 是内部函数,一个闭包
alert(name); // 使用了父函数中声明的变量
}
return displayName
}
init()();
浏览器渲染优化
......
算法相关
二叉树深度优先遍历
// 前序遍历
var preorderTraversal = function (root, array = []) {
if (root) {
array.push(root.val);
preorderTraversal(root.left, array);
preorderTraversal(root.right, array);
}
return array;
};
二叉树广度优先遍历
function PrintFromTopToBottom(root) {
const result = [];
const queue = [];
if (root) {
queue.push(root);
while (queue.length > 0) {
const current = queue.shift();
if (current.left) {
queue.push(current.left);
}
if (current.right) {
queue.push(current.right);
}
result.push(current.val);
}
}
return result;
}
二叉树相邻父子节点最小距离
......
给定一个整数数组 nums ,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。
输入: [-2,1,-3,4,-1,2,1,-5,4],
输出: 6
解释: 连续子数组 [4,-1,2,1] 的和最大,为 6。
var maxSubArray = function(nums) {
var sum = nums[0]
var max = nums[0]
for (let i = 1; i < nums.length; i++) {
if (sum < 0) {
sum = nums[i]
} else {
sum = sum + nums[i]
}
if (max < sum) {
max = sum
}
}
return max
};
1为起点,2为终点,0为可通过,-1为不可通过,求1到2的所有路径
[
[1, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 2, -1]
]
打印机优先级输出
某个打印机根据打印队列执行打印任务。打印任务分为九个优先级,分别采用数字1~9表示,数字越大优先级越高。打印机每次从队列头部取出第一个任务A,然后检查队列余下任务中有没有比A优先级更高的任务,如果有比A优先级高的任务,则将任务A放到队列尾部,否则执行任务A的打印。请编写一个程序,根据输入的打印队列,输出实际打印顺序。
// 例如 9,3,5 输出 0,2,1
// 例如 1,3,1 输出 2,0,1
let arr = [3,1,6,0,9,5,2,4,8]
let temp = [...arr]
let len = temp.length
let idx = 0
let outArr = []
while (temp.length > 0) {
let isBig = false
let head = temp.slice(0, 1)
for (let i = 0; i < len; i++) {
if (head < temp[i]) {
isBig = true
break
}
}
if (isBig) {
temp.push(temp.shift())
} else {
temp.shift()
for (let i = 0; i < len; i++) {
if (arr[i] == head) {
outArr[i] = idx;
idx++
}
}
}
}