Create an instance of an object:
ES5 commonly used model constructor
function Person(name){ this.name = name; this.getName = function(){ return this.name } }
By defining classes class ES6
class Person{ constructor(name){ this.name = name; } getName(){ return this.name; }; }
1, all classes of methods are defined in the class prototype property above
2, methods, properties, classes and the prototype is not enumerable, so only through Object.getOwnPropertyNames whose properties (Person / Person.prototype), the method name to traverse;
Note: for-in and Object.keys () can only get enumerable properties, methods
reference:
http://es6.ruanyifeng.com/#docs/class