SlideShare ist ein Scribd-Unternehmen logo
1 von 35
CORDOVA TRAINING
SESSION: 3 – ADVANCED JAVASCRIPT
OBJECTS
 JavaScript is an Object Oriented Programming (OOP) language.
 Objects are composed of attributes.
 If an attribute contains a function, it is considered to be a method.
OBJECT PROPERTIES
 Object properties can be any of the three primitive data types, or any of the abstract
data types, such as another object.
 Object properties are usually variables that are used internally in the object's methods,
but can also be globally visible variables that are used throughout the page.
 The syntax for adding a property to an object is:
objectName.objectProperty = propertyValue;
OBJECT METHODS
 Methods are the functions that let the object do something or let something be done
to it.
 There is a small difference between a function and a method.
 A function is a standalone unit of statements and a method is attached to an object
and can be referenced by the this keyword.
USER DEFINED OBJECTS
 All user-defined objects and built-in objects are descendants of an object called Object.
 The new operator is used to create an instance of an object. To create an object, the
new operator is followed by the object name method.
 The object name method is called a ‘constructor’.
var employee = new Object();
var books = new Array("C++", "Perl", "Java");
var day = new Date("August 15, 1947");
OBJECT CONSTRUCTOR
 A constructor is a function that creates and initializes an object.
 JavaScript provides a special constructor function called Object() to build the object.
The return value of the Object() constructor is assigned to a variable.
 The variable contains a reference to the new object.
var book = new Object();
book.subject = “Introduction to JavaScript ";
book.author = “Binu Paul";
OBJECT METHODS
 An object method is created by defining functions with in an object.
function book(title, author){
this.title = title;
this.author = author;
this.addPrice = addPrice;
}
BUILT-IN OBJECTS
 JavaScript has several built-in or native objects. These objects are accessible anywhere
in your program and will work the same way in any browser running in any operating
system.
 Some of the popular objects are:
 Date
 Math
 String
 Array
DATE OBJECT
 The Date object is a datatype built into the JavaScript language. The date methods
simply allow you to get and set the year, month, day, hour, minute, second, and
millisecond fields of the object
 Some of the popular methods are:
 getDay();
 getMonth();
 getFullYear();
 getHours();
 getMinutes();
 getSeconds();
MATH OBJECT
 The math object provides you properties and methods for mathematical constants and
functions. Unlike other global objects, Math is not a constructor.
 Some of the popular methods are:
 Math.PI;
 Math.abs(x);
 Math.cos(x);
 Math.sin(x);
 Math.tan(x);
 Math.random();
MATH OBJECT
 Math.floor(x)
 Math.ceil(x);
 Math.log(x);
 Math.max(x1, x2,…);
 Math.min(x1, x2, …);
 Math.sqrt(x);
 Math.pow(x, y);
STRING OBJECT
 The String object lets you work with a series of characters; it wraps Javascript's string
primitive data type with a number of helper methods.
 You can get the length of a sting using length attribute.
 Some of the popular methods are:
 toUpperCase();
 toLowerCase();
 substr(startPosition, length);
 concat(str1, str2, …);
 split(separator, limit);
ARRAY OBJECT
 The Array object lets you store multiple values in a single variable. It stores a fixed-size
sequential collection of elements of the same type.
 An array is used to store a collection of data, but it is often more useful to think of an
array as a collection of variables of the same type.
 We can get the length of array using the length attribute.
 Some of the popular methods are:
 push(element1, element2, …);
 pop();
ARRAY OBJECT
 reverse();
 sort();
 shift();
 join(seperator);
ACCESSING HTML DOM
 Every web page resides inside a browser window which can be considered as an object.
 DOM stands for Document Object Model.
 A Document object represents the HTML document that is displayed in that window.
The Document object has various properties that refer to other objects which allow
access to and modification of document content.
DOM HIERARCHY
DOM HIERARCHY
 Window object − Top of the hierarchy. It is the outmost element of the object hierarchy.
 Document object − Each HTML document that gets loaded into a window becomes a
document object. The document contains the contents of the page.
 Form object − Everything enclosed in the <form>...</form> tags sets the form object.
DOM ATTRIBUTES
 This DOM model provides several read-only properties, such as title, URL, and
lastModified provide information about the document as a whole.
 The most popular document properties are:
 alinkColor
 anchors[ ]
