Código Javascript:
Ver original
var Constructor = function(){ //properties this.public_prop = "publico"; var private_prop = "privado"; //methods var private_meth = function(){ return private_prop; }; this.public_meth = function(){ return this.public_prop + private_prop; }; }; var objeto = new Constructor(); console.log(objeto.public_prop); //"publico" console.log(objeto.public_meth()); //"publicoprivado" console.log(objeto.private_prop); //undefined console.log(objeto.private_meth());//Uncaught TypeError: Object [object Object] has no method 'private_meth'
Pero notación literal?
Código Javascript:
Ver original
var plainObject = { //... ¿como hago acá? ¿se puede? };