SlideShare une entreprise Scribd logo
1  sur  18
JavaScript – A New Look Mr. Geek
Interpreted language what makes a static webpage dynamic. Is not complied but interpreted by the browser. Browser downloads the code and run it. Manipulates HTML object also known as DOM, such as form items, anchors. What is JavaScript?
Developed by Brendan Eich of Netscape, originally under the name mocha. Became livescript before renaming into JavaScript. Unrelated to Java, despite the name. It was developed to create a dynamic website. AJAX has given a brand new look to JavaScript; Now JavaScript has become more important than ever. History of JavaScript
Different browsers implements different versions of JavaScript. Some browsers like Internet Explorer even add their own functions to enhance the code. Every JavaScript codes does not work in every browser; therefore code should be written with the user demographic in mind. Newer browsers are adopting standard JavaScript; also known as “Class A” browsers. Browser Issues
To make static page more interactive by adding dynamic functions. Validate form before submitting. Since the data can be validated or cleaned up before sending to the server, JavaScript helps lessen the burden on the server. JavaScript can dynamically create and manipulate DOM objects, hence HTML pages can be created and changed programmatically without refreshing the page. JavaScript can fetch HTML objects as needed, so that unnecessary data does not transfer – this makes the page/data load faster. Why use JavaScript?
JavaScript can be implemented in three basic styles. Embed in Body of the document. Embed in Header of the document. Load from an external (.js) file. Embed in Body of the document This is the easiest way to implement JavaScript. Embed where needed using <script>…</script>. This is very poor way of implementation as the functions cannot be easily reused. Script is not available for the part of the document which is above the implantation. Difficult to manage codes. How to use JavaScript?
Embed in Header of the document Here <script>…</script> is implemented before the <body> tag. This ensures that JavaScript functions are available for all the parts of the documents (DOMs). Cannot be applied across multiple documents (webpages). Changes have to be replicated across multiple documents manually. Does not make the JavaScript code independent. More codes.	 How to use JavaScript?
Load from an external (.js) file Most efficient way of implementing JavaScript Codes. Multiple documents can reference single JavaScript files using <script src=“JSPATH”></script>. Changes in the script file with automatically reflected to all the documents that references it. This enables true separation of header components. One weakness of this implementation is that a page has to load all the JavaScript codes regardless it uses it or not. This is helped by caching; but what if the js file becomes multiple megabytes in size (this has become true in newer AJAX-enabled website). One way to overcome this weakness is that breaking up the file into multiple files and load dynamically only when a function is needed. AJAX makes this possible. How to use JavaScript?
With the explosion of AJAX enabled components like JavaScript trees and grids, JS files tend to become very large – often in multiple megabytes. Large files makes the web application slow due to net transfer and browser processing of large files. An ideal solution will be only download only the part of the file, whose function is called. This can be accomplished by creating multiple files with relevant piece of the code.  When the function that resides in a file is called; dynamically download the JS file with that function and load it to the browser – after it loads to the browser then only execute the function. All this process should happen within few seconds. Dynamic Load of JavaScript File
Previously JavaScript was restricted to form validation and interaction with HTML objects. Now AJAX (which is basically a JavaScript implementation) enables us to do more than just validation. It is used to fetch data without refreshing the page. It is used to fetch only the required data and modify only the part of the webpage. If you have a high traffic website, JavaScript is a must for form validation so that it is less burden for the server. When to Use JavaScript?
Since all the codes of JavaScript is available to the public; it is advisable not to put confidential business logic in the JavaScript code. As JavaScript runs in client machine you cannot use it to interact with the files and databases in the server. You would need an intermediary language like ASP.Net, PHP and CGI to do the server functions. If you need some of your data to be indexed by Search Engines; it is advisable to fetch data in static manner, instead of using AJAX. Till date Search Engines are not very AJAX friendly. When NOT to use JavaScript?
JavaScript follows basic rules of programming; and the codes are similar to c++ and Java. Every statement should end in “;” (Although many browsers do not enforce it). Variable variables can be public or private.  Variables are case sensitive. All the variables that are defined outside a function are public. Variables that are defined inside a function but with out a “var” keyword is also a public variable. Since JavaScript code is read and interpreted top to bottom; variables defined at the bottom are not available to the top. Eg: varfirstName=“santosh”; Anatomy of JavaScript - Variable
Array Array helps store and manipulate multiple values at multiple location in the memory. You can sort through an array. Array always have index number; can also have keyword. Array index starts with zero. Array can be single or multiple dimension. Eg: var animals = new Array(“Tiger”, “Fish”, “Snake”); document.write(animals[0]) prints Tiger. Anatomy of JavaScript - Array
Functions Functions in JavaScript can be used in two ways: As a regular function. As a signature of a class. This means any function in JavaScript can instantiate an object with new keyword. This is UNLIKE any other programming language. This is a very powerful feature, at the same time can make things very confusing. Just like in Class you can extend property of any function by using prototype keyword. This makes inheritance possible in JavaScript – which makes JavaScript truly object oriented programming. Functions can be nested; meaning you can define a function within a function. A JavaScript functions can be used as: function, method, constructor, class and modules Anatomy of JavaScript - Functions
JavaScript is an event driven language. Initiation of any class and method is done by a user clicking (or other interaction) any part of the document or a program initiating an event. Each object can listen to various types of events. Once an event is fired other functions work in harmony to accomplish relevant task. Example: <input type=button onClick=“doSomething();”> Here a button is capturing a click event. Once it captures, a function called doSomething is executed. Anatomy of JavaScript - Events
Example of a function: function Call(number){phone_dial(number)} Example of pseudo function: Call: function(number){phone_dial(number)} Extending a Class: Call.prototype.hangup(){phone_onhook();} Now the Call class has a hangup function. Instantiating an object from function: var c = new Call(); c.hangup(); //this is valid since we extened Call using prototype. Nesting functions: Call: function(number){Home: function(){dial:function(){}	}} Not it is possible to call the nested function dial.var c=new Call();c.Home.dial(); Anatomy of JavaScript - Functions
JavaScript and HTML’s implementation got out of control as new browsers did not follow the standard. A need for Standard implementation arose; which gave birth to XHTML, which follow the strict guidelines as in XML.  This give rise to Document Object Modal (DOM) which treats every element and nodes in the XHTML as an object. Like in XML you can manipulate XHTML via programming languages like JavaScript. You can reference to any node using XPATH. One can even use XQUERY to get and manipulate one or collection of similar nodes. This gave documents more structure and flexibility of manipulate. Since JavaScript was already doing some manipulation; it was an ideal choice of language for DOM Scripting. CSS plays a vital role in formatting the DOM objects. JavaScript can manipulate CSS as well. It can apply CSS formatting to one or multiple objects in the DOM. Example: var elements = document.getElementsByTagName("body")[0].childNodes;for(i=0;i<elements.length;i++){	   if(elements[i].nodeType == 1 && elements[i].id) alert(elements[i].id);} DOM Scripting
Invention of AJAX has revolutionize the way JavaScript is implemented. Even though basic AJAX means fetching the data asynchronously from the server (without refreshing the whole page), DOM Scripting has become synonymous to AJAX implementation.  Combination of DOM Scripting and AJAX has truly made a webpage a rich, dynamic and powerful medium to share information. AJAX has made the webpage very efficient by enabling it to download data in parts when needed and render only part of the webpage which is changed due to the new data. Different browsers have different implementation of AJAX but their basic concept is the same. AJAX tries to make stateless HTTP protocol seem stateful. …More about AJAX in next slideshow Reborn of JavaScript with AJAX

