this's tip
来源:互联网 发布:淘宝网小虫米子 编辑:程序博客网 时间:2024/06/05 04:34
构造函数时,this的一个tip.
function Person(){ var a = 1;//私有变量,只能函数内部访问使用,不是属性 this.b = 2;//实例变量,只能由实例化的新对象访问使用}Person.c = 3;//静态变量,也就是属性,由该类型访问console.log(a);//errorconsole.log(Person.a);//undefined;(只能函数内部访问使用,不是属性)console.log(Person.b);//undefined;(b只能由实例化的新对象访问使用)console.log(Person.c);//3var me = new Person();console.log(me.a);//undefinedconsole.log(me.b);//2console.log(me.c);//undefined
构造函数Person()中this指向当前实例化对象本身;
function Person(name){ this.name= name; console.log(this);}var me0 = new Person("me0");//Person {name: "me0"}name: "me0"__proto__: Objectvar me1 = new Person("me1");//Person {name: "me1"}name:"me1"__proto__:Object
阅读全文
0 0
- this's tip
- Gmail's Tip
- grub 多硬盘管理tip’s
- the tip's of office word
- tip
- Tip
- tip
- Tip:
- TIP
- Tip
- tip
- Tip
- Tip
- tip
- This's my life.
- this week`s feelings
- what's this?
- this's bug
- 多重背包模板题 背包问题V2
- python 试题:简述Python是如何进行内存管理的?
- RTOS任务
- XX和OO
- dubbo常用配置总结
- this's tip
- unity3d 基础 2017.9.17
- 657. Judge Route Circle
- 数据结构——队列、循环队列、链式队列主要操作函数的实现
- ORACLE自动扩展表空间添加数据文件
- IntelliJ IDEA 2017 提示“Unmapped Spring configuration files found.Please configure Spring facet.”解决办法
- FPGA中对竞争冒险问题的研究(转)
- 使用python对登录密码爆破
- 中文分词技术概要