js方面

1判断数组的方法:

        1.arr instanceof Array

        2.arr.constructor == Array

                           3.Object.prototype.toString.call(ob                j) === '[object Array]'

        4.Array.isArray(arr)

2.Object.create()

        方法创建一个新对象,使用现有的对象来提供新创建的对象的proto

3. let const var 区别

        let作用域是块级作用域、不存在变量提升、不能重复定义、存在暂时性死区

        const的声明的变量不允许改变

4.基本类型: String Number Boolean Null Undefined  栈内存保存简单数据段

    引用类型: 对象、数组、函数、正则   保存在堆内存的  

5. call\apply\bind实现

    Function.prototype.newCall = function(context, ...arr) {

            if (typeof context === 'object') {

                    context = context || window;

            } else {

                    context = Object.create(null)

            }

            let fn =Symbol();

            context[fn] = this;

            context[fn] (...arr);

            delete context[fn];

        }

Function.prototype.newBind = function (context, ...innerArgs) {

    var me = this;

    return function (...finnalArgs) {

        return me.call(context, ...innerArgs, ...finnalArgs)

    }   

}

 6.  介绍事件循环

        (macro)task 主要包含:script( 整体代码)、setTimeout、setInterval、I/O、UI 交互事件、setImmediate(Node.js 环境)

microtask主要包含:Promise、MutaionObserver、process.nextTick(Node.js 环境)

7.定时器不准原因: eventloop循环机制中,异步事件set interval到时回把回调函数放入消息队列,主线程的任务执行完毕后,依次执行消息队列的任务,由于消息队列中存在大量任务,其他任务执行时间就会造成定时器回调函数的延迟,如果不处理会一直叠加延迟

        使用web Work

                let work = new Work()

8.原型介绍

        原型就是一个属性,这个属性是构造函数的属性,后面所有的对象都会继承原型的属性与方法.

9.继承方法: 

    1.原型链继承:

            Cat.prototype = new Animal();

    2.构造继承:

            function  Cat() { Animal.call(this);}

    3.实例继承

            function Cat() { var instance = new Animal(); return instance }

    4.拷贝继承        

    5.组合继承

         function Cat() {  Animal.call(this)  }

         Cat.prototype = new Animal();

         Cat.prototype.constructor = Cat;

    6.es6的extends继承

            class Chinese extends Person {

                    constructor() {
                            super()

                            }

                }

        7.闭包的介绍和它的作用:

                闭包就是能够读取其他函数内部变量的函数.

                     可以读取函数内部的变量;让这些变量的值始终保存在内存中

        8.new的实现过程

                1.创建了一个空对象,将它的引用赋给this,继承函数的原型;

                2.通过this将属性和方法添加至这个对象

                3.最后返回this指向新对象,也就是实例

你可能感兴趣的:(js方面)