Contenu connexe

Tendances

An Introduction to Ajax Programming
An Introduction to Ajax ProgrammingAn Introduction to Ajax Programming
An Introduction to Ajax Programminghchen1
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event HandlingWebStackAcademy
 
What is Ajax technology?
What is Ajax technology?What is Ajax technology?
What is Ajax technology?JavaTpoint.Com
 
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSONAn introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSONSyed Moosa Kaleem
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajaxNir Elbaz
 
Introduction to ajax
Introduction  to  ajaxIntroduction  to  ajax
Introduction to ajaxPihu Goel
 
Ajax Introduction Presentation
Ajax   Introduction   PresentationAjax   Introduction   Presentation
Ajax Introduction Presentationthinkphp
 
Session vii(java scriptbasics)
Session vii(java scriptbasics)Session vii(java scriptbasics)
Session vii(java scriptbasics)Shrijan Tiwari
 
JAVA SCRIPT
JAVA SCRIPTJAVA SCRIPT
JAVA SCRIPTGo4Guru
 
jQuery - Chapter 1 - Introduction
 jQuery - Chapter 1 - Introduction jQuery - Chapter 1 - Introduction
jQuery - Chapter 1 - IntroductionWebStackAcademy
 
Angular - Chapter 5 - Directives
 Angular - Chapter 5 - Directives Angular - Chapter 5 - Directives
