SlideShare ist ein Scribd-Unternehmen logo
1 von 27
function myNonClosure() {            Variable lost after
    var date = new Date();           function returns
    return date.getMilliseconds();
}
function myClosure() {           Variable stays around
var date = new Date();           even after function returns
//nested function
return function () {
     return date.getMilliseconds();
     };
}
var calc = new Calculator('eqCtl');
calc.add(2,2)
var Calculator = function() {
     //private variables
     //private functions

     return {
          //public members
     };
};
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;
                 }
           };
};
<html>
...
    <script source="first.js"></script>
    <script source="second.js"></script>
</html>


// first.js
(function(ns) {                                      // second.js
            ns.Customer = function() {               (function(ns) {
                    this.name = "";                           ns.Order = function() { ... };
            };                                       }(window.WilderMinds = window.WilderMinds || {}));
}(window.WilderMinds = window.WilderMinds || {}));
<!DOCTYPE html>
<html lang="en">
<head>
         <meta charset="utf-8">
         <title>RequireJS</title>
</head>
<body>
         <script src="scripts/require.js" data-main="scripts/lib/main.js">
         </script>
</body>
</html>
// 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;
       }
 );
// 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
}
Suresh.Balla@neudesic.com

Weitere ähnliche Inhalte

Was ist angesagt?

Functional Reactive Programming - RxSwift
Functional Reactive Programming - RxSwiftFunctional Reactive Programming - RxSwift
Functional Reactive Programming - RxSwiftRodrigo Leite
 
React, Redux, ES2015 by Max Petruck
React, Redux, ES2015   by Max PetruckReact, Redux, ES2015   by Max Petruck
React, Redux, ES2015 by Max PetruckMaksym Petruk
 
Reactивная тяга
Reactивная тягаReactивная тяга
Reactивная тягаVitebsk Miniq
 
Reactive Programming Patterns with RxSwift
Reactive Programming Patterns with RxSwiftReactive Programming Patterns with RxSwift
Reactive Programming Patterns with RxSwiftFlorent Pillet
 
Net/http and the http.handler interface
Net/http and the http.handler interfaceNet/http and the http.handler interface
Net/http and the http.handler interfaceJoakim Gustin
 
Testando API's de forma unitária mocando as dependências
Testando API's de forma unitária mocando as dependênciasTestando API's de forma unitária mocando as dependências
Testando API's de forma unitária mocando as dependênciasMarcelo Aymone
 
Demoiselle 2.0 no JavaOne Brasil 2010
Demoiselle 2.0 no JavaOne Brasil 2010Demoiselle 2.0 no JavaOne Brasil 2010
Demoiselle 2.0 no JavaOne Brasil 2010Cleverson Sacramento
 
Magento2&amp;java script (2)
Magento2&amp;java script (2)Magento2&amp;java script (2)
Magento2&amp;java script (2)EvgeniyKapelko1
 
Why You Shouldn't Write OO
Why You Shouldn't Write OO Why You Shouldn't Write OO
Why You Shouldn't Write OO Yehuda Katz
 
Async js - Nemetschek Presentaion @ HackBulgaria
Async js - Nemetschek Presentaion @ HackBulgariaAsync js - Nemetschek Presentaion @ HackBulgaria
Async js - Nemetschek Presentaion @ HackBulgariaHackBulgaria
 
Promises, promises, and then observables
Promises, promises, and then observablesPromises, promises, and then observables
Promises, promises, and then observablesStefan Charsley
 
AngulrJS Overview
AngulrJS OverviewAngulrJS Overview
AngulrJS OverviewEyal Vardi
 

Was ist angesagt? (18)

Functional Reactive Programming - RxSwift
Functional Reactive Programming - RxSwiftFunctional Reactive Programming - RxSwift
Functional Reactive Programming - RxSwift
 
16 18
16 1816 18
16 18
 
Hack tutorial
Hack tutorialHack tutorial
Hack tutorial
 
React with Redux
React with ReduxReact with Redux
React with Redux
 