DOM ATTRIBUTES
 domain
 forms[ ]
 images[ ]
 location
 referrer
 title
 URL
DOM METHODS
 There are various methods provided by DOM model which can be used to set and get
document property values.
 document.getElementById(id);
 document.getElementsByName(name);
 document.getElementsByTagName(tagName);
DOM - WINDOW
 The window object represents a window containing a DOM document; the document
property points to the DOM document loaded in that window. A window for a given
document can be obtained using the document.defaultView property. The popular
methods are:
 window.forward();
 window.back();
 window.home();
 window.open(url);
 window.close();
DOM - LOCATION
 The Location interface represents the location (URL) of the object it is linked to. The
mostly used properties are:
 location.href;
 location.protocol;
 location.host;
 location.pathname;
 location.port;
DOM - LOCATION
 The mostly used methods are:
 location.reload();
 location.replace(url);
DOM - SCREEN
 The Screen interface represents a screen, usually the one on which the current window
is being rendered. The mostly used properties are:
 screen.height;
 screen.width;
 screen.top;
 screen.left;
DOM - CSS
 The HTML DOM allows JavaScript to change the style of HTML elements. To change the
style of an HTML element, use this syntax:
document.getElementById(id).style.property=new style;
JAVASCRIPT - EVENTS
 An HTML event can be something the browser does, or something a user does. Here
are some examples of HTML events:
 An HTML web page has finished loading
 An HTML input field was changed
 An HTML button was clicked
 Often, when events happen, you may want to do something. JavaScript lets you
execute code when events are detected.
JAVASCRIPT - EVENTS
 JavaScript can be executed when an event occurs, like when a user clicks on an HTML
element.
 The syntax is:
<some-HTML-element some-event="some JavaScript">
JAVASCRIPT - EVENTS
 The common event elements are:
 onchange
 onclick
 onload
 onkeydown
 onfocus
 onblur
JSON
 JSON stands for JavaScript Object Notation.
 JSON is a format for storing and transporting data.
 JSON format is text only.
 JSON is often used when data is sent from a server to a web page.
 The JSON Format Evaluates to JavaScript Objects.
JSON SYNTAX RULE
 Data is in name/value pairs.
 Data is separated by commas.
 Curly braces hold objects.
 Square brackets hold arrays.
JSON DATA
 JSON data is written as name/value pairs, just like JavaScript object properties.
 A name/value pair consists of a field name (in double quotes), followed by a colon,
