Saturday, 27 April 2013

private variable to Javascript object literal

var dataset = {
tables: {
customers:function(){
var privateVar = 'foo';
return {
cols:[ /*here*/ ],
rows:[ /*here*/ ],
getPrivateVar: function()
{
return privateVar;
}
};
}(),
orders:{
cols:[ /*here*/ ],
rows:[ /*here*/ ]
}
},
relations: [{
parent:'customers',
child:'orders',
keyparent:'custid',
keychild:'orderid',
onetomany:true
}]
};
alert( dataset.tables.customers.getPrivateVar() );
view raw gistfile1.js hosted with ❤ by GitHub


http://stackoverflow.com/questions/1396294/how-to-add-private-variable-to-this-javascript-object-literal-snippet

No comments:

Post a Comment