rambomambo
Gebruiker
- Lid geworden
- 9 dec 2012
- Berichten
- 163
Hey
when i call DisplayThings i have an empty error when i make my array global then i see all my listitems.
but i want a local var. How can i fix this ?
when i call DisplayThings i have an empty error when i make my array global then i see all my listitems.
but i want a local var. How can i fix this ?
HTML:
function List(getproducts)
{
var productenlijst = [];
this.getProducts = function () {
return productenlijst;
}
}
List.prototype.add = function(p) {
this.getProducts().push(p);
}
var producten = new List();
//toevoegen van Producten
var standaardkorting = false;
producten.add(product1 = new Product(0,'Bazinga',12,'images/1.jpg',standaardkorting));
producten.add(product2 = new Product(1,'Sarcasm',14,'images/2.jpg',standaardkorting));
producten.add( product3 = new Product(2,'RPSLS',11,'images/3.jpg',standaardkorting));
producten.add(product4 = new Product(3,'Socks',39,'images/4.jpg',standaardkorting));
Wenslijst.prototype = Object.create(List.prototype);
Wenslijst.prototype.constructor = Wenslijst;
function Wenslijst (products)
{
var that = this;
this.voegtoe = function () {
return this.getProducts()
}
List.call(this,products)
}
Wenslijst.prototype.displayThings = function(){
return this.getProducts();
}
var wenss = new Wenslijst();
console.log(wenss.displayThings())