Define an object and get the descriptor of a certain attribute: for example
let obj = {name: 'Andy'};
let descriptor = Object.getOwnPropertyDescriptor(obj, 'name');
The Object here should be a constructor. Why can the getOwnPropertyDescriptor method be called? Hope you can enlighten me
给我你的怀抱2017-07-05 10:39:23
Object is the top-level object of JavaScipr!
In js, there are two concepts: prototype and prototype chain. Instance objects only have prototype chains, while function objects and objects have their own prototypes.
Function objects and objects are the two top-level objects of JavaScipr, whether they are functions Whether instantiated objects, custom objects, array objects, etc., their prototypes are based on these two.
学习ing2017-07-05 10:39:23
function Template () {
// 在用 new 操作符 调用的时候,这就是构造函数
};
Template.staticMethod = function() {
// 静态方法
};
Template.prototype.instanceMethod = function() {
// 实例方法
};
This should not be difficult to understandObject
The implementation principle is the same