1. 程式人生 > 其它 >VBA 簡單的資料獲取,寫入SHEET(ORACLE)

VBA 簡單的資料獲取,寫入SHEET(ORACLE)

技術標籤:javascript

【紅寶書p207】訪問器屬性用法

let book = {
            // 物件裡面的屬性實則可以被直接訪問
            year_: 2017,
            edition: 1
        };

準備以上物件,通過訪問器屬性間接修改物件裡面屬性的值
es5的用法

 // es5
        Object.defineProperty(book, "year", {
            get() {
                return this.year_;
            },
            set(newValue) {
                if (newValue > 2017) {
                    this.year_ = newValue;
                    this.edition += newValue - 2017;
                }
            }
        });
        console.log(book.year_, book.edition);//2017 1
        book.year = 2018;
        console.log(book.year_, book.edition);//2018 2

es5之前的用

 book.__defineGetter__("year", function () {
            return this.year_;
        });
        book.__defineSetter__("year", function (newValue) {
            this.year_ = newValue;
            this.edition += newValue - 2017;
        });
        console.log(book.year_, book.edition);//2017 1
        book.year = 2018;
        console.log(book.year_, book.edition);//2018 2 

在這裡插入圖片描述