1 静态方法
1.1 判断是否为数组
-
-
- 使用Array的静态方法 -
1 | Array.isArray( array ) |
-
-
- 使用原型toString方法,返回的字符串第二个词表示构造函数
+
Classes
1 Class-Like structures in ecma5
- more >> + more >> -1
2
3
4
5
6
7
8
9
10
11
12
13
14// property
function PersonType(name){
this.name = name;
}
// methods: be assigned to the prototype
// all instances of the object share the same function
PersonType.prototype.sayName = function(){
console.log(this.name);
}
let person = new PersonType('chochi');
person.sayName();
// person is a instance of obeject and PersonType