4. JavaScript:
★ Created by Brendan Eich 1995
★ Developed in less than 2 Weeks
★ First release in NetScape 2
★ Influenced by Scheme,Java,Self
★ Interpreted language
★ Object-Oriented
Friday, 13 May 2011
19. // 6, manual type conversion
parseInt("1", 10) + 2 + 3;
parseInt: Parses a string argument and returns an
integer of the specified radix or base.
Friday, 13 May 2011
26. typeof return values:
★ string
★ number
★ boolean
★ function
★ object
★ undefined
Friday, 13 May 2011
27. typeof fanClub // "undefined"
var title = "Conan the Barbarian";
typeof title // Equals "string"
var age = 64;
typeof age // Equals "number"
Friday, 13 May 2011
28. function anotherQuote() {
return "If it bleeds, we can kill it.";
}
typeof anotherQuote; // "function"
Friday, 13 May 2011
29. var obj = {};
typeof obj // "object"
var arr = ["A", "R", "N", "O", "L", "D"];
typeof arr // "object"
Friday, 13 May 2011
30. var obj = {};
typeof obj // "object"
var arr = ["A", "R", "N", "O", "L", "D"];
typeof arr // "object"
Blimey!
Friday, 13 May 2011
44. Object literal
var arnold = {
name : "Arnold Schwarzenegger",
gotAnOscar : true
};
alert(arnold.name); // "Arnold Schwarzenegger"
Friday, 13 May 2011
45. Object notation
arnold["arms"] = 2;
arnold.arms = 2;
did you just say array?
Friday, 13 May 2011
46. Object notation
arnold["arms"] = 2;
arnold.arms = 2;
Same thing, different syntax
Friday, 13 May 2011
47. works with any object
var arnold = {};
arnold[1972] = "Year of birth";
arnold["born"] = 1972;
arnold[true] = false;
Friday, 13 May 2011
48. var decentMovie = {
title : "Red Sonia",
year : 1997
};
for (var item in decentMovie) {
/*
make sure we only check decentMovie
and not the whole prototype chain
*/
if (decentMovie.hasOwnProperty(item)) {
alert(item + ": " + decentMovie[item]);
}
}
Friday, 13 May 2011
49. Arni aside, srsly.
How do I use all of
this in real life?
Friday, 13 May 2011
50. // TAG namespace
TAG = window.TAG || {};
var TAG = (function ($) {
// private vars
var
privateVar1 = $('#boo-selecta'),
privateVar2 = $('#braaap'),
badAssArray = [];
return {
// approvals module
approvals: {
methodCall1: function (jQuery, TAG) {
alert("some string");
}
}
};
})(jQuery);
TAG.approvals.methodCall1(); // "some string"
Friday, 13 May 2011