Q1:有人可以解释如何触发setProperty中的setter,通过这种方式使用它的函数吗? Q2:如何获得setter中的最后一个键? fiddle is here function test(root) {
Object.defineProperty(this, 'subtree', {
get: function() {
console.log("get"
是否有无论如何添加一些静态方法类型如Date,String, Array等? 比如我想添加方法today到Date类,并在JavaScript中我可以将属性简单地添加到它也许我用Object.defineProperty: Date.today = function(){
let date = new Date;
date.setHours(0,0,0,0);
ret
这里 // inherit methods of Date to extend it.
var extendDate=Date.prototype;
// add year property to Date.prototype, thus to an instance of Date
/*extendDate.year={
get: function() { return thi