React, Redux, ES2015 by Max Petruck
React, Redux, ES2015   by Max PetruckReact, Redux, ES2015   by Max Petruck
React, Redux, ES2015 by Max Petruck
 
Reactивная тяга
Reactивная тягаReactивная тяга
Reactивная тяга
 
Reactive Programming Patterns with RxSwift
Reactive Programming Patterns with RxSwiftReactive Programming Patterns with RxSwift
Reactive Programming Patterns with RxSwift
 
Net/http and the http.handler interface
Net/http and the http.handler interfaceNet/http and the http.handler interface
Net/http and the http.handler interface
 
Testing in JavaScript
Testing in JavaScriptTesting in JavaScript
Testing in JavaScript
 
Testando API's de forma unitária mocando as dependências
Testando API's de forma unitária mocando as dependênciasTestando API's de forma unitária mocando as dependências
Testando API's de forma unitária mocando as dependências
 
React и redux
React и reduxReact и redux
React и redux
 
Demoiselle 2.0 no JavaOne Brasil 2010
Demoiselle 2.0 no JavaOne Brasil 2010Demoiselle 2.0 no JavaOne Brasil 2010
Demoiselle 2.0 no JavaOne Brasil 2010
 
mediator
mediatormediator
mediator
 
Magento2&amp;java script (2)
Magento2&amp;java script (2)Magento2&amp;java script (2)
Magento2&amp;java script (2)
 
Why You Shouldn't Write OO
Why You Shouldn't Write OO Why You Shouldn't Write OO
Why You Shouldn't Write OO
 
Async js - Nemetschek Presentaion @ HackBulgaria
Async js - Nemetschek Presentaion @ HackBulgariaAsync js - Nemetschek Presentaion @ HackBulgaria
Async js - Nemetschek Presentaion @ HackBulgaria
 
Promises, promises, and then observables
Promises, promises, and then observablesPromises, promises, and then observables
Promises, promises, and then observables
 
AngulrJS Overview
AngulrJS OverviewAngulrJS Overview
AngulrJS Overview
 

Andere mochten auch

Html5 Canvas and Media
Html5 Canvas and MediaHtml5 Canvas and Media
Html5 Canvas and MediaSuresh Balla
 
React native - Under the Hood and App Live Updates without App Store Approval
React native - Under the Hood and App Live Updates without App Store ApprovalReact native - Under the Hood and App Live Updates without App Store Approval
React native - Under the Hood and App Live Updates without App Store ApprovalSuresh Balla
 
Developing context aware applications with iBeacons technology
Developing context aware applications with iBeacons technologyDeveloping context aware applications with iBeacons technology
Developing context aware applications with iBeacons technologySuresh Balla
 
Digital connections- Disease Vocab
Digital connections- Disease VocabDigital connections- Disease Vocab
Digital connections- Disease Vocab16veronicaa
 
Ad. New Deodorants
Ad. New DeodorantsAd. New Deodorants
Ad. New DeodorantsSandoz
 

Andere mochten auch (8)

Html5 Canvas and Media
Html5 Canvas and MediaHtml5 Canvas and Media
Html5 Canvas and Media
 
React native - Under the Hood and App Live Updates without App Store Approval
React native - Under the Hood and App Live Updates without App Store ApprovalReact native - Under the Hood and App Live Updates without App Store Approval
React native - Under the Hood and App Live Updates without App Store Approval
 
Developing context aware applications with iBeacons technology
Developing context aware applications with iBeacons technologyDeveloping context aware applications with iBeacons technology
Developing context aware applications with iBeacons technology
 
The Influence Of The Media Ppp
The Influence Of The Media PppThe Influence Of The Media Ppp
The Influence Of The Media Ppp
 
Filsafat islam
Filsafat islamFilsafat islam
Filsafat islam
 
Au Psy492 M7 A3 E Portf Lee C
Au Psy492 M7 A3 E Portf Lee CAu Psy492 M7 A3 E Portf Lee C
Au Psy492 M7 A3 E Portf Lee C
 
Digital connections- Disease Vocab
Digital connections- Disease VocabDigital connections- Disease Vocab
Digital connections- Disease Vocab
 
Ad. New Deodorants
Ad. New DeodorantsAd. New Deodorants
Ad. New Deodorants
 

Ähnlich wie Architecting JavaScript Code

Introduction to Zend Framework web services
Introduction to Zend Framework web servicesIntroduction to Zend Framework web services
Introduction to Zend Framework web servicesMichelangelo van Dam
 
What's new in jQuery 1.5
What's new in jQuery 1.5What's new in jQuery 1.5
What's new in jQuery 1.5Martin Kleppe
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesAnkit Rastogi
 
Symfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologySymfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologyDaniel Knell
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the TrenchesJonathan Wage
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionDmitry Sheiko
 
Object-Oriented JavaScript
Object-Oriented JavaScriptObject-Oriented JavaScript
Object-Oriented JavaScriptkvangork
 
Object-Oriented Javascript
Object-Oriented JavascriptObject-Oriented Javascript
Object-Oriented Javascriptkvangork
 
Virtual Madness @ Etsy
Virtual Madness @ EtsyVirtual Madness @ Etsy
Virtual Madness @ EtsyNishan Subedi
 
ZF2 for the ZF1 Developer
ZF2 for the ZF1 DeveloperZF2 for the ZF1 Developer
ZF2 for the ZF1 DeveloperGary Hockin
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For BeginnersJonathan Wage
 
Clean code in JavaScript
Clean code in JavaScriptClean code in JavaScript
Clean code in JavaScriptMathieu Breton
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6Dmitry Soshnikov
 
Google App Engine Developer - Day3
Google App Engine Developer - Day3Google App Engine Developer - Day3
Google App Engine Developer - Day3Simon Su
 

Ähnlich wie Architecting JavaScript Code (20)

Introduction to Zend Framework web services
Introduction to Zend Framework web servicesIntroduction to Zend Framework web services
Introduction to Zend Framework web services
 
Javascript - Beyond-jQuery
Javascript - Beyond-jQueryJavascript - Beyond-jQuery
Javascript - Beyond-jQuery
 
What's new in jQuery 1.5
What's new in jQuery 1.5What's new in jQuery 1.5
What's new in jQuery 1.5
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
 
Symfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologySymfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technology
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the Trenches
 
Clean Javascript
Clean JavascriptClean Javascript
Clean Javascript
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Zend framework service
Zend framework serviceZend framework service
Zend framework service
 
Zend framework service
Zend framework serviceZend framework service
Zend framework service
 
Object-Oriented JavaScript
Object-Oriented JavaScriptObject-Oriented JavaScript
Object-Oriented JavaScript
 
Object-Oriented Javascript
Object-Oriented JavascriptObject-Oriented Javascript
Object-Oriented Javascript
 
Virtual Madness @ Etsy
Virtual Madness @ EtsyVirtual Madness @ Etsy
Virtual Madness @ Etsy
 
ZF2 for the ZF1 Developer
ZF2 for the ZF1 DeveloperZF2 for the ZF1 Developer
ZF2 for the ZF1 Developer
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
 
Clean code in JavaScript
Clean code in JavaScriptClean code in JavaScript
Clean code in JavaScript
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
 
Ad java prac sol set
Ad java prac sol setAd java prac sol set
Ad java prac sol set
 
Backbone Basics with Examples
Backbone Basics with ExamplesBackbone Basics with Examples
Backbone Basics with Examples
 
Google App Engine Developer - Day3
Google App Engine Developer - Day3Google App Engine Developer - Day3
Google App Engine Developer - Day3
 

Kürzlich hochgeladen

Deerfoot Church of Christ Bulletin 4 28 24
Deerfoot Church of Christ Bulletin 4 28 24Deerfoot Church of Christ Bulletin 4 28 24
Deerfoot Church of Christ Bulletin 4 28 24deerfootcoc
 
Hire Best Next Js Developer For Your Project
Hire Best Next Js Developer For Your ProjectHire Best Next Js Developer For Your Project
Hire Best Next Js Developer For Your ProjectCyanic lab
 
Genesis 1:7 || Meditate the Scripture daily verse by verse
Genesis 1:7  ||  Meditate the Scripture daily verse by verseGenesis 1:7  ||  Meditate the Scripture daily verse by verse
Genesis 1:7 || Meditate the Scripture daily verse by versemaricelcanoynuay
 
Famous Kala Jadu, Black magic expert in UK and Kala ilam expert in Saudi Arab...
Famous Kala Jadu, Black magic expert in UK and Kala ilam expert in Saudi Arab...Famous Kala Jadu, Black magic expert in UK and Kala ilam expert in Saudi Arab...
Famous Kala Jadu, Black magic expert in UK and Kala ilam expert in Saudi Arab...baharayali
 
Professional Amil baba, Kala jadu specialist in Multan and Kala ilam speciali...
Professional Amil baba, Kala jadu specialist in Multan and Kala ilam speciali...Professional Amil baba, Kala jadu specialist in Multan and Kala ilam speciali...
Professional Amil baba, Kala jadu specialist in Multan and Kala ilam speciali...makhmalhalaaay
 
NoHo First Good News online newsletter May 2024
NoHo First Good News online newsletter May 2024NoHo First Good News online newsletter May 2024
NoHo First Good News online newsletter May 2024NoHo FUMC
 
Jude: The Acts of the Apostates (Jude vv.1-4).pptx
Jude: The Acts of the Apostates (Jude vv.1-4).pptxJude: The Acts of the Apostates (Jude vv.1-4).pptx
Jude: The Acts of the Apostates (Jude vv.1-4).pptxStephen Palm
 
A Spiritual Guide To Truth v10.pdf xxxxxxx
A Spiritual Guide To Truth v10.pdf xxxxxxxA Spiritual Guide To Truth v10.pdf xxxxxxx
A Spiritual Guide To Truth v10.pdf xxxxxxxssuser83613b
 
Best Astrologer Vashikaran Specialist in Germany and France Black Magic Exper...
Best Astrologer Vashikaran Specialist in Germany and France Black Magic Exper...Best Astrologer Vashikaran Specialist in Germany and France Black Magic Exper...
Best Astrologer Vashikaran Specialist in Germany and France Black Magic Exper...Amil Baba Naveed Bangali
 
Verified Amil baba in Pakistan Amil baba in Islamabad Famous Amil baba in Ger...
Verified Amil baba in Pakistan Amil baba in Islamabad Famous Amil baba in Ger...Verified Amil baba in Pakistan Amil baba in Islamabad Famous Amil baba in Ger...
Verified Amil baba in Pakistan Amil baba in Islamabad Famous Amil baba in Ger...Amil Baba Naveed Bangali
 
VADODARA CALL GIRL AVAILABLE 7568201473 call me
VADODARA CALL GIRL AVAILABLE 7568201473 call meVADODARA CALL GIRL AVAILABLE 7568201473 call me
VADODARA CALL GIRL AVAILABLE 7568201473 call meshivanisharma5244
 
The Revelation Chapter 4 Working Copy.docx
The Revelation Chapter 4 Working Copy.docxThe Revelation Chapter 4 Working Copy.docx
The Revelation Chapter 4 Working Copy.docxFred Gosnell
 
Top Kala Jadu, Bangali Amil baba in Lahore and Kala jadu specialist in Lahore...
Top Kala Jadu, Bangali Amil baba in Lahore and Kala jadu specialist in Lahore...Top Kala Jadu, Bangali Amil baba in Lahore and Kala jadu specialist in Lahore...
Top Kala Jadu, Bangali Amil baba in Lahore and Kala jadu specialist in Lahore...baharayali
 
Top 10 Amil baba list Famous Amil baba In Pakistan Amil baba Kala jadu in Raw...
Top 10 Amil baba list Famous Amil baba In Pakistan Amil baba Kala jadu in Raw...Top 10 Amil baba list Famous Amil baba In Pakistan Amil baba Kala jadu in Raw...
Top 10 Amil baba list Famous Amil baba In Pakistan Amil baba Kala jadu in Raw...Amil Baba Naveed Bangali
 
From The Heart v8.pdf xxxxxxxxxxxxxxxxxxx
From The Heart v8.pdf xxxxxxxxxxxxxxxxxxxFrom The Heart v8.pdf xxxxxxxxxxxxxxxxxxx
From The Heart v8.pdf xxxxxxxxxxxxxxxxxxxssuser83613b
 
Famous Kala Jadu, Kala ilam specialist in USA and Bangali Amil baba in Saudi ...
Famous Kala Jadu, Kala ilam specialist in USA and Bangali Amil baba in Saudi ...Famous Kala Jadu, Kala ilam specialist in USA and Bangali Amil baba in Saudi ...
Famous Kala Jadu, Kala ilam specialist in USA and Bangali Amil baba in Saudi ...baharayali
 
"The Magnificent Surah Rahman: PDF Version"
"The Magnificent Surah Rahman: PDF Version""The Magnificent Surah Rahman: PDF Version"
"The Magnificent Surah Rahman: PDF Version"aijazuddin14
 

Kürzlich hochgeladen (20)

Deerfoot Church of Christ Bulletin 4 28 24
Deerfoot Church of Christ Bulletin 4 28 24Deerfoot Church of Christ Bulletin 4 28 24
Deerfoot Church of Christ Bulletin 4 28 24
 
St. Louise de Marillac and Poor Children
St. Louise de Marillac and Poor ChildrenSt. Louise de Marillac and Poor Children
St. Louise de Marillac and Poor Children
 
Hire Best Next Js Developer For Your Project
Hire Best Next Js Developer For Your ProjectHire Best Next Js Developer For Your Project
Hire Best Next Js Developer For Your Project
 
Genesis 1:7 || Meditate the Scripture daily verse by verse
Genesis 1:7  ||  Meditate the Scripture daily verse by verseGenesis 1:7  ||  Meditate the Scripture daily verse by verse
Genesis 1:7 || Meditate the Scripture daily verse by verse
 
Famous Kala Jadu, Black magic expert in UK and Kala ilam expert in Saudi Arab...
Famous Kala Jadu, Black magic expert in UK and Kala ilam expert in Saudi Arab...Famous Kala Jadu, Black magic expert in UK and Kala ilam expert in Saudi Arab...
Famous Kala Jadu, Black magic expert in UK and Kala ilam expert in Saudi Arab...
 
Professional Amil baba, Kala jadu specialist in Multan and Kala ilam speciali...
Professional Amil baba, Kala jadu specialist in Multan and Kala ilam speciali...Professional Amil baba, Kala jadu specialist in Multan and Kala ilam speciali...
Professional Amil baba, Kala jadu specialist in Multan and Kala ilam speciali...
 
NoHo First Good News online newsletter May 2024
NoHo First Good News online newsletter May 2024NoHo First Good News online newsletter May 2024
NoHo First Good News online newsletter May 2024
 
Jude: The Acts of the Apostates (Jude vv.1-4).pptx
Jude: The Acts of the Apostates (Jude vv.1-4).pptxJude: The Acts of the Apostates (Jude vv.1-4).pptx
Jude: The Acts of the Apostates (Jude vv.1-4).pptx
 
A Spiritual Guide To Truth v10.pdf xxxxxxx
A Spiritual Guide To Truth v10.pdf xxxxxxxA Spiritual Guide To Truth v10.pdf xxxxxxx
A Spiritual Guide To Truth v10.pdf xxxxxxx
 
Best Astrologer Vashikaran Specialist in Germany and France Black Magic Exper...
Best Astrologer Vashikaran Specialist in Germany and France Black Magic Exper...Best Astrologer Vashikaran Specialist in Germany and France Black Magic Exper...
Best Astrologer Vashikaran Specialist in Germany and France Black Magic Exper...
 
Verified Amil baba in Pakistan Amil baba in Islamabad Famous Amil baba in Ger...
Verified Amil baba in Pakistan Amil baba in Islamabad Famous Amil baba in Ger...Verified Amil baba in Pakistan Amil baba in Islamabad Famous Amil baba in Ger...
Verified Amil baba in Pakistan Amil baba in Islamabad Famous Amil baba in Ger...
 
VADODARA CALL GIRL AVAILABLE 7568201473 call me
VADODARA CALL GIRL AVAILABLE 7568201473 call meVADODARA CALL GIRL AVAILABLE 7568201473 call me
VADODARA CALL GIRL AVAILABLE 7568201473 call me
 
The Revelation Chapter 4 Working Copy.docx
The Revelation Chapter 4 Working Copy.docxThe Revelation Chapter 4 Working Copy.docx
The Revelation Chapter 4 Working Copy.docx
 
Top Kala Jadu, Bangali Amil baba in Lahore and Kala jadu specialist in Lahore...
Top Kala Jadu, Bangali Amil baba in Lahore and Kala jadu specialist in Lahore...Top Kala Jadu, Bangali Amil baba in Lahore and Kala jadu specialist in Lahore...
Top Kala Jadu, Bangali Amil baba in Lahore and Kala jadu specialist in Lahore...
 
Top 10 Amil baba list Famous Amil baba In Pakistan Amil baba Kala jadu in Raw...
Top 10 Amil baba list Famous Amil baba In Pakistan Amil baba Kala jadu in Raw...Top 10 Amil baba list Famous Amil baba In Pakistan Amil baba Kala jadu in Raw...
Top 10 Amil baba list Famous Amil baba In Pakistan Amil baba Kala jadu in Raw...
 
From The Heart v8.pdf xxxxxxxxxxxxxxxxxxx
From The Heart v8.pdf xxxxxxxxxxxxxxxxxxxFrom The Heart v8.pdf xxxxxxxxxxxxxxxxxxx
From The Heart v8.pdf xxxxxxxxxxxxxxxxxxx
 
St. Louise de Marillac and Care of the Sick Poor
St. Louise de Marillac and Care of the Sick PoorSt. Louise de Marillac and Care of the Sick Poor
St. Louise de Marillac and Care of the Sick Poor
 
Famous No -1 amil baba in Hyderabad ! Best No _ Astrologer in Pakistan, UK, A...
Famous No -1 amil baba in Hyderabad ! Best No _ Astrologer in Pakistan, UK, A...Famous No -1 amil baba in Hyderabad ! Best No _ Astrologer in Pakistan, UK, A...
Famous No -1 amil baba in Hyderabad ! Best No _ Astrologer in Pakistan, UK, A...
 
Famous Kala Jadu, Kala ilam specialist in USA and Bangali Amil baba in Saudi ...
Famous Kala Jadu, Kala ilam specialist in USA and Bangali Amil baba in Saudi ...Famous Kala Jadu, Kala ilam specialist in USA and Bangali Amil baba in Saudi ...
Famous Kala Jadu, Kala ilam specialist in USA and Bangali Amil baba in Saudi ...
 
"The Magnificent Surah Rahman: PDF Version"
"The Magnificent Surah Rahman: PDF Version""The Magnificent Surah Rahman: PDF Version"
"The Magnificent Surah Rahman: PDF Version"
 

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; } }; };
  • 18.
  • 19.
  • 20. <html> ... <script source="first.js"></script> <script source="second.js"></script> </html> // first.js (function(ns) { // second.js ns.Customer = function() { (function(ns) { this.name = ""; ns.Order = function() { ... }; }; }(window.WilderMinds = window.WilderMinds || {})); }(window.WilderMinds = window.WilderMinds || {}));
  • 21.
  • 22. <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>RequireJS</title> </head> <body> <script src="scripts/require.js" data-main="scripts/lib/main.js"> </script> </body> </html>
  • 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 }
  • 25.
  • 26.

Hinweis der Redaktion

  1. 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
  2. C:\\Users\\Suresh.Balla\\Desktop\\Win8\\Html5Demos\\2 - advanced\\C-RectanglesWithCircles.html
  3. C:\\Users\\Suresh.Balla\\Desktop\\Win8\\Html5Demos\\2 - advanced\\C-RectanglesWithCircles.html