function Equipment() {
const Bag = [];
function addTools() {
for (var i=0; i < tools; i++) {
Bag.push(tools.item1)
}
}
}
function tools() {
this.item1 = {
name: "item1",
price: 5,
count: 10
};
this.item2 = {
name: "item2",
price: 15,
count: 20
};
this.item3 = {
name: "item3",
price: 20,
count: 30
};
this.item4 = {
name: "item4",
price: 30,
count: 40
};
this.item5 = {
name: "item5",
price: 40,
count: 50
};
}
const equipment = new Equipment();
const tools = new Tools();
equipment.addTools(tools)
function Equipment() {
var Bag = [];
this.addTool = function(tool) {
Bag.push(tool);
console.log("Added. Bag:", Bag);
}
}
function Tools() {
this.item1 = {
name: "item1",
price: 5,
count: 10
};
this.item2 = {
name: "item2",
price: 15,
count: 20
};
this.item3 = {
name: "item3",
price: 20,
count: 30
};
this.item4 = {
name: "item4",
price: 30,
count: 40
};
this.item5 = {
name: "item5",
price: 40,
count: 50
};
}
var equipment = new Equipment();
var tools = new Tools();
equipment.addTool(tools.item1); //
function Equipment() {
const Bag = [];
function addTools() {
for (var i=0; i < tools; i++) {
Bag.push(tools.item1)
}
Object.assign(Bag, new tools);
console.log('=== ', Bag.item2)
}
addTools()
}
function tools() {
this.item1 = {
name: "item1",
price: 5,
count: 10
};
this.item2 = {
name: "item2",
price: 15,
count: 20
};
this.item3 = {
name: "item3",
price: 20,
count: 30
};
this.item4 = {
name: "item4",
price: 30,
count: 40
};
this.item5 = {
name: "item5",
price: 40,
count: 50
};
}
Equipment();