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