SlideShare a Scribd company logo
Google+:
Blog:
Twitter:

Advanced JavaScript
Techniques, Design patterns, Best practices

Mahmoud Tolba
Mahmoodfcis.wordpress.com
@mahmoodfcis
JS brief overview

 Developed at Netscpae with the name “LiveScript” at 1996
 The key design principles within JavaScript are taken from the Self and Scheme programming
languages
 Copies many of the names and naming conventions from Java.
 Is an interpreted and dynamic language
JavaScript vs. C# vs. other languages

JavaScript

C#

Dynamic

Static

Interpreted

Compiled

Client side

Server side

No plugins required to run it

Need plugins to run in client like
silverlight
Why JavaScript is important
JavaScript is a dynamic language

 You can easily change a variable type dynamically in code so we use the typeof operator to
check the data type of a variable
 You can add or remove properties from an object dynamically so we can check for them
using hasOwnProperty () function
JavaScript is an OOP language
 We can create objects in JavaScript either using Constructors or Object literals
 We can extend the properties of an object using prototype object
 Using String object ( bold(),color(),concat(),replace())
 Using Date object (setMoth(),setDate(),setYear(),….)
 Using Math object (sqrt(),pi,abs(),floor(),round())
window object

 Sits at the top of the JS object hierarchy and represents the browser window.
 Used for creating and closing browser windows, displaying alerts, confirmation, setting timeouts

 whenever an object method or property is referenced in a script without the object name and
dot prefix it is assumed by JavaScript to be a member of the window object
 Contains many properties “closed,name,parent,opener,screen,self,top”
 Moveto()
Document object

 Contains all the HTML elements of the head and body sections of the HTML
 Contains may functions and properties “open(),write(),bgcolor,fgcolor”
location object
 Is a child object of the window object
 Is used to store information about the current window url
 Window.location.href=“some url”;
 location.protocol - the protocol section of the URL (for example http: or https:)
 location.hostname - the hostname (for example www.techotopia.com)
 location.port - the HTTP Port number of the URL (for example 80)
 location.search - the search portion of the URL (batch=1 in the example above)
 location.hash - the anchor name in the URL (#intro in our example)
 Has Reload(),replace() methods
history object
 Is a child object of the window object
 holds information about the URLs visited before and after the current URL
 history.length - a property containing the numner of URLs held in the history.
 history.go() - takes a postive or negative number as an argument to specify how many changes
back or forward in the history to go. For example history.go(-4) is equivalent to pressing the Back
buttonm in the browser 4 times.
 history.back() - equivalent to pressing the browser Back button (loads the previous page from the
history list).
 history.forward() - equivalent to pressing the browser Forward button (loads the next page from the
history if it exists).


Array object

 Used to create a list, sequence
 var arr=new Array(“1”,”2”,3)
 Push(),sort(),reverse()
JS cookies

 Create cookies using document.cookie=“name=”+value;
 Read cookie using document.cookie.split(„=‟)[1]
Closures
 A closure is nothing more than a function object with a related scope in which the function’s
variables are resolved.
 "Think of closures as a kind of regional scope: broader than local but not as broad as global.“

 To create a closure, you nest a function inside of a function. That inner function has access to all
variables in its parent function‟s scope
 http://ejohn.org/apps/learn/#49
 http://ejohn.org/apps/learn/#50

 http://ejohn.org/apps/learn/#51
Using object literals to pass optional
parameters to function

 functions that can accept a large number of optional arguments. Instead of passing the
large number of arguments in the conventional fashion, which could unnecessarily
complicate the function, you can pass just one argument which ends up being a collection
of arguments declared in an object literal
Inheritance

 Inheritance is a way to create a class as a specialized version of one or more classes
(JavaScript only supports single class inheritance). The specialized class is commonly called
the child, and the other class is commonly called the parent. In JavaScript you do this by
assigning an instance of the parent class to the child class, and then specializing it. In
modern browsers you can also use Object.create to implement inheritance
Callbacks

 Passing a function as an argument is easy
JavaScript libraries

 There are many JavaScript libraries and resources.
 Jquery,Node.js, Bootstrap, Backbone, knockout are popular JavaScript libraries
Knockout.js


Knockout is a JavaScript library that helps you to create rich, responsive display and editor user interfaces with a clean underlying data model. Any
time you have sections of UI that update dynamically (e.g., changing depending on the user‟s actions or when an external data source changes),
KO can help you implement it more simply and maintainably



Headline features:



Elegant dependency tracking - automatically updates the right parts of your UI whenever your data model changes.



Declarative bindings - a simple and obvious way to connect parts of your UI to your data model. You can construct a complex dynamic UIs easily
using arbitrarily nested binding contexts.



Trivially extensible - implement custom behaviors as new declarative bindings for easy reuse in just a few lines of code.



Additional benefits:



Pure JavaScript library - works with any server or client-side technology



Can be added on top of your existing web application without requiring major architectural changes



Compact - around 13kb after gzipping



Works on any mainstream browser (IE 6+, Firefox 2+, Chrome, Safari, others)



Comprehensive suite of specifications (developed BDD-style) means its correct functioning can easily be verified on new browsers and platforms



http://knockoutjs.com/examples/helloWorld.html



http://knockoutjs.com/index.html
JavaScriptMvc
 Is an open-source rich Internet
application framework based
on jQuery and OpenAjax. It extends those
libraries with a model–view–
controller architecture and tools for
testing and deployment. As it does not
depend on server components, it can be
combined with any web service interface
and server-side language
like ASP.NET, Java, Perl, PHP, Python,
or Ruby
 For more info http://javascriptmvc.com/
Backbone.js
 Backbone.js is basically an uber-light framework that allows you to structure your Javascript
code in anMVC(Model, View, Controller) fashion where...
 Model is part of your code that retrieves and populates the data,
 View is the HTML representation of this model(views change as models change, etc)
 and Controller that in this case allows you to save the state of your javascript application via a
hashbang url, for example: http://twitter.com/#search?q=backbone.js
 http://backbonejs.org/
 http://backbonetutorials.com/
 http://www.asp.net/single-page-application/overview/templates/backbonejs-template
Angularjs

 A toolset based on extending the HTML
vocabulary for your application
 http://angularjs.org/
 http://docs.angularjs.org/tutorial
 is an MVC library for Javascript that lets
you write maintainable and reusable
browser code without the verbose or
infrastructural overhead found
in other MVC libraries. The goal is to
enable developers to write web apps at
least as quickly as with jQuery, while
simplifying long-term maintainability
through MVC objects.
 http://agilityjs.com/
 Sencha Ext JS is the industry's most powerful desktop application development platform with
unparalleled cross-browser compatibility, advanced MVC architecture, plugin-free charting,
and modern UI widgets
 http://www.sencha.com/products/extjs
 http://modernizr.com/
 is a JavaScript library that detects HTML5 and CSS3 features in the user‟s browser
 runs quickly on page load to detect features; it then creates a JavaScript object with the results,
and adds classes to the HTML element for you to key your CSS on
 http://webdesignernotebook.com/css/how-to-use-modernizr/
 is an asynchronous conditional resource loader that's super-fast, and allows you to load only
the scripts that your users need
 http://yepnopejs.com/
Winjs

 Is a JavaScript library for building windows 8 store apps
 http://winjstoolkit.codeplex.com
 http://dev.bennage.com/blog/2012/08/01/a-brief-introduction-to-winjs/
LimeJS

 Is a HTML5 game framework for building fast, native-experience games for all modern
touchscreens and
desktop browsers
 http://www.limejs.com/
Lungo Framework

 A framework based on HTML5 fordevelopers who want to design, buildand share cross
device applications
 http://www.lungo.tapquo.com/
 Breeze is a JavaScript library that helps you manage data in rich client applications. If you store
data in a database, query and save those data as complex object graphs, and share these
graphs across multiple screens of your JavaScript client, Breeze is for you
 http://www.breezejs.com/home
 http://www.johnpapa.net/spajs04/
 is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal
and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API
that works across a multitude of browsers. With a combination of versatility and extensibility,
jQuery has changed the way that millions of people write JavaScript
 http://jquery.com/
 jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top
of the jQuery JavaScript Library. Whether you're building highly interactive web applications or
you just need to add a date picker to a form control, jQuery UI is the perfect choice.
 http://jqueryui.com/
 A unified, HTML5-based user interface system for all popular mobile device platforms, built on
the rock-solid jQuery and jQuery UI foundation. Its lightweight code is built with progressive
enhancement, and has a flexible, easily themeable design.
 http://jquerymobile.com/
 Is A JavaScript Unit Testing framework.

 is a powerful, easy-to-use JavaScript unit testing framework. It's used by the jQuery, jQuery UI
and jQuery Mobile projects and is capable of testing any generic JavaScript code
 http://qunitjs.com/
Jo Framework for HTML5

 he simple app framework for HTML5
 For iOS, Android, webOS, BlackBerry, Chrome OS & anything else with HTML5
 Widgets, lists and scrolling goodness using JavaScript & CSS3
 Make native mobile apps or web apps with the same code
 Works great with PhoneGap
 http://joapp.com/
 See a demo at http://joapp.com/live/samples/test.html
DHTMLX Touch

 DHTMLX Touch is a free open source JavaScript library for building HTML5-based mobile web
apps. It's not just a set of UI widgets, but a complete framework that allows you to create eyecatching, robust web applications that run on iOS, Android, and other mobile platforms
 http://dhtmlx.com/touch/
 MooTools is a compact, modular, Object-Oriented JavaScript framework designed for the
intermediate to advanced JavaScript developer. It allows you to write powerful, flexible,
and cross-browser code with its elegant, well documented, and coherent API
 http://mootools.net/
 Prototype takes the complexity out of client-side web programming. Built to solve real-world
problems, it adds useful extensions to the browser scripting environment and provides elegant
APIs around the clumsy interfaces of Ajax and the Document Object Model
 http://prototypejs.org/
 http://wijmo.com/demo/explore/
 Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable
network applications. Node.js uses an event-driven, non-blocking I/O model that makes it
lightweight and efficient, perfect for data-intensive real-time applications that run across
distributed devices
 http://nodejs.org/
Finally, Thanks to JavaScript

More Related Content

What's hot

Introduction into ES6 JavaScript.
Introduction into ES6 JavaScript.Introduction into ES6 JavaScript.
Introduction into ES6 JavaScript.
boyney123
 
Type Driven Development with TypeScript
Type Driven Development with TypeScriptType Driven Development with TypeScript
Type Driven Development with TypeScript
Garth Gilmour
 
JavaScript Design Patterns
JavaScript Design PatternsJavaScript Design Patterns
JavaScript Design Patterns
Derek Brown
 
FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6
Dmitry Soshnikov
 
ES2015 (ES6) Overview
ES2015 (ES6) OverviewES2015 (ES6) Overview
ES2015 (ES6) Overview
hesher
 
5 Tips for Better JavaScript
5 Tips for Better JavaScript5 Tips for Better JavaScript
5 Tips for Better JavaScript
Todd Anglin
 
AST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptAST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptIngvar Stepanyan
 
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Domenic Denicola
 
Performance Optimization and JavaScript Best Practices
Performance Optimization and JavaScript Best PracticesPerformance Optimization and JavaScript Best Practices
Performance Optimization and JavaScript Best Practices
Doris Chen
 
Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6
Nilesh Jayanandana
 
Explaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to ComeExplaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to Come
Cory Forsyth
 
EcmaScript 6 - The future is here
EcmaScript 6 - The future is hereEcmaScript 6 - The future is here
EcmaScript 6 - The future is here
Sebastiano Armeli
 
JavaScript and the AST
JavaScript and the ASTJavaScript and the AST
JavaScript and the AST
Jarrod Overson
 
Why TypeScript?
Why TypeScript?Why TypeScript?
Why TypeScript?
FITC
 
ES6 - Next Generation Javascript
ES6 - Next Generation JavascriptES6 - Next Generation Javascript
ES6 - Next Generation Javascript
Ramesh Nair
 
Javascript & Ajax Basics
Javascript & Ajax BasicsJavascript & Ajax Basics
Javascript & Ajax BasicsRichard Paul
 
Consuming Web Services with Swift and Rx
Consuming Web Services with Swift and RxConsuming Web Services with Swift and Rx
Consuming Web Services with Swift and Rx
Guillermo Gonzalez
 
JavaScript - From Birth To Closure
JavaScript - From Birth To ClosureJavaScript - From Birth To Closure
JavaScript - From Birth To Closure
Robert Nyman
 
Javascript tid-bits
Javascript tid-bitsJavascript tid-bits
Javascript tid-bits
David Atchley
 

What's hot (20)

Introduction into ES6 JavaScript.
Introduction into ES6 JavaScript.Introduction into ES6 JavaScript.
Introduction into ES6 JavaScript.
 
Type Driven Development with TypeScript
Type Driven Development with TypeScriptType Driven Development with TypeScript
Type Driven Development with TypeScript
 
JavaScript Design Patterns
JavaScript Design PatternsJavaScript Design Patterns
JavaScript Design Patterns
 
FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6
 
ES2015 (ES6) Overview
ES2015 (ES6) OverviewES2015 (ES6) Overview
ES2015 (ES6) Overview
 
5 Tips for Better JavaScript
5 Tips for Better JavaScript5 Tips for Better JavaScript
5 Tips for Better JavaScript
 
AST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptAST - the only true tool for building JavaScript
AST - the only true tool for building JavaScript
 
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
 
Performance Optimization and JavaScript Best Practices
Performance Optimization and JavaScript Best PracticesPerformance Optimization and JavaScript Best Practices
Performance Optimization and JavaScript Best Practices
 
Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6
 
Explaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to ComeExplaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to Come
 
EcmaScript 6 - The future is here
EcmaScript 6 - The future is hereEcmaScript 6 - The future is here
EcmaScript 6 - The future is here
 
JavaScript and the AST
JavaScript and the ASTJavaScript and the AST
JavaScript and the AST
 
ECMAScript 6
ECMAScript 6ECMAScript 6
ECMAScript 6
 
Why TypeScript?
Why TypeScript?Why TypeScript?
Why TypeScript?
 
ES6 - Next Generation Javascript
ES6 - Next Generation JavascriptES6 - Next Generation Javascript
ES6 - Next Generation Javascript
 
Javascript & Ajax Basics
Javascript & Ajax BasicsJavascript & Ajax Basics
Javascript & Ajax Basics
 
Consuming Web Services with Swift and Rx
Consuming Web Services with Swift and RxConsuming Web Services with Swift and Rx
Consuming Web Services with Swift and Rx
 
JavaScript - From Birth To Closure
JavaScript - From Birth To ClosureJavaScript - From Birth To Closure
JavaScript - From Birth To Closure
 
Javascript tid-bits
Javascript tid-bitsJavascript tid-bits
Javascript tid-bits
 

Viewers also liked

Windows Communication Foundation
Windows Communication FoundationWindows Communication Foundation
Windows Communication FoundationMahmoud Tolba
 
Microsoft Entity Framework
Microsoft Entity FrameworkMicrosoft Entity Framework
Microsoft Entity Framework
Mahmoud Tolba
 
Disruptive technologies and the implications for University Information Servi...
Disruptive technologies and the implications for University Information Servi...Disruptive technologies and the implications for University Information Servi...
Disruptive technologies and the implications for University Information Servi...
diharrison
 
The role of the central IT Services organisation in a Web 2.0 world - paper
The role of the central IT Services organisation in a Web 2.0 world - paperThe role of the central IT Services organisation in a Web 2.0 world - paper
The role of the central IT Services organisation in a Web 2.0 world - paper
diharrison
 
So that's it for it services, or is it?
So that's it for it services, or is it?So that's it for it services, or is it?
So that's it for it services, or is it?
diharrison
 
Universities And Social Networking: making sense out of nonsense
Universities And Social Networking: making sense out of nonsenseUniversities And Social Networking: making sense out of nonsense
Universities And Social Networking: making sense out of nonsense
diharrison
 

Viewers also liked (6)

Windows Communication Foundation
Windows Communication FoundationWindows Communication Foundation
Windows Communication Foundation
 
Microsoft Entity Framework
Microsoft Entity FrameworkMicrosoft Entity Framework
Microsoft Entity Framework
 
Disruptive technologies and the implications for University Information Servi...
Disruptive technologies and the implications for University Information Servi...Disruptive technologies and the implications for University Information Servi...
Disruptive technologies and the implications for University Information Servi...
 
The role of the central IT Services organisation in a Web 2.0 world - paper
The role of the central IT Services organisation in a Web 2.0 world - paperThe role of the central IT Services organisation in a Web 2.0 world - paper
The role of the central IT Services organisation in a Web 2.0 world - paper
 
So that's it for it services, or is it?
So that's it for it services, or is it?So that's it for it services, or is it?
So that's it for it services, or is it?
 
Universities And Social Networking: making sense out of nonsense
Universities And Social Networking: making sense out of nonsenseUniversities And Social Networking: making sense out of nonsense
Universities And Social Networking: making sense out of nonsense
 

Similar to Advanced JavaScript

Technology Stack Discussion
Technology Stack DiscussionTechnology Stack Discussion
Technology Stack DiscussionZaiyang Li
 
Java Script - A New Look
Java Script - A New LookJava Script - A New Look
Java Script - A New Lookrumsan
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application development
zonathen
 
Java script Basic
Java script BasicJava script Basic
Java script Basic
Jaya Kumari
 
Ajax toolkit framework
Ajax toolkit frameworkAjax toolkit framework
Ajax toolkit framework
Sunil Kumar
 
Sofea and SOUI - Web future without web frameworks
Sofea and SOUI - Web future without web frameworksSofea and SOUI - Web future without web frameworks
Sofea and SOUI - Web future without web frameworks
André Neubauer
 
Front End Development | Introduction
Front End Development | IntroductionFront End Development | Introduction
Front End Development | Introduction
JohnTaieb
 
Html5
Html5Html5
Survive JavaScript - Strategies and Tricks
Survive JavaScript - Strategies and TricksSurvive JavaScript - Strategies and Tricks
Survive JavaScript - Strategies and Tricks
Juho Vepsäläinen
 
Making Of PHP Based Web Application
Making Of PHP Based Web ApplicationMaking Of PHP Based Web Application
Making Of PHP Based Web Application
Sachin Walvekar
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN StackRob Davarnia
 
Using Ajax In Domino Web Applications
Using Ajax In Domino Web ApplicationsUsing Ajax In Domino Web Applications
Using Ajax In Domino Web Applicationsdominion
 
Crash Course HTML/Rails Slides
Crash Course HTML/Rails SlidesCrash Course HTML/Rails Slides
Crash Course HTML/Rails Slides
Udita Plaha
 
Career guideline
Career guidelineCareer guideline
Career guideline
Mehrab Hossain
 
WEB MODULE 3.pdf
WEB MODULE 3.pdfWEB MODULE 3.pdf
WEB MODULE 3.pdf
Deepika A B
 
Get Ahead with HTML5 on Moible
Get Ahead with HTML5 on MoibleGet Ahead with HTML5 on Moible
Get Ahead with HTML5 on Moible
markuskobler
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
hchen1
 
Web Application Frameworks - Lecture 05 - Web Information Systems (4011474FNR)
Web Application Frameworks - Lecture 05 - Web Information Systems (4011474FNR)Web Application Frameworks - Lecture 05 - Web Information Systems (4011474FNR)
Web Application Frameworks - Lecture 05 - Web Information Systems (4011474FNR)
Beat Signer
 
Ajax toolkit-framework
Ajax toolkit-frameworkAjax toolkit-framework
Ajax toolkit-framework
WBUTTUTORIALS
 
State of modern web technologies: an introduction
State of modern web technologies: an introductionState of modern web technologies: an introduction
State of modern web technologies: an introduction
Michael Ahearn
 

Similar to Advanced JavaScript (20)

Technology Stack Discussion
Technology Stack DiscussionTechnology Stack Discussion
Technology Stack Discussion
 
Java Script - A New Look
Java Script - A New LookJava Script - A New Look
Java Script - A New Look
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application development
 
Java script Basic
Java script BasicJava script Basic
Java script Basic
 
Ajax toolkit framework
Ajax toolkit frameworkAjax toolkit framework
Ajax toolkit framework
 
Sofea and SOUI - Web future without web frameworks
Sofea and SOUI - Web future without web frameworksSofea and SOUI - Web future without web frameworks
Sofea and SOUI - Web future without web frameworks
 
Front End Development | Introduction
Front End Development | IntroductionFront End Development | Introduction
Front End Development | Introduction
 
Html5
Html5Html5
Html5
 
Survive JavaScript - Strategies and Tricks
Survive JavaScript - Strategies and TricksSurvive JavaScript - Strategies and Tricks
Survive JavaScript - Strategies and Tricks
 
Making Of PHP Based Web Application
Making Of PHP Based Web ApplicationMaking Of PHP Based Web Application
Making Of PHP Based Web Application
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN Stack
 
Using Ajax In Domino Web Applications
Using Ajax In Domino Web ApplicationsUsing Ajax In Domino Web Applications
Using Ajax In Domino Web Applications
 
Crash Course HTML/Rails Slides
Crash Course HTML/Rails SlidesCrash Course HTML/Rails Slides
Crash Course HTML/Rails Slides
 
Career guideline
Career guidelineCareer guideline
Career guideline
 
WEB MODULE 3.pdf
WEB MODULE 3.pdfWEB MODULE 3.pdf
WEB MODULE 3.pdf
 
Get Ahead with HTML5 on Moible
Get Ahead with HTML5 on MoibleGet Ahead with HTML5 on Moible
Get Ahead with HTML5 on Moible
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
 
Web Application Frameworks - Lecture 05 - Web Information Systems (4011474FNR)
Web Application Frameworks - Lecture 05 - Web Information Systems (4011474FNR)Web Application Frameworks - Lecture 05 - Web Information Systems (4011474FNR)
Web Application Frameworks - Lecture 05 - Web Information Systems (4011474FNR)
 
Ajax toolkit-framework
Ajax toolkit-frameworkAjax toolkit-framework
Ajax toolkit-framework
 
State of modern web technologies: an introduction
State of modern web technologies: an introductionState of modern web technologies: an introduction
State of modern web technologies: an introduction
 

More from Mahmoud Tolba

The passionate programmer
The passionate programmerThe passionate programmer
The passionate programmer
Mahmoud Tolba
 
Introduction to SAP, Systems, Applications
Introduction to SAP, Systems, ApplicationsIntroduction to SAP, Systems, Applications
Introduction to SAP, Systems, Applications
Mahmoud Tolba
 
AngularJS
AngularJSAngularJS
AngularJS
Mahmoud Tolba
 
Developing cross platforms mobile applications using the Apache Cordova
Developing cross platforms mobile applications using the Apache CordovaDeveloping cross platforms mobile applications using the Apache Cordova
Developing cross platforms mobile applications using the Apache Cordova
Mahmoud Tolba
 
JQuery Overview
JQuery OverviewJQuery Overview
JQuery Overview
Mahmoud Tolba
 
ASP.NET MVC controllers
ASP.NET MVC controllersASP.NET MVC controllers
ASP.NET MVC controllersMahmoud Tolba
 
ASP.NET MVC4 Overview
ASP.NET MVC4 OverviewASP.NET MVC4 Overview
ASP.NET MVC4 Overview
Mahmoud Tolba
 
Top emerging technologies
Top emerging technologiesTop emerging technologies
Top emerging technologies
Mahmoud Tolba
 

More from Mahmoud Tolba (8)

The passionate programmer
The passionate programmerThe passionate programmer
The passionate programmer
 
Introduction to SAP, Systems, Applications
Introduction to SAP, Systems, ApplicationsIntroduction to SAP, Systems, Applications
Introduction to SAP, Systems, Applications
 
AngularJS
AngularJSAngularJS
AngularJS
 
Developing cross platforms mobile applications using the Apache Cordova
Developing cross platforms mobile applications using the Apache CordovaDeveloping cross platforms mobile applications using the Apache Cordova
Developing cross platforms mobile applications using the Apache Cordova
 
JQuery Overview
JQuery OverviewJQuery Overview
JQuery Overview
 
ASP.NET MVC controllers
ASP.NET MVC controllersASP.NET MVC controllers
ASP.NET MVC controllers
 
ASP.NET MVC4 Overview
ASP.NET MVC4 OverviewASP.NET MVC4 Overview
ASP.NET MVC4 Overview
 
Top emerging technologies
Top emerging technologiesTop emerging technologies
Top emerging technologies
 

Recently uploaded

Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 

Recently uploaded (20)

Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 

Advanced JavaScript

  • 1. Google+: Blog: Twitter: Advanced JavaScript Techniques, Design patterns, Best practices Mahmoud Tolba Mahmoodfcis.wordpress.com @mahmoodfcis
  • 2. JS brief overview  Developed at Netscpae with the name “LiveScript” at 1996  The key design principles within JavaScript are taken from the Self and Scheme programming languages  Copies many of the names and naming conventions from Java.  Is an interpreted and dynamic language
  • 3. JavaScript vs. C# vs. other languages JavaScript C# Dynamic Static Interpreted Compiled Client side Server side No plugins required to run it Need plugins to run in client like silverlight
  • 4. Why JavaScript is important
  • 5. JavaScript is a dynamic language  You can easily change a variable type dynamically in code so we use the typeof operator to check the data type of a variable  You can add or remove properties from an object dynamically so we can check for them using hasOwnProperty () function
  • 6. JavaScript is an OOP language  We can create objects in JavaScript either using Constructors or Object literals  We can extend the properties of an object using prototype object  Using String object ( bold(),color(),concat(),replace())  Using Date object (setMoth(),setDate(),setYear(),….)  Using Math object (sqrt(),pi,abs(),floor(),round())
  • 7. window object  Sits at the top of the JS object hierarchy and represents the browser window.  Used for creating and closing browser windows, displaying alerts, confirmation, setting timeouts  whenever an object method or property is referenced in a script without the object name and dot prefix it is assumed by JavaScript to be a member of the window object  Contains many properties “closed,name,parent,opener,screen,self,top”  Moveto()
  • 8. Document object  Contains all the HTML elements of the head and body sections of the HTML  Contains may functions and properties “open(),write(),bgcolor,fgcolor”
  • 9. location object  Is a child object of the window object  Is used to store information about the current window url  Window.location.href=“some url”;  location.protocol - the protocol section of the URL (for example http: or https:)  location.hostname - the hostname (for example www.techotopia.com)  location.port - the HTTP Port number of the URL (for example 80)  location.search - the search portion of the URL (batch=1 in the example above)  location.hash - the anchor name in the URL (#intro in our example)  Has Reload(),replace() methods
  • 10. history object  Is a child object of the window object  holds information about the URLs visited before and after the current URL  history.length - a property containing the numner of URLs held in the history.  history.go() - takes a postive or negative number as an argument to specify how many changes back or forward in the history to go. For example history.go(-4) is equivalent to pressing the Back buttonm in the browser 4 times.  history.back() - equivalent to pressing the browser Back button (loads the previous page from the history list).  history.forward() - equivalent to pressing the browser Forward button (loads the next page from the history if it exists). 
  • 11. Array object  Used to create a list, sequence  var arr=new Array(“1”,”2”,3)  Push(),sort(),reverse()
  • 12. JS cookies  Create cookies using document.cookie=“name=”+value;  Read cookie using document.cookie.split(„=‟)[1]
  • 13. Closures  A closure is nothing more than a function object with a related scope in which the function’s variables are resolved.  "Think of closures as a kind of regional scope: broader than local but not as broad as global.“  To create a closure, you nest a function inside of a function. That inner function has access to all variables in its parent function‟s scope  http://ejohn.org/apps/learn/#49  http://ejohn.org/apps/learn/#50  http://ejohn.org/apps/learn/#51
  • 14. Using object literals to pass optional parameters to function  functions that can accept a large number of optional arguments. Instead of passing the large number of arguments in the conventional fashion, which could unnecessarily complicate the function, you can pass just one argument which ends up being a collection of arguments declared in an object literal
  • 15. Inheritance  Inheritance is a way to create a class as a specialized version of one or more classes (JavaScript only supports single class inheritance). The specialized class is commonly called the child, and the other class is commonly called the parent. In JavaScript you do this by assigning an instance of the parent class to the child class, and then specializing it. In modern browsers you can also use Object.create to implement inheritance
  • 16. Callbacks  Passing a function as an argument is easy
  • 17. JavaScript libraries  There are many JavaScript libraries and resources.  Jquery,Node.js, Bootstrap, Backbone, knockout are popular JavaScript libraries
  • 18. Knockout.js  Knockout is a JavaScript library that helps you to create rich, responsive display and editor user interfaces with a clean underlying data model. Any time you have sections of UI that update dynamically (e.g., changing depending on the user‟s actions or when an external data source changes), KO can help you implement it more simply and maintainably  Headline features:  Elegant dependency tracking - automatically updates the right parts of your UI whenever your data model changes.  Declarative bindings - a simple and obvious way to connect parts of your UI to your data model. You can construct a complex dynamic UIs easily using arbitrarily nested binding contexts.  Trivially extensible - implement custom behaviors as new declarative bindings for easy reuse in just a few lines of code.  Additional benefits:  Pure JavaScript library - works with any server or client-side technology  Can be added on top of your existing web application without requiring major architectural changes  Compact - around 13kb after gzipping  Works on any mainstream browser (IE 6+, Firefox 2+, Chrome, Safari, others)  Comprehensive suite of specifications (developed BDD-style) means its correct functioning can easily be verified on new browsers and platforms  http://knockoutjs.com/examples/helloWorld.html  http://knockoutjs.com/index.html
  • 19. JavaScriptMvc  Is an open-source rich Internet application framework based on jQuery and OpenAjax. It extends those libraries with a model–view– controller architecture and tools for testing and deployment. As it does not depend on server components, it can be combined with any web service interface and server-side language like ASP.NET, Java, Perl, PHP, Python, or Ruby  For more info http://javascriptmvc.com/
  • 20. Backbone.js  Backbone.js is basically an uber-light framework that allows you to structure your Javascript code in anMVC(Model, View, Controller) fashion where...  Model is part of your code that retrieves and populates the data,  View is the HTML representation of this model(views change as models change, etc)  and Controller that in this case allows you to save the state of your javascript application via a hashbang url, for example: http://twitter.com/#search?q=backbone.js  http://backbonejs.org/  http://backbonetutorials.com/  http://www.asp.net/single-page-application/overview/templates/backbonejs-template
  • 21. Angularjs  A toolset based on extending the HTML vocabulary for your application  http://angularjs.org/  http://docs.angularjs.org/tutorial
  • 22.  is an MVC library for Javascript that lets you write maintainable and reusable browser code without the verbose or infrastructural overhead found in other MVC libraries. The goal is to enable developers to write web apps at least as quickly as with jQuery, while simplifying long-term maintainability through MVC objects.  http://agilityjs.com/
  • 23.  Sencha Ext JS is the industry's most powerful desktop application development platform with unparalleled cross-browser compatibility, advanced MVC architecture, plugin-free charting, and modern UI widgets  http://www.sencha.com/products/extjs
  • 24.  http://modernizr.com/  is a JavaScript library that detects HTML5 and CSS3 features in the user‟s browser  runs quickly on page load to detect features; it then creates a JavaScript object with the results, and adds classes to the HTML element for you to key your CSS on  http://webdesignernotebook.com/css/how-to-use-modernizr/
  • 25.  is an asynchronous conditional resource loader that's super-fast, and allows you to load only the scripts that your users need  http://yepnopejs.com/
  • 26. Winjs  Is a JavaScript library for building windows 8 store apps  http://winjstoolkit.codeplex.com  http://dev.bennage.com/blog/2012/08/01/a-brief-introduction-to-winjs/
  • 27. LimeJS  Is a HTML5 game framework for building fast, native-experience games for all modern touchscreens and desktop browsers  http://www.limejs.com/
  • 28. Lungo Framework  A framework based on HTML5 fordevelopers who want to design, buildand share cross device applications  http://www.lungo.tapquo.com/
  • 29.  Breeze is a JavaScript library that helps you manage data in rich client applications. If you store data in a database, query and save those data as complex object graphs, and share these graphs across multiple screens of your JavaScript client, Breeze is for you  http://www.breezejs.com/home  http://www.johnpapa.net/spajs04/
  • 30.  is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript  http://jquery.com/
  • 31.  jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. Whether you're building highly interactive web applications or you just need to add a date picker to a form control, jQuery UI is the perfect choice.  http://jqueryui.com/
  • 32.  A unified, HTML5-based user interface system for all popular mobile device platforms, built on the rock-solid jQuery and jQuery UI foundation. Its lightweight code is built with progressive enhancement, and has a flexible, easily themeable design.  http://jquerymobile.com/
  • 33.  Is A JavaScript Unit Testing framework.  is a powerful, easy-to-use JavaScript unit testing framework. It's used by the jQuery, jQuery UI and jQuery Mobile projects and is capable of testing any generic JavaScript code  http://qunitjs.com/
  • 34. Jo Framework for HTML5  he simple app framework for HTML5  For iOS, Android, webOS, BlackBerry, Chrome OS & anything else with HTML5  Widgets, lists and scrolling goodness using JavaScript & CSS3  Make native mobile apps or web apps with the same code  Works great with PhoneGap  http://joapp.com/  See a demo at http://joapp.com/live/samples/test.html
  • 35. DHTMLX Touch  DHTMLX Touch is a free open source JavaScript library for building HTML5-based mobile web apps. It's not just a set of UI widgets, but a complete framework that allows you to create eyecatching, robust web applications that run on iOS, Android, and other mobile platforms  http://dhtmlx.com/touch/
  • 36.  MooTools is a compact, modular, Object-Oriented JavaScript framework designed for the intermediate to advanced JavaScript developer. It allows you to write powerful, flexible, and cross-browser code with its elegant, well documented, and coherent API  http://mootools.net/
  • 37.  Prototype takes the complexity out of client-side web programming. Built to solve real-world problems, it adds useful extensions to the browser scripting environment and provides elegant APIs around the clumsy interfaces of Ajax and the Document Object Model  http://prototypejs.org/
  • 39.  Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices  http://nodejs.org/
  • 40. Finally, Thanks to JavaScript