followed by a value.
"firstName":"John“
{ "employees":[
{"firstName":“Steve”, "lastName":“Jobs"},
{"firstName":“Tim“, "lastName":“Cook"}
] }
JSON OBJECT
 JSON objects are written inside curly braces.
 Just like in JavaScript, objects can contain multiple name/value pairs.
{"firstName":"John", "lastName":"Doe"}
JSON ARRAY
 JSON arrays are written inside square brackets.
 Just like in JavaScript, an array can contain objects.
"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]
JSON PARSING
 A common use of JSON is to read data from a web server, and display the data in a
web page.
 We can use the JavaScript built-in function JSON.parse() to convert the string into a
JavaScript object.
var obj = JSON.parse(text);
THANK YOU

Weitere ähnliche Inhalte

Was ist angesagt?

Functions and Objects in JavaScript
Functions and Objects in JavaScript Functions and Objects in JavaScript
Functions and Objects in JavaScript Dhananjay Kumar
 
12. session 12 java script objects
12. session 12   java script objects12. session 12   java script objects
12. session 12 java script objectsPhúc Đỗ
 
jQuery. Write less. Do More.
jQuery. Write less. Do More.jQuery. Write less. Do More.
jQuery. Write less. Do More.Dennis Loktionov
 
Javascript, DOM, browsers and frameworks basics
Javascript, DOM, browsers and frameworks basicsJavascript, DOM, browsers and frameworks basics
Javascript, DOM, browsers and frameworks basicsNet7
 
Xsd restrictions, xsl elements, dhtml
Xsd restrictions, xsl elements, dhtmlXsd restrictions, xsl elements, dhtml
Xsd restrictions, xsl elements, dhtmlAMIT VIRAMGAMI
 
11. session 11 functions and objects
11. session 11   functions and objects11. session 11   functions and objects
11. session 11 functions and objectsPhúc Đỗ
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQueryZeeshan Khan
 
Easy data-with-spring-data-jpa
Easy data-with-spring-data-jpaEasy data-with-spring-data-jpa
Easy data-with-spring-data-jpaStaples
 

Was ist angesagt? (20)

Functions and Objects in JavaScript
Functions and Objects in JavaScript Functions and Objects in JavaScript
Functions and Objects in JavaScript
 
Jquery
JqueryJquery
Jquery
 
12. session 12 java script objects
12. session 12   java script objects12. session 12   java script objects
12. session 12 java script objects
 
jQuery. Write less. Do More.
jQuery. Write less. Do More.jQuery. Write less. Do More.
jQuery. Write less. Do More.
 
Json
JsonJson
Json
 
Session 09 - OOPS
Session 09 - OOPSSession 09 - OOPS
Session 09 - OOPS
 
Javascript, DOM, browsers and frameworks basics
Javascript, DOM, browsers and frameworks basicsJavascript, DOM, browsers and frameworks basics
Javascript, DOM, browsers and frameworks basics
 
Spring Data JPA
Spring Data JPASpring Data JPA
Spring Data JPA
 
Xsd restrictions, xsl elements, dhtml
Xsd restrictions, xsl elements, dhtmlXsd restrictions, xsl elements, dhtml
Xsd restrictions, xsl elements, dhtml
 
11. session 11 functions and objects
11. session 11   functions and objects11. session 11   functions and objects
11. session 11 functions and objects
 
Reversing JavaScript
Reversing JavaScriptReversing JavaScript
Reversing JavaScript
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
Jscript part2
Jscript part2Jscript part2
Jscript part2
 
Java Script Basics
Java Script BasicsJava Script Basics
Java Script Basics
 
Ajax
AjaxAjax
Ajax
 
jQuery
jQueryjQuery
jQuery
 
Easy data-with-spring-data-jpa
Easy data-with-spring-data-jpaEasy data-with-spring-data-jpa
Easy data-with-spring-data-jpa
 
Jquery 2
Jquery 2Jquery 2
Jquery 2
 
jQuery Introduction
jQuery IntroductionjQuery Introduction
jQuery Introduction
 
jQuery
jQueryjQuery
jQuery
 

Ähnlich wie Cordova Advanced JavaScript Objects, Events & JSON

Web Development Introduction to jQuery
Web Development Introduction to jQueryWeb Development Introduction to jQuery
Web Development Introduction to jQueryLaurence Svekis ✔
 
INTRODUCTION TO CLIENT SIDE PROGRAMMING
INTRODUCTION TO CLIENT SIDE PROGRAMMINGINTRODUCTION TO CLIENT SIDE PROGRAMMING
INTRODUCTION TO CLIENT SIDE PROGRAMMINGProf Ansari
 
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPTHSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPTAAFREEN SHAIKH
 
Understanding-Objects-in-Javascript.pptx
Understanding-Objects-in-Javascript.pptxUnderstanding-Objects-in-Javascript.pptx
Understanding-Objects-in-Javascript.pptxMariaTrinidadTumanga
 
Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02Sopheak Sem
 
Document Object Model (DOM)
Document Object Model (DOM)Document Object Model (DOM)
Document Object Model (DOM)GOPAL BASAK
 
Oop features java presentationshow
Oop features java presentationshowOop features java presentationshow
Oop features java presentationshowilias ahmed
 
JavaScript Workshop
JavaScript WorkshopJavaScript Workshop
JavaScript WorkshopPamela Fox
 
Javascript Templating
Javascript TemplatingJavascript Templating
Javascript Templatingbcruhl
 
eXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction TrainingeXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction TrainingHoat Le
 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - ObjectsWebStackAcademy
 

Ähnlich wie Cordova Advanced JavaScript Objects, Events & JSON (20)

Web Development Introduction to jQuery
Web Development Introduction to jQueryWeb Development Introduction to jQuery
Web Development Introduction to jQuery
 
Javascript.ppt
Javascript.pptJavascript.ppt
Javascript.ppt
 
INTRODUCTION TO CLIENT SIDE PROGRAMMING
INTRODUCTION TO CLIENT SIDE PROGRAMMINGINTRODUCTION TO CLIENT SIDE PROGRAMMING
INTRODUCTION TO CLIENT SIDE PROGRAMMING
 
JS basics
JS basicsJS basics
JS basics
 
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPTHSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
 
JavsScript OOP
JavsScript OOPJavsScript OOP
JavsScript OOP
 
J Query
J QueryJ Query
J Query
 
Dom
Dom Dom
Dom
 
Understanding-Objects-in-Javascript.pptx
Understanding-Objects-in-Javascript.pptxUnderstanding-Objects-in-Javascript.pptx
Understanding-Objects-in-Javascript.pptx
 
Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02
 
Understanding XML DOM
Understanding XML DOMUnderstanding XML DOM
Understanding XML DOM
 
Document Object Model (DOM)
Document Object Model (DOM)Document Object Model (DOM)
Document Object Model (DOM)
 
Jquery beltranhomewrok
Jquery beltranhomewrokJquery beltranhomewrok
Jquery beltranhomewrok
 
Jquery beltranhomewrok
Jquery beltranhomewrokJquery beltranhomewrok
Jquery beltranhomewrok
 
Oop features java presentationshow
Oop features java presentationshowOop features java presentationshow
Oop features java presentationshow
 
JavaScript Workshop
JavaScript WorkshopJavaScript Workshop
JavaScript Workshop
 
Oop java
Oop javaOop java
Oop java
 
Javascript Templating
Javascript TemplatingJavascript Templating
Javascript Templating
 
eXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction TrainingeXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction Training
 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - Objects
 

Mehr von Binu Paul

Cordova training - Day 9 - SQLITE
Cordova training - Day 9 - SQLITECordova training - Day 9 - SQLITE
Cordova training - Day 9 - SQLITEBinu Paul
 
Cordova training - Day 8 - REST API's
Cordova training - Day 8 - REST API'sCordova training - Day 8 - REST API's
Cordova training - Day 8 - REST API'sBinu Paul
 
Cordova training - Day 7 - Form data processing
Cordova training - Day 7 - Form data processingCordova training - Day 7 - Form data processing
Cordova training - Day 7 - Form data processingBinu Paul
 
Cordova training : Cordova plugins
Cordova training : Cordova pluginsCordova training : Cordova plugins
Cordova training : Cordova pluginsBinu Paul
 
Cordova training : Day 6 - UI development using Framework7
Cordova training : Day 6 - UI development using Framework7Cordova training : Day 6 - UI development using Framework7
Cordova training : Day 6 - UI development using Framework7Binu Paul
 
Cordova training : Day 5 - UI development using Framework7
Cordova training : Day 5 - UI development using Framework7Cordova training : Day 5 - UI development using Framework7
Cordova training : Day 5 - UI development using Framework7Binu Paul
 
Cordova training : Day 3 - Introduction to Javascript
Cordova training : Day 3 - Introduction to JavascriptCordova training : Day 3 - Introduction to Javascript
Cordova training : Day 3 - Introduction to JavascriptBinu Paul
 
Cordova training - Day 3 : Advanced CSS 3
Cordova training - Day 3 : Advanced CSS 3Cordova training - Day 3 : Advanced CSS 3
Cordova training - Day 3 : Advanced CSS 3Binu Paul
 
Cordova training - Day 2 Introduction to CSS 3
Cordova training - Day 2 Introduction to CSS 3Cordova training - Day 2 Introduction to CSS 3
Cordova training - Day 2 Introduction to CSS 3Binu Paul
 
Cordova training : Day 1 : Introduction to Cordova
Cordova training : Day 1 : Introduction to CordovaCordova training : Day 1 : Introduction to Cordova
Cordova training : Day 1 : Introduction to CordovaBinu Paul
 

Mehr von Binu Paul (11)

GIT
GITGIT
GIT
 
Cordova training - Day 9 - SQLITE
Cordova training - Day 9 - SQLITECordova training - Day 9 - SQLITE
Cordova training - Day 9 - SQLITE
 
Cordova training - Day 8 - REST API's
Cordova training - Day 8 - REST API'sCordova training - Day 8 - REST API's
Cordova training - Day 8 - REST API's
 
Cordova training - Day 7 - Form data processing
Cordova training - Day 7 - Form data processingCordova training - Day 7 - Form data processing
Cordova training - Day 7 - Form data processing
 
Cordova training : Cordova plugins
Cordova training : Cordova pluginsCordova training : Cordova plugins
Cordova training : Cordova plugins
 
Cordova training : Day 6 - UI development using Framework7
Cordova training : Day 6 - UI development using Framework7Cordova training : Day 6 - UI development using Framework7
Cordova training : Day 6 - UI development using Framework7
 
Cordova training : Day 5 - UI development using Framework7
Cordova training : Day 5 - UI development using Framework7Cordova training : Day 5 - UI development using Framework7
Cordova training : Day 5 - UI development using Framework7
 
Cordova training : Day 3 - Introduction to Javascript
Cordova training : Day 3 - Introduction to JavascriptCordova training : Day 3 - Introduction to Javascript
Cordova training : Day 3 - Introduction to Javascript
 
Cordova training - Day 3 : Advanced CSS 3
Cordova training - Day 3 : Advanced CSS 3Cordova training - Day 3 : Advanced CSS 3
Cordova training - Day 3 : Advanced CSS 3
 
Cordova training - Day 2 Introduction to CSS 3
Cordova training - Day 2 Introduction to CSS 3Cordova training - Day 2 Introduction to CSS 3
Cordova training - Day 2 Introduction to CSS 3
 
Cordova training : Day 1 : Introduction to Cordova
Cordova training : Day 1 : Introduction to CordovaCordova training : Day 1 : Introduction to Cordova
Cordova training : Day 1 : Introduction to Cordova
 

Kürzlich hochgeladen

why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 

Kürzlich hochgeladen (20)

why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 

Cordova Advanced JavaScript Objects, Events & JSON

  • 1. CORDOVA TRAINING SESSION: 3 – ADVANCED JAVASCRIPT
  • 2. OBJECTS  JavaScript is an Object Oriented Programming (OOP) language.  Objects are composed of attributes.  If an attribute contains a function, it is considered to be a method.
  • 3. OBJECT PROPERTIES  Object properties can be any of the three primitive data types, or any of the abstract data types, such as another object.  Object properties are usually variables that are used internally in the object's methods, but can also be globally visible variables that are used throughout the page.  The syntax for adding a property to an object is: objectName.objectProperty = propertyValue;
  • 4. OBJECT METHODS  Methods are the functions that let the object do something or let something be done to it.  There is a small difference between a function and a method.  A function is a standalone unit of statements and a method is attached to an object and can be referenced by the this keyword.
  • 5. USER DEFINED OBJECTS  All user-defined objects and built-in objects are descendants of an object called Object.  The new operator is used to create an instance of an object. To create an object, the new operator is followed by the object name method.  The object name method is called a ‘constructor’. var employee = new Object(); var books = new Array("C++", "Perl", "Java"); var day = new Date("August 15, 1947");
  • 6. OBJECT CONSTRUCTOR  A constructor is a function that creates and initializes an object.  JavaScript provides a special constructor function called Object() to build the object. The return value of the Object() constructor is assigned to a variable.  The variable contains a reference to the new object. var book = new Object(); book.subject = “Introduction to JavaScript "; book.author = “Binu Paul";
  • 7. OBJECT METHODS  An object method is created by defining functions with in an object. function book(title, author){ this.title = title; this.author = author; this.addPrice = addPrice; }
  • 8. BUILT-IN OBJECTS  JavaScript has several built-in or native objects. These objects are accessible anywhere in your program and will work the same way in any browser running in any operating system.  Some of the popular objects are:  Date  Math  String  Array
  • 9. DATE OBJECT  The Date object is a datatype built into the JavaScript language. The date methods simply allow you to get and set the year, month, day, hour, minute, second, and millisecond fields of the object  Some of the popular methods are:  getDay();  getMonth();  getFullYear();  getHours();  getMinutes();  getSeconds();
  • 10. MATH OBJECT  The math object provides you properties and methods for mathematical constants and functions. Unlike other global objects, Math is not a constructor.  Some of the popular methods are:  Math.PI;  Math.abs(x);  Math.cos(x);  Math.sin(x);  Math.tan(x);  Math.random();
  • 11. MATH OBJECT  Math.floor(x)  Math.ceil(x);  Math.log(x);  Math.max(x1, x2,…);  Math.min(x1, x2, …);  Math.sqrt(x);  Math.pow(x, y);
  • 12. STRING OBJECT  The String object lets you work with a series of characters; it wraps Javascript's string primitive data type with a number of helper methods.  You can get the length of a sting using length attribute.  Some of the popular methods are:  toUpperCase();  toLowerCase();  substr(startPosition, length);  concat(str1, str2, …);  split(separator, limit);
  • 13. ARRAY OBJECT  The Array object lets you store multiple values in a single variable. It stores a fixed-size sequential collection of elements of the same type.  An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.  We can get the length of array using the length attribute.  Some of the popular methods are:  push(element1, element2, …);  pop();
  • 14. ARRAY OBJECT  reverse();  sort();  shift();  join(seperator);
  • 15. ACCESSING HTML DOM  Every web page resides inside a browser window which can be considered as an object.  DOM stands for Document Object Model.  A Document object represents the HTML document that is displayed in that window. The Document object has various properties that refer to other objects which allow access to and modification of document content.
  • 17. DOM HIERARCHY  Window object − Top of the hierarchy. It is the outmost element of the object hierarchy.  Document object − Each HTML document that gets loaded into a window becomes a document object. The document contains the contents of the page.  Form object − Everything enclosed in the <form>...</form> tags sets the form object.
  • 18. DOM ATTRIBUTES  This DOM model provides several read-only properties, such as title, URL, and lastModified provide information about the document as a whole.  The most popular document properties are:  alinkColor  anchors[ ]
  • 19. DOM ATTRIBUTES  domain  forms[ ]  images[ ]  location  referrer  title  URL
  • 20. DOM METHODS  There are various methods provided by DOM model which can be used to set and get document property values.  document.getElementById(id);  document.getElementsByName(name);  document.getElementsByTagName(tagName);
  • 21. DOM - WINDOW  The window object represents a window containing a DOM document; the document property points to the DOM document loaded in that window. A window for a given document can be obtained using the document.defaultView property. The popular methods are:  window.forward();  window.back();  window.home();  window.open(url);  window.close();
  • 22. DOM - LOCATION  The Location interface represents the location (URL) of the object it is linked to. The mostly used properties are:  location.href;  location.protocol;  location.host;  location.pathname;  location.port;
  • 23. DOM - LOCATION  The mostly used methods are:  location.reload();  location.replace(url);
  • 24. DOM - SCREEN  The Screen interface represents a screen, usually the one on which the current window is being rendered. The mostly used properties are:  screen.height;  screen.width;  screen.top;  screen.left;
  • 25. DOM - CSS  The HTML DOM allows JavaScript to change the style of HTML elements. To change the style of an HTML element, use this syntax: document.getElementById(id).style.property=new style;
  • 26. JAVASCRIPT - EVENTS  An HTML event can be something the browser does, or something a user does. Here are some examples of HTML events:  An HTML web page has finished loading  An HTML input field was changed  An HTML button was clicked  Often, when events happen, you may want to do something. JavaScript lets you execute code when events are detected.
  • 27. JAVASCRIPT - EVENTS  JavaScript can be executed when an event occurs, like when a user clicks on an HTML element.  The syntax is: <some-HTML-element some-event="some JavaScript">
  • 28. JAVASCRIPT - EVENTS  The common event elements are:  onchange  onclick  onload  onkeydown  onfocus  onblur
  • 29. JSON  JSON stands for JavaScript Object Notation.  JSON is a format for storing and transporting data.  JSON format is text only.  JSON is often used when data is sent from a server to a web page.  The JSON Format Evaluates to JavaScript Objects.
  • 30. JSON SYNTAX RULE  Data is in name/value pairs.  Data is separated by commas.  Curly braces hold objects.  Square brackets hold arrays.
  • 31. JSON DATA  JSON data is written as name/value pairs, just like JavaScript object properties.  A name/value pair consists of a field name (in double quotes), followed by a colon, followed by a value. "firstName":"John“ { "employees":[ {"firstName":“Steve”, "lastName":“Jobs"}, {"firstName":“Tim“, "lastName":“Cook"} ] }
  • 32. JSON OBJECT  JSON objects are written inside curly braces.  Just like in JavaScript, objects can contain multiple name/value pairs. {"firstName":"John", "lastName":"Doe"}
  • 33. JSON ARRAY  JSON arrays are written inside square brackets.  Just like in JavaScript, an array can contain objects. "employees":[ {"firstName":"John", "lastName":"Doe"}, {"firstName":"Anna", "lastName":"Smith"}, {"firstName":"Peter", "lastName":"Jones"} ]
  • 34. JSON PARSING  A common use of JSON is to read data from a web server, and display the data in a web page.  We can use the JavaScript built-in function JSON.parse() to convert the string into a JavaScript object. var obj = JSON.parse(text);