How to convert a JSON to work as Class for creating object
Here is my JSON
var nodeclienthash={
socket:null,
init : function() {
// initialize socket.io
this.socket = 开发者_开发问答new io.Socket(this.config.host, {port: this.config.port, rememberTransport: false});
}
};
For now i want to create only two object , how should i create that ?
function NodeClientHash() {
this.socket = null;
this.init = function() {
this.socket = new io.Socket(this.config.host, {port: this.congig.port, rememberTransport: false});
}
}
var client = new NodeClientHash();
精彩评论