This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
<script> | |
window.onload = function () { | |
calculator.add(2,2); | |
calculator.subtract(2,2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Revealing Prototype Pattern</title> | |
<script> | |
window.onload = function () { | |
var calc = new Calculator('Output'); | |
calc.add(2,2); | |
calc.subtract(2,2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var box = {} | |
box['material'] = "cardboard" | |
box[0] = 'meow' | |
box['^&*'] = 'testing 123' | |
// since var is variable the interpreter hold different properties in bracket notation because key holds the value | |
for(var key in box) { | |
console.log(box[key]) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var animal = {}; | |
animal.username = 'Mittens'; | |
animal['tagline'] = 'pet me'; | |
var noises = []; | |
animal.noises = noises; | |
var count = 0; | |
for(var key in animal) { | |
count++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var box = [] | |
box['size'] = 9; | |
box['0'] = 'meow'; | |
box['size'] // 9 | |
console.log(box[0]); | |
// ['meow'] | |
// index # 0 | |
// {0: 'meow', 'size': 9} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var box = [] | |
box['size'] = 9; | |
box['0'] = 'meow'; | |
for (var k in box){ | |
console.log(k); | |
// prints out property names | |
} | |
for (var k in box){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var box = [] | |
box['size'] = 9; // doesn't return size because it's a string and not integer | |
box['0'] = 'meow'; | |
box.push("Whoohoo"); | |
for(var i =0; i < 2; i++) { | |
console.log(box[i]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var box = [] | |
box['size'] = true; | |
box[3] = {'hey': true}; | |
console.log(box.length); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// We are creating a constructor | |
function AnimalMaker(name) { | |
return { | |
speak: function () { | |
console.log("my name is ", name); | |
}, | |
name: name, | |
owner: "jason" | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function AnimalMaker(name) { | |
return { | |
speak: function () { | |
console.log("my name is ", name); | |
}, | |
name: name, | |
owner: "jason" | |
}; | |
}; |
OlderNewer