1function runFunction() {
2 myFunction();
3}
4
5function myFunction() {
6 alert("runFunction made me run");
7}
8
9runFunction();
1function Product(name, price) {
2 this.name = name;
3 this.price = price;
4
5 if (price < 0)
6 throw RangeError('Cannot create product "' + name + '" with a negative price');
7 return this;
8}
9
10function Food(name, price) {
11 Product.call(this, name, price);
12 this.category = 'food';
13}
14Food.prototype = new Product();
15
16function Toy(name, price) {
17 Product.call(this, name, price);
18 this.category = 'toy';
19}
20Toy.prototype = new Product();
21
22var cheese = new Food('feta', 5);
23var fun = new Toy('robot', 40);