This file contains hidden or 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 student = { | |
"name": "Bob Barker", | |
"age": 100 | |
}; | |
console.log(student.name); | |
console.log(student.age); | |
console.log(student["name"]); |
This file contains hidden or 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 person = { | |
"name": "Bob Barker" | |
}; | |
person.name = "Batman"; | |
//or | |
person["name"] = "Batman"; |
This file contains hidden or 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
// add | |
var add = function (a, b) { | |
return a + b; | |
}; | |
// or | |
function add (a, b) { | |
return a + b; | |
} |
This file contains hidden or 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 counter = { | |
value: 0, | |
increment: function () { | |
this.value += 1; | |
}, | |
reset: function () { | |
this.value = 0; | |
} | |
}; |
This file contains hidden or 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 person = { | |
first_name: "Robert", | |
last_name: "Barker", | |
nick_name: "Bob", | |
full_name: undefined, | |
name_helper: function (short) { | |
var shorter_name = function () { | |
this.full_name = this.nick_name + " " + this.last_name; | |
}; | |
This file contains hidden or 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 person = { | |
first_name: "Robert", | |
last_name: "Barker", | |
nick_name: "Bob", | |
full_name: undefined, | |
name_helper: function (short) { | |
var that = this; // the important part | |
var shorter_name = function () { | |
// this to that | |
that.full_name = that.nick_name + " " + that.last_name; |
This file contains hidden or 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 a = 100, | |
b = 0; | |
function change() { | |
var b = a + 5; | |
} | |
change(); | |
alert(b); |
This file contains hidden or 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 people = ['Bob', 'Sally', 'Sara', 'Frank']; | |
console.log(people.length); // 4 | |
var i; | |
var len = people.length; | |
for (i = 0; i < len; i += 1) { | |
console.log(people[i]); | |
} |
This file contains hidden or 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 a = []; // empty array | |
a.push('a', 'b', 'c', 'd', 'e'); // ["a", "b", "c", "d", "e"] | |
a.pop(); // ["a", "b", "c", "d"] | |
a.reverse(); // ["d", "c", "b", "a"] | |
var s = a.join(''); |
This file contains hidden or 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 button, button2, button3; | |
var i, xhr, activeXids = [ | |
'MSXML2.XMLHTTP.3.0', | |
'MSXML2.XMLHTTP', | |
'Microsoft.XMLHTTP' | |
]; | |
if (typeof XMLHttpRequest === "function") { | |
xhr = new XMLHttpRequest(); | |
} else { |