日期:2014-05-16 浏览次数:20433 次
function Obj() { // Initialising code goes here: alert( 'Loaded!' ); // ... // Private properties/methods: var message = 'hello'; sayHello = function() { alert(message); }; // Public properties/methods: this.prop = function() { sayHello(); }; // Encapsulation: 封装 this.setMessage = function(newMessage) { message = newMessage; }; }