zoukankan      html  css  js  c++  java
  • 复习:JS

    1. new操作执行了哪些过程?

    1. 创建一个新对象
    2. 空对象的对象原型(__proto__)指向构造函数原型对象(prototype
    3. 构造函数的this绑定空对象
    4. 执行构造函数返回这个新对象

    2. 箭头函数和普通函数有什么区别?

    1. this:箭头函数捕获上下文this,普通函数this指向声明处
    2. 不支持绑定:apply()/bind()/call()不会修改箭头函数获取的this
    3. 不支持new:箭头函数是匿名函数,不能当做构造函数
    4. 无法使用arguments参数,想要获取参数可以使用扩展符
    5. 箭头函数没有原型

    帮助理解:https://www.cnblogs.com/biubiuxixiya/p/8610594.html

    3. 数组方法对空位的处理是怎样的?

    1. 当做undefined:join(),toString(),被方法处理为空字符串
    2. 跳过不处理,结果保留位置:map()
    3. 跳过忽略:forEach(),filter(),reduce(),some()
    4. 明确转为undefined:Array.from(),扩展运算符,entries(),value(),keys(),for...of...,for...in...,find(),findIndex(),includes(),indexOf(),concat()
    5. 视为正常位置:fill(),copyWithin()将开始到结束的数据复制到指定起始位

    帮助理解:https://es6.ruanyifeng.com/#docs/array#数组的空位
    copyWithin()将开始到结束的数据复制到指定起始位

    4. 什么是原型链?

    构造函数生成的对象都有__proto__属性,它指向构造函数的prototype原型,终端是Object的__proto__指向null,由此形成一条原型链。在实例中没有的方法会和变量会沿着原型链向上查找。

    5. 哪些方法改变原数组?

    增删改排序: shift()/unshift()/push()/pop()/splice()/sort()/reserve()

    6. js基本数据类型?

    7个: number/string/boolean/undefined/null/object/symbol

    7. typeof()/instanceOf/Object.prototype.toString.call()的区别?

    1. typeof()无法区分具体对象和null,typeof(null)为对象
    2. instanceOf无法识别null作为依据;null/undefined和对象判断返回true;可以区分子类型;简单类型不能直接进行判断,返回false。
    3. Object.prototype.toString.call()可判断具体子类型和null。
    //返回类型
    Object.prototype.toString.call(undefined).slice(8,-1).toLowerCase()
    

    8. 浏览器缓存的一些问题

    V8浏览器,64位系统的内存为1.4G,32位系统的内存为700mb
    解决:
    代码上数组保存请求数据,超过上限栈的形式弹出。

  • 相关阅读:
    [LeetCode] Same Tree, Solution
    图搜索
    1 sec on Large Judge (java): https://github.com/l...
    [LeetCode] Path Sum, Solution
    嗯哪
    海量数据处理总结
    [LeetCode] Unique Binary Search Trees II, Solution
    [Interview] Serialize and Deserialize a tree
    设计题
    [LeetCode] Convert Sorted Array to Binary Search Tree, Solution
  • 原文地址:https://www.cnblogs.com/vera-7c/p/13802927.html
Copyright © 2011-2022 走看看