1、构造函数(相对于面向对象编程语言里面的类)

2、对象实例(它是由构造函数构造出来的对象,使用到关键字 new)

3、this关键字(往往是指我们的对象本身)

下面我们来看一个实例:

var Person = function Person(living, age, gender) {

    // "this" below is the new object that is being created (i.e. this = new Object();)

this.living = living;

this.age = age;

this.gender = gender;

this.getGender = function() {return this.gender;};

}

// when the function is called with the new keyword "this" is returned instead of false

// instantiate a Person object named cody

var cody = new Person(true, 33, 'male');

// cody is an object and an instance of Person()

console.log(typeof cody); // logs object

console.log(cody); // logs the internal properties and values of cody

console.log(cody.constructor); // logs the Person() function

最新文章

  1. Ubuntu Dev Box Setup
  2. CSS深入研究:display的恐怖故事解密(2) - table-cell
  3. 【洛谷P2889】Milking Time
  4. jQuery学习笔记---兄弟元素、子元素和父元素的获取
  5. mongoose的promise(转发)
  6. 2014-2015 ACM-ICPC, Asia Xian Regional Contest G The Problem to Slow Down You 回文树
  7. 浅谈MVC模式
  8. Android studio中添加外部的jar包
  9. 如何把函数都用promise方式实现?
  10. win7+ ubuntu 双系统
  11. c# List实现原理
  12. C学习笔记(自增)
  13. IntelliJ IDEA使用SVN检出项目到本地工作空间
  14. shell脚本一键安装redis
  15. RestfulAPI超简单入门
  16. OpenStack云桌面系列【2】—OpenStack和Spice
  17. python3 线性同余发生器 ( random 随机数生成器 ) 伪随机数产生周期的一些探究
  18. DLL文件的使用
  19. WPF进阶之接口(3):INotifyPropertyChanged,ICommand
  20. openwrt生成的镜像放在哪里

热门文章

  1. filter-mapping中的dispatcher使用
  2. windows下使用selenium报错selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH
  3. ActiveMQ教程(消息发送和接受)
  4. 决定整理一下canvas的基础学习
  5. # 2018-2019-2 20165210《网络攻防技术》Exp1 PC平台逆向破解(BOF实验)
  6. L171
  7. jenkins执行xctool命令出现command not found问题解决方法
  8. 在头文件中声明class 类 与 include类所在的头文件区别---理解
  9. Mac OS 升级到10.12问题 Android ADT 下载SDK问题 https://dl-ssl.google.com refused...
  10. 你离BAT之间,只差这一套Java面试题