Acceso a métodos privados de JS
Estoy trabajando para tratar de hacer un objeto JS y acceder a métodos privados. El problema con el que me encuentro al intentar devolver una función es que no se puede acceder a los métodos privados. Código abajo.
var Item = (function() {
var price = 0;
var name = '';
var description = '';
var quantity = '';
var attributes = {};
var Item = function(data) {
}
function setPrice(variable) {
this.price = variable;
};
function getPrice() {
return this.price;
};
function setName(variable) {
this.name = variable;
};
function getName() {
return this.name;
};
function setDescription(variable) {
this.description = variable;
};
function setQuantity(variable) {
this.quanity = variable;
};
return function(data){
setPrice : setPrice;
getPrice : getPrice;
setName : setName;
setDescription : setDescription;
setQuantity : setQuantity;
return new Item(data);
}
})();
item2 = Item();
item2.setPrice('3');
alert(item2.getPrice());
Con esta configuración, ¿cómo puedo acceder a los métodos privados?