题目1:如何判断一个变量是数组类型

答案:

var arr = [];
arr instanceof Array//true
typeof arr //object  typeof 是无法判断数组的

题目2:原型链继承的例子(原型链继承,还有很多方法 参考我的js系列继承的6种方式)

答案:

function Animal(){
     this.eat = function(){
         console.log('animal  eat')

    }

}

function Dog(){
    this.bark = function(){
       console.log('bark')
    
     }

}

Dog.prototype = new Animal();

var hashiqi = new Dog()

题目3:描述new一个对象的过程

答案: ①、创建一个新对象 ②、this指向这个新对象  ③、执行代码,即对this赋值  ④、返回this

题目4:创建对象的几种方式(字面量方式、构造函数模式、Object.create())

答案:

js面试题-----原型和原型链

 

题目5:原型、构造函数、实例、原型链

答案:

js面试题-----原型和原型链

 

题目6:instanceof

答案:

js面试题-----原型和原型链

题目7:new运算符

答案:

js面试题-----原型和原型链

 

相关文章:

  • 2021-12-01
  • 2022-12-23
  • 2022-12-23
  • 2021-09-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-19
  • 2021-04-10
  • 2021-06-22
  • 2021-09-30
相关资源
相似解决方案