Flores de Mayo-history and origin we need to understand
Architecting JavaScript Code
1.
2.
3.
4.
5.
6.
7.
8. function myNonClosure() { Variable lost after
var date = new Date(); function returns
return date.getMilliseconds();
}
9. function myClosure() { Variable stays around
var date = new Date(); even after function returns
//nested function
return function () {
return date.getMilliseconds();
};
}
10.
11.
12. var calc = new Calculator('eqCtl');
calc.add(2,2)
13.
14.
15.
16. var Calculator = function() {
//private variables
//private functions
return {
//public members
};
};
17. var Calculator = function(eq) {
//private member
var eqCtl = document.getElementById(eq);
return {
var calculator = new Calculator('eq');
//expose public member calculator.add(2,2)
add: function(x,y) {
var val = x + y;
eqCtl.innerHTML = val;
}
};
};
23. // main.js
require(["Customer"],
// Requires the Customer Module
function (Customer) { // Call with required Module(s)
// Your Initialization Code
var c = new Customer("A Customer");
var name = c.name;
}
);
24. // Customer.js
define( [], // Required Scripts (None)
function(){
// Gets any required modules here like main
function Customer (name) {
this.name = name
}
return Customer; // Return the object that Requires
//constructor to allow you to call it
}
HTML5 JavaScript codeTraditional ASP.NET vs ASP.NET MVCLoad views first and get all data – talk about Windows Azure Preview Portal, pivotal trackeretcSPAWindows 8 WinRT with HTML and JavaScript