function hideData () { var data = {} return { set:function(key,val){ data[key]=val }, get:function (key) { return data[key] } } } var hide = hideData() hide.set('name','黄石有') console.log(hide.get('name'))