JS进阶(一)(面向对象、原型)

栏目: 后端 · 前端 · 发布时间: 6年前

  • 面向对象的思想是--->抽象的过程--->实例化的过程
  • function Person(name,age){
            this.name = name;
            this.age = age;
            this.eat = function(){};
        }
        //构造函数--->实例对象
        var per = new Person("xx",11);
        console.log(per.constructor == Person);//true
        console.log(per instanceof Person);//true
    复制代码
  • 实例对象和构造函数之间的关系:
    • 实例对象是通过构造函数来创建的--创建的过程叫实例化
    • 判断对象是否为该数据类型
      • 通过(原型)构造器的方式 实例对象.构造器 == 构造函数名字
      • 对象 instanceof 构造函数名字

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

CSS3 For Web Designers

CSS3 For Web Designers

Dan Cederholm / Happy Cog / 2010-11 / $18

From advanced selectors to generated content to the triumphant return of web fonts, and from gradients, shadows, and rounded corners to full-blown animations, CSS3 is a universe of creative possibilit......一起来看看 《CSS3 For Web Designers》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具