我一直在學習OOP和JavaScript中玩耍,並想知道如何得到的東西看起來像這樣的工作中......獲取功能,從目標函數
function myApp(){
this.nav = function(){
function toggle(state = 'show'){
//toggle nav code...
}
toggle();
}
}
var app = new myApp();
app.nav();
怎麼會去訪問切換功能從這裏像這樣...
app.nav().toggle('hide');
你的函數必須返回'{切換:函數(){...}}'是可鏈接 – adeneo