Angular - Chapter 5 - DirectivesWebStackAcademy
 

Tendances (20)

PHP - Introduction to PHP AJAX
PHP -  Introduction to PHP AJAXPHP -  Introduction to PHP AJAX
PHP - Introduction to PHP AJAX
 
An Introduction to Ajax Programming
An Introduction to Ajax ProgrammingAn Introduction to Ajax Programming
An Introduction to Ajax Programming
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
 
Ajax Ppt
Ajax PptAjax Ppt
Ajax Ppt
 
Ajax
AjaxAjax
Ajax
 
What is Ajax technology?
What is Ajax technology?What is Ajax technology?
What is Ajax technology?
 
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSONAn introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Introduction to ajax
Introduction  to  ajaxIntroduction  to  ajax
Introduction to ajax
 
Ajax Introduction Presentation
Ajax   Introduction   PresentationAjax   Introduction   Presentation
Ajax Introduction Presentation
 
JSON and XML
JSON and XMLJSON and XML
JSON and XML
 
Session vii(java scriptbasics)
Session vii(java scriptbasics)Session vii(java scriptbasics)
Session vii(java scriptbasics)
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 
JAVA SCRIPT
JAVA SCRIPTJAVA SCRIPT
JAVA SCRIPT
 
Jquery Ajax
Jquery AjaxJquery Ajax
Jquery Ajax
 
jQuery - Chapter 1 - Introduction
 jQuery - Chapter 1 - Introduction jQuery - Chapter 1 - Introduction
jQuery - Chapter 1 - Introduction
 
Ajax and Jquery
Ajax and JqueryAjax and Jquery
Ajax and Jquery
 
Angular - Chapter 5 - Directives
 Angular - Chapter 5 - Directives Angular - Chapter 5 - Directives
Angular - Chapter 5 - Directives
 
25250716 seminar-on-ajax text
25250716 seminar-on-ajax text25250716 seminar-on-ajax text
25250716 seminar-on-ajax text
 

En vedette

TED Talk Presentation
TED Talk PresentationTED Talk Presentation
TED Talk Presentationcoleyoung
 
Week 5 java script functions
Week 5  java script functionsWeek 5  java script functions
Week 5 java script functionsbrianjihoonlee
 
TM 2nd qtr-3ndmeeting(java script-functions)
TM 2nd qtr-3ndmeeting(java script-functions)TM 2nd qtr-3ndmeeting(java script-functions)
TM 2nd qtr-3ndmeeting(java script-functions)Esmeraldo Jr Guimbarda
 
JavaScript Functions
JavaScript Functions JavaScript Functions
JavaScript Functions Reem Alattas
 
LinkedIn TBC JavaScript 100: Functions
 LinkedIn TBC JavaScript 100: Functions LinkedIn TBC JavaScript 100: Functions
LinkedIn TBC JavaScript 100: FunctionsAdam Crabtree
 
Introduction to Nodejs
Introduction to NodejsIntroduction to Nodejs
Introduction to NodejsGabriele Lana
 

En vedette (6)

TED Talk Presentation
TED Talk PresentationTED Talk Presentation
TED Talk Presentation
 
Week 5 java script functions
Week 5  java script functionsWeek 5  java script functions
Week 5 java script functions
 
TM 2nd qtr-3ndmeeting(java script-functions)
TM 2nd qtr-3ndmeeting(java script-functions)TM 2nd qtr-3ndmeeting(java script-functions)
TM 2nd qtr-3ndmeeting(java script-functions)
 
JavaScript Functions
JavaScript Functions JavaScript Functions
JavaScript Functions
 
LinkedIn TBC JavaScript 100: Functions
 LinkedIn TBC JavaScript 100: Functions LinkedIn TBC JavaScript 100: Functions
LinkedIn TBC JavaScript 100: Functions
 
Introduction to Nodejs
Introduction to NodejsIntroduction to Nodejs
Introduction to Nodejs
 

Similaire à Java Script - A New Look

Basics java scripts
Basics java scriptsBasics java scripts
Basics java scriptsch samaram
 
Java script Basic
Java script BasicJava script Basic
Java script BasicJaya Kumari
 
JavaScript: Implementations And Applications
JavaScript: Implementations And ApplicationsJavaScript: Implementations And Applications
JavaScript: Implementations And ApplicationsPragya Pai
 
Introduction to mean and mern || Event by DSC UNIDEB
Introduction to mean and mern || Event by DSC UNIDEBIntroduction to mean and mern || Event by DSC UNIDEB
Introduction to mean and mern || Event by DSC UNIDEBMuhammad Raza
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application developmentzonathen
 
Java script by Act Academy
Java script by Act AcademyJava script by Act Academy
Java script by Act Academyactanimation
 
PPT on javascript ajax and css and some points related to server
PPT on javascript ajax and css and some points related to serverPPT on javascript ajax and css and some points related to server
PPT on javascript ajax and css and some points related to servershivanichourasia01
 
Beyond HTML: Tools for Building Web 2.0 Apps
Beyond HTML: Tools for Building Web 2.0 AppsBeyond HTML: Tools for Building Web 2.0 Apps
Beyond HTML: Tools for Building Web 2.0 AppsMarcos Caceres
 
Using Ajax In Domino Web Applications
Using Ajax In Domino Web ApplicationsUsing Ajax In Domino Web Applications
Using Ajax In Domino Web Applicationsdominion
 
Java script202
Java script202Java script202
Java script202Wasiq Zia
 
JavaScript - Getting Started.pptx
JavaScript - Getting Started.pptxJavaScript - Getting Started.pptx
JavaScript - Getting Started.pptxJonnJorellPunto
 
Lessons from the Trenches: Engineering Great AJAX Experiences
Lessons from the Trenches: Engineering Great AJAX ExperiencesLessons from the Trenches: Engineering Great AJAX Experiences
Lessons from the Trenches: Engineering Great AJAX Experiencesgoodfriday
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]GDSC UofT Mississauga
 
CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2Geoffrey Fox
 
What is java script
What is java scriptWhat is java script
What is java scriptsumanbaba_73
 

Similaire à Java Script - A New Look (20)

Basics java scripts
Basics java scriptsBasics java scripts
Basics java scripts
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
Java script Basic
Java script BasicJava script Basic
Java script Basic
 
JavaScript: Implementations And Applications
JavaScript: Implementations And ApplicationsJavaScript: Implementations And Applications
JavaScript: Implementations And Applications
 
Introduction to mean and mern || Event by DSC UNIDEB
Introduction to mean and mern || Event by DSC UNIDEBIntroduction to mean and mern || Event by DSC UNIDEB
Introduction to mean and mern || Event by DSC UNIDEB
 
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 by Act Academy
Java script by Act AcademyJava script by Act Academy
Java script by Act Academy
 
PPT on javascript ajax and css and some points related to server
PPT on javascript ajax and css and some points related to serverPPT on javascript ajax and css and some points related to server
PPT on javascript ajax and css and some points related to server
 
Beyond HTML: Tools for Building Web 2.0 Apps
Beyond HTML: Tools for Building Web 2.0 AppsBeyond HTML: Tools for Building Web 2.0 Apps
Beyond HTML: Tools for Building Web 2.0 Apps
 
Using Ajax In Domino Web Applications
Using Ajax In Domino Web ApplicationsUsing Ajax In Domino Web Applications
Using Ajax In Domino Web Applications
 
Java script202
Java script202Java script202
Java script202
 
JavaScript - Getting Started.pptx
JavaScript - Getting Started.pptxJavaScript - Getting Started.pptx
JavaScript - Getting Started.pptx
 
WTA-MODULE-4.pptx
WTA-MODULE-4.pptxWTA-MODULE-4.pptx
WTA-MODULE-4.pptx
 
Lessons from the Trenches: Engineering Great AJAX Experiences
Lessons from the Trenches: Engineering Great AJAX ExperiencesLessons from the Trenches: Engineering Great AJAX Experiences
Lessons from the Trenches: Engineering Great AJAX Experiences
 
Lessons
LessonsLessons
Lessons
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
 
Javascripts. pptt
Javascripts. ppttJavascripts. pptt
Javascripts. pptt
 
CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2
 
What is java script
What is java scriptWhat is java script
What is java script
 
CSC PPT 12.pptx
CSC PPT 12.pptxCSC PPT 12.pptx
CSC PPT 12.pptx
 

Dernier

Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 

Dernier (20)

Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 

Java Script - A New Look

  • 1. JavaScript – A New Look Mr. Geek
  • 2. Interpreted language what makes a static webpage dynamic. Is not complied but interpreted by the browser. Browser downloads the code and run it. Manipulates HTML object also known as DOM, such as form items, anchors. What is JavaScript?
  • 3. Developed by Brendan Eich of Netscape, originally under the name mocha. Became livescript before renaming into JavaScript. Unrelated to Java, despite the name. It was developed to create a dynamic website. AJAX has given a brand new look to JavaScript; Now JavaScript has become more important than ever. History of JavaScript
  • 4. Different browsers implements different versions of JavaScript. Some browsers like Internet Explorer even add their own functions to enhance the code. Every JavaScript codes does not work in every browser; therefore code should be written with the user demographic in mind. Newer browsers are adopting standard JavaScript; also known as “Class A” browsers. Browser Issues
  • 5. To make static page more interactive by adding dynamic functions. Validate form before submitting. Since the data can be validated or cleaned up before sending to the server, JavaScript helps lessen the burden on the server. JavaScript can dynamically create and manipulate DOM objects, hence HTML pages can be created and changed programmatically without refreshing the page. JavaScript can fetch HTML objects as needed, so that unnecessary data does not transfer – this makes the page/data load faster. Why use JavaScript?
  • 6. JavaScript can be implemented in three basic styles. Embed in Body of the document. Embed in Header of the document. Load from an external (.js) file. Embed in Body of the document This is the easiest way to implement JavaScript. Embed where needed using <script>…</script>. This is very poor way of implementation as the functions cannot be easily reused. Script is not available for the part of the document which is above the implantation. Difficult to manage codes. How to use JavaScript?
  • 7. Embed in Header of the document Here <script>…</script> is implemented before the <body> tag. This ensures that JavaScript functions are available for all the parts of the documents (DOMs). Cannot be applied across multiple documents (webpages). Changes have to be replicated across multiple documents manually. Does not make the JavaScript code independent. More codes. How to use JavaScript?
  • 8. Load from an external (.js) file Most efficient way of implementing JavaScript Codes. Multiple documents can reference single JavaScript files using <script src=“JSPATH”></script>. Changes in the script file with automatically reflected to all the documents that references it. This enables true separation of header components. One weakness of this implementation is that a page has to load all the JavaScript codes regardless it uses it or not. This is helped by caching; but what if the js file becomes multiple megabytes in size (this has become true in newer AJAX-enabled website). One way to overcome this weakness is that breaking up the file into multiple files and load dynamically only when a function is needed. AJAX makes this possible. How to use JavaScript?
  • 9. With the explosion of AJAX enabled components like JavaScript trees and grids, JS files tend to become very large – often in multiple megabytes. Large files makes the web application slow due to net transfer and browser processing of large files. An ideal solution will be only download only the part of the file, whose function is called. This can be accomplished by creating multiple files with relevant piece of the code. When the function that resides in a file is called; dynamically download the JS file with that function and load it to the browser – after it loads to the browser then only execute the function. All this process should happen within few seconds. Dynamic Load of JavaScript File
  • 10. Previously JavaScript was restricted to form validation and interaction with HTML objects. Now AJAX (which is basically a JavaScript implementation) enables us to do more than just validation. It is used to fetch data without refreshing the page. It is used to fetch only the required data and modify only the part of the webpage. If you have a high traffic website, JavaScript is a must for form validation so that it is less burden for the server. When to Use JavaScript?
  • 11. Since all the codes of JavaScript is available to the public; it is advisable not to put confidential business logic in the JavaScript code. As JavaScript runs in client machine you cannot use it to interact with the files and databases in the server. You would need an intermediary language like ASP.Net, PHP and CGI to do the server functions. If you need some of your data to be indexed by Search Engines; it is advisable to fetch data in static manner, instead of using AJAX. Till date Search Engines are not very AJAX friendly. When NOT to use JavaScript?
  • 12. JavaScript follows basic rules of programming; and the codes are similar to c++ and Java. Every statement should end in “;” (Although many browsers do not enforce it). Variable variables can be public or private. Variables are case sensitive. All the variables that are defined outside a function are public. Variables that are defined inside a function but with out a “var” keyword is also a public variable. Since JavaScript code is read and interpreted top to bottom; variables defined at the bottom are not available to the top. Eg: varfirstName=“santosh”; Anatomy of JavaScript - Variable
  • 13. Array Array helps store and manipulate multiple values at multiple location in the memory. You can sort through an array. Array always have index number; can also have keyword. Array index starts with zero. Array can be single or multiple dimension. Eg: var animals = new Array(“Tiger”, “Fish”, “Snake”); document.write(animals[0]) prints Tiger. Anatomy of JavaScript - Array
  • 14. Functions Functions in JavaScript can be used in two ways: As a regular function. As a signature of a class. This means any function in JavaScript can instantiate an object with new keyword. This is UNLIKE any other programming language. This is a very powerful feature, at the same time can make things very confusing. Just like in Class you can extend property of any function by using prototype keyword. This makes inheritance possible in JavaScript – which makes JavaScript truly object oriented programming. Functions can be nested; meaning you can define a function within a function. A JavaScript functions can be used as: function, method, constructor, class and modules Anatomy of JavaScript - Functions
  • 15. JavaScript is an event driven language. Initiation of any class and method is done by a user clicking (or other interaction) any part of the document or a program initiating an event. Each object can listen to various types of events. Once an event is fired other functions work in harmony to accomplish relevant task. Example: <input type=button onClick=“doSomething();”> Here a button is capturing a click event. Once it captures, a function called doSomething is executed. Anatomy of JavaScript - Events
  • 16. Example of a function: function Call(number){phone_dial(number)} Example of pseudo function: Call: function(number){phone_dial(number)} Extending a Class: Call.prototype.hangup(){phone_onhook();} Now the Call class has a hangup function. Instantiating an object from function: var c = new Call(); c.hangup(); //this is valid since we extened Call using prototype. Nesting functions: Call: function(number){Home: function(){dial:function(){} }} Not it is possible to call the nested function dial.var c=new Call();c.Home.dial(); Anatomy of JavaScript - Functions
  • 17. JavaScript and HTML’s implementation got out of control as new browsers did not follow the standard. A need for Standard implementation arose; which gave birth to XHTML, which follow the strict guidelines as in XML. This give rise to Document Object Modal (DOM) which treats every element and nodes in the XHTML as an object. Like in XML you can manipulate XHTML via programming languages like JavaScript. You can reference to any node using XPATH. One can even use XQUERY to get and manipulate one or collection of similar nodes. This gave documents more structure and flexibility of manipulate. Since JavaScript was already doing some manipulation; it was an ideal choice of language for DOM Scripting. CSS plays a vital role in formatting the DOM objects. JavaScript can manipulate CSS as well. It can apply CSS formatting to one or multiple objects in the DOM. Example: var elements = document.getElementsByTagName("body")[0].childNodes;for(i=0;i<elements.length;i++){ if(elements[i].nodeType == 1 && elements[i].id) alert(elements[i].id);} DOM Scripting
  • 18. Invention of AJAX has revolutionize the way JavaScript is implemented. Even though basic AJAX means fetching the data asynchronously from the server (without refreshing the whole page), DOM Scripting has become synonymous to AJAX implementation. Combination of DOM Scripting and AJAX has truly made a webpage a rich, dynamic and powerful medium to share information. AJAX has made the webpage very efficient by enabling it to download data in parts when needed and render only part of the webpage which is changed due to the new data. Different browsers have different implementation of AJAX but their basic concept is the same. AJAX tries to make stateless HTTP protocol seem stateful. …More about AJAX in next slideshow Reborn of JavaScript with AJAX