Daily-Interview-Question
Daily-Interview-Question copied to clipboard
我是依扬(木易杨),公众号「高级前端进阶」作者,每天搞定一道前端大厂面试题,祝大家天天进步,一年后会看到不一样的自己。
let sele = { 1: 222, 2: 123, 5: 888 } function tansformSele(obj) { let res = [null, null, null, null, null, null, null, null, null, null, null, null] for...
```js 'abcaakjbb' => {'a':2,'b':2} 'abbkejsbcccwqaa' => {'c':3} ``` 注意:题目说的是连续出现,注意连续二字
要求: 1、只能修改 `setTimeout` 到 `Math.floor(Math.random() * 1000` 的代码 2、不能修改 `Math.floor(Math.random() * 1000` 3、不能使用全局变量 ```js function print(n){ setTimeout(() => { console.log(n); }, Math.floor(Math.random() * 1000)); } for(var i = 0; i...
``` function toArr(obj){ console.log(Object.keys(obj)); return Array.from({length:12},(v,k)=>{ if(obj[k+1]===undefined){console.log("ok"); return null} else{return obj[k+1]} }) } ```
``` function myflatten(arr){ let res = [] let temp while(arr.length > 0){ temp = arr.shift() console.log("temp",temp); if(temp instanceof Array){ arr.unshift(...temp) } else{ res.push(temp) } } return res } ```
#### 1. npm 模块安装机制: - 发出`npm install`命令 - 查询node_modules目录之中是否已经存在指定模块 - 若存在,不再重新安装 - 若不存在 - npm 向 registry 查询模块压缩包的网址 - 下载压缩包,存放在根目录下的`.npm`目录里 - 解压压缩包到当前项目的`node_modules`目录 #### 2. npm 实现原理 输入 npm install 命令并敲下回车后,会经历如下几个阶段(以...
分别为undefined 10 20,原因是作用域问题,在内部声名var a = 20;相当于先声明var a;然后再执行赋值操作,这是在IIFE内形成的独立作用域,如果把var a=20注释掉,那么a只有在外部有声明,显示的就是外部的A变量的值了。结果A会是10 5 5