SlideShare a Scribd company logo
JAVASCRIPT ANALYSIS
GROUP NUMBER: 03
THE SCOPE
• JavaScript Objects
• JavaScript Functions
• JavaScript DataTypes
JavaScript Objects
INTRODUCTION TO JAVASCRIPT OBJECTS
• JavaScript is designed on a simple object-based paradigm. An object is a
collection of properties. In JavaScript almost everything is an object.
Here are some of the examples of JavaScript objects
• Numbers can be objects (or primitive data treated as objects)
• Strings can be objects (or primitive data treated as objects)
• Dates are always objects
• Math's are always objects
• Regular expressions are always objects
• Arrays are always objects
• Functions are always objects
• Objects are objects
Objective Overview
• Objects in JavaScript, just as in many other programming languages, can
be compared to objects in real life. (Example : Car/person )The concept of
objects in JavaScript can be understood with real life, tangible objects.
• EXAMPLE. A cup is an object, with properties. A cup has a color, a design,
weight, a material it is made of, etc.The same way, JavaScript objects can
have properties, which define their characteristics.
Further Explanations
• Basically you can see, Objects are variables too. But objects can
contain many values.The values are written as name: value pairs
(name and value separated by a colon)
• Example
• var person = { firstName:"Uchitha ", lastName:"Bandara", age:25, eyeColor:"blue"
};
Creating Objects in JavaScript
There are different ways to create new objects: but
• Define and create a single object, using an object literal.
• Define and create a single object, with the keyword new.
• Define an object constructor, and then create objects of the constructed type.
How to Use an Object Literal.
• This is the easiest way to create a JavaScript Object. Using an object literal, you both
define and create an object in one statement. An object literal is a list of name: value pairs
(like age:25) inside curly braces {}.
• Example
• var person = {firstName:"Uchitha", lastName:"Bandara", age:25, eyeColor:"blue"};
How to Use the JavaScript Keyword “new”
The following example also creates a new JavaScript object
with four properties:
Example
var person = new Object ();
person.firstName = "Uchitha ";
person.lastName = "Bandara";
person.age = 25;
person.eyeColor = "blue";
Using an Object Constructor
The examples above are limited in many situations.They only create a single object.
Sometimes we like to have an "object type" that can be used to create many objects of one
type.The standard way to create an "object type" is to use an object constructor function:
Example
function person(first, last, age, eye)
{
this.firstName = first;
this.lastName = last;
this.age = age;
this.eyeColor = eye;
}
var myFather = new person("John", "Doe", 50, "blue");
var myMother = new person("Sally", "Rally", 48, "green");
JavaScript Functions
A JavaScript function is a block of code designed to perform a particular task. A
JavaScript function is executed when "something" invokes it (calls it).You can
reuse code: Define the code once, and use it many times.You can use the same
code many times with different arguments, to produce different results
Syntax
A JavaScript function is defined with the function keyword, followed by a name, followed by
parentheses ()
Function names can contain letters, digits, underscores, and dollar signs (same rules as variables).
The parentheses may include parameter names separated by commas:
(parameter1, parameter2, ...)
The code to be executed, by the function, is placed inside curly brackets: { }
Function Invocation
The code inside the function will execute when "something"
invokes (calls) the function:
• When an event occurs (when a user clicks a button)
• When it is invoked (called) from JavaScript code
• Automatically (self invoked)
Function Return
When JavaScript reaches a return statement, the function will stop executing.
If the function was invoked from a statement, JavaScript will "return" to execute the code
after the invoking statement.
Functions often compute a return value.The return value is "returned" back to the "caller":
Functions Used asVariables
Example
We can use:
var text = "The temperature is " + toCelsius(77) + " Celsius";
Instead of:
var x = toCelsius(32);
var text = "The temperature is " + x+ " Celsius";
 JavaScript allows the same variable to contain different types of data
values.
 Primitive data types
– String : a sequence of alphanumeric characters
– Number: integer & floating-point numbers
– Boolean: logical values “true” or “false”
 Composite data types (or Complex data types)
– Object : a named collection of data
– Array : a sequence of values
 Special data types
– Null : an initial value is assigned
– Undefined: the variable has been created by not yet assigned a value
JavaScript Data Types :
String Data Type
Ex:
var crsName = “MIT“ ; // Using double quotes
var crsName = ‘MIT‘ ; // Using single quotes
var result = “ It's nice "; // Single quote inside double quotes
var result = “ It is called ‘B.Sc in MIT‘ "; // Single quotes inside double quotes
var result = ‘ It is called " B.Sc in MIT“ '; // Double quotes inside single quotes
 A string variable can store a sequence of alphanumeric characters,
spaces and special characters.
 String can also be enclosed in single quotation marks (‘) or in double
quotation marks (“).
 It is an important part of any programming language for doing arithmetic
calculations.
 JavaScript supports:
– Integers: A positive or negative number with no
decimal places.
 Ranged from –253 to 253
– Floating-point numbers: usually written in exponential
notation.
 3.1415…, 2.0e11
Number Data Type
<script language=“JavaScript”>
var integerVar = 100;
var floatingPointVar = 3.0e10;
// floating-point number 30000000000
document.write(integerVar);
document.write(floatingPointVar);
</script>
 The integer 100 and the number 30,000,000,000
will be appeared in the browser window.
 A Boolean value is a logical value of either true or false. (yes/no, on/off)
 Often used in decision making and data comparison.
 In JavaScript, we can use the words “true” and “false” directly to indicate
Boolean values.
 Booleans are often used in conditional testing.
 Ex:
var x = true;
var y = false;
Boolean Data Type
 An Array contains a set of data represented by a single variable name.
 Arrays in JavaScript are represented by the Array Object, we need to
“new Array()” to construct this object.
 The first element of the array is “Array[0]” until the last one Array[i-1].
Array :
<html>
<script language="JavaScript">
Car = new Array(3);
Car[0] = "Ford";
Car[1] = "Toyota";
Car[2] = "Honda";
document.write(Car[0] + "<br>");
document.write(Car[1] + "<br>");
document.write(Car[2] + "<br>");
</script>
</html>
 JavaScript objects are written with curly braces.
 Object properties are written as name:value pairs, separated by commas.
 An object is a thing, anything, just as things in the real world.
– E.g. {cars, dogs, money, books, … }
 All objects have properties.
– Cars have wheels.
– Browser has a name and version number.
var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};
Object :
 In JavaScript, a variable without a value, has the value undefined.
 An “undefined” value is returned when you attempt to use a variable that has
not been defined or you have declared but you forgot to provide with a value.
 var person; //Value is undefined, type is undefined
 Null refers to “nothing”
 We can declare and define a variable as “null” if you want absolutely nothing
in it, but you just don’t want it to be “undefined”.
 var person = null; //Value is null, but type is still an object
Undefined & Null
Ad

More Related Content

What's hot (20)

JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
Doug Jones
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
Walid Ashraf
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Rangana Sampath
 
JavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayJavaScript in Object-Oriented Way
JavaScript in Object-Oriented Way
Chamnap Chhorn
 
Shapeless- Generic programming for Scala
Shapeless- Generic programming for ScalaShapeless- Generic programming for Scala
Shapeless- Generic programming for Scala
Knoldus Inc.
 
05 ruby classes
05 ruby classes05 ruby classes
05 ruby classes
Walker Maidana
 
JavaScript Data Types
JavaScript Data TypesJavaScript Data Types
JavaScript Data Types
Charles Russell
 
Ajax and JavaScript Bootcamp
Ajax and JavaScript BootcampAjax and JavaScript Bootcamp
Ajax and JavaScript Bootcamp
AndreCharland
 
Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
Priya Goyal
 
Javascript 101
Javascript 101Javascript 101
Javascript 101
Shlomi Komemi
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
Bala Narayanan
 
Introduction to JavaScript Basics.
Introduction to JavaScript Basics.Introduction to JavaScript Basics.
Introduction to JavaScript Basics.
Hassan Ahmed Baig - Web Developer
 
Prototype Utility Methods(1)
Prototype Utility Methods(1)Prototype Utility Methods(1)
Prototype Utility Methods(1)
mussawir20
 
Basic JavaScript Tutorial
Basic JavaScript TutorialBasic JavaScript Tutorial
Basic JavaScript Tutorial
DHTMLExtreme
 
Javascript
JavascriptJavascript
Javascript
mussawir20
 
Javascript functions
Javascript functionsJavascript functions
Javascript functions
Alaref Abushaala
 
Java script basics
Java script basicsJava script basics
Java script basics
Shrivardhan Limbkar
 
JavaScript objects and functions
JavaScript objects and functionsJavaScript objects and functions
JavaScript objects and functions
Victor Verhaagen
 
Javascript
JavascriptJavascript
Javascript
Aditya Gaur
 
JavaScript - Chapter 4 - Types and Statements
 JavaScript - Chapter 4 - Types and Statements JavaScript - Chapter 4 - Types and Statements
JavaScript - Chapter 4 - Types and Statements
WebStackAcademy
 
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
Doug Jones
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
Walid Ashraf
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Rangana Sampath
 
JavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayJavaScript in Object-Oriented Way
JavaScript in Object-Oriented Way
Chamnap Chhorn
 
Shapeless- Generic programming for Scala
Shapeless- Generic programming for ScalaShapeless- Generic programming for Scala
Shapeless- Generic programming for Scala
Knoldus Inc.
 
Ajax and JavaScript Bootcamp
Ajax and JavaScript BootcampAjax and JavaScript Bootcamp
Ajax and JavaScript Bootcamp
AndreCharland
 
Prototype Utility Methods(1)
Prototype Utility Methods(1)Prototype Utility Methods(1)
Prototype Utility Methods(1)
mussawir20
 
Basic JavaScript Tutorial
Basic JavaScript TutorialBasic JavaScript Tutorial
Basic JavaScript Tutorial
DHTMLExtreme
 
JavaScript objects and functions
JavaScript objects and functionsJavaScript objects and functions
JavaScript objects and functions
Victor Verhaagen
 
JavaScript - Chapter 4 - Types and Statements
 JavaScript - Chapter 4 - Types and Statements JavaScript - Chapter 4 - Types and Statements
JavaScript - Chapter 4 - Types and Statements
WebStackAcademy
 

Similar to Javascript analysis (20)

JavaScript Workshop
JavaScript WorkshopJavaScript Workshop
JavaScript Workshop
Pamela Fox
 
Javascript
JavascriptJavascript
Javascript
20261A05H0SRIKAKULAS
 
Presentation JavaScript Introduction Data Types Variables Control Structure
Presentation JavaScript Introduction  Data Types Variables Control StructurePresentation JavaScript Introduction  Data Types Variables Control Structure
Presentation JavaScript Introduction Data Types Variables Control Structure
SripathiRavi1
 
Java script
Java scriptJava script
Java script
Sukrit Gupta
 
chap04.ppt
chap04.pptchap04.ppt
chap04.ppt
Varsha Uchagaonkar
 
Introduction to JavaScript presentations
Introduction to JavaScript presentationsIntroduction to JavaScript presentations
Introduction to JavaScript presentations
XaiMaeChanelleSopsop
 
JavaScript ppt for introduction of javascripta
JavaScript ppt for introduction of javascriptaJavaScript ppt for introduction of javascripta
JavaScript ppt for introduction of javascripta
nehatanveer5765
 
Java Script
Java ScriptJava Script
Java Script
Sarvan15
 
Java Script
Java ScriptJava Script
Java Script
Sarvan15
 
Java script
 Java script Java script
Java script
bosybosy
 
Web designing unit 4
Web designing unit 4Web designing unit 4
Web designing unit 4
Dr. SURBHI SAROHA
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
Sehwan Noh
 
Js ppt
Js pptJs ppt
Js ppt
Rakhi Thota
 
Web Host_G4.pptx
Web Host_G4.pptxWeb Host_G4.pptx
Web Host_G4.pptx
RNithish1
 
Java script final presentation
Java script final presentationJava script final presentation
Java script final presentation
Adhoura Academy
 
Java script
Java scriptJava script
Java script
Jay Patel
 
javascript client side scripting la.pptx
javascript client side scripting la.pptxjavascript client side scripting la.pptx
javascript client side scripting la.pptx
lekhacce
 
Powerpoint about JavaScript presentation
Powerpoint about JavaScript presentationPowerpoint about JavaScript presentation
Powerpoint about JavaScript presentation
XaiMaeChanelleSopsop
 
JavaScript.pptx
JavaScript.pptxJavaScript.pptx
JavaScript.pptx
KennyPratheepKumar
 
Lecture 4- Javascript Function presentation
Lecture 4- Javascript Function presentationLecture 4- Javascript Function presentation
Lecture 4- Javascript Function presentation
GomathiUdai
 
JavaScript Workshop
JavaScript WorkshopJavaScript Workshop
JavaScript Workshop
Pamela Fox
 
Presentation JavaScript Introduction Data Types Variables Control Structure
Presentation JavaScript Introduction  Data Types Variables Control StructurePresentation JavaScript Introduction  Data Types Variables Control Structure
Presentation JavaScript Introduction Data Types Variables Control Structure
SripathiRavi1
 
Introduction to JavaScript presentations
Introduction to JavaScript presentationsIntroduction to JavaScript presentations
Introduction to JavaScript presentations
XaiMaeChanelleSopsop
 
JavaScript ppt for introduction of javascripta
JavaScript ppt for introduction of javascriptaJavaScript ppt for introduction of javascripta
JavaScript ppt for introduction of javascripta
nehatanveer5765
 
Java Script
Java ScriptJava Script
Java Script
Sarvan15
 
Java Script
Java ScriptJava Script
Java Script
Sarvan15
 
Java script
 Java script Java script
Java script
bosybosy
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
Sehwan Noh
 
Web Host_G4.pptx
Web Host_G4.pptxWeb Host_G4.pptx
Web Host_G4.pptx
RNithish1
 
Java script final presentation
Java script final presentationJava script final presentation
Java script final presentation
Adhoura Academy
 
javascript client side scripting la.pptx
javascript client side scripting la.pptxjavascript client side scripting la.pptx
javascript client side scripting la.pptx
lekhacce
 
Powerpoint about JavaScript presentation
Powerpoint about JavaScript presentationPowerpoint about JavaScript presentation
Powerpoint about JavaScript presentation
XaiMaeChanelleSopsop
 
Lecture 4- Javascript Function presentation
Lecture 4- Javascript Function presentationLecture 4- Javascript Function presentation
Lecture 4- Javascript Function presentation
GomathiUdai
 
Ad

Recently uploaded (20)

How to Manage Manual Reordering Rule in Odoo 18 Inventory
How to Manage Manual Reordering Rule in Odoo 18 InventoryHow to Manage Manual Reordering Rule in Odoo 18 Inventory
How to Manage Manual Reordering Rule in Odoo 18 Inventory
Celine George
 
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdfAntepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Dr H.K. Cheema
 
114P_English.pdf114P_English.pdf114P_English.pdf
114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf
114P_English.pdf114P_English.pdf114P_English.pdf
paulinelee52
 
libbys peer assesment.docx..............
libbys peer assesment.docx..............libbys peer assesment.docx..............
libbys peer assesment.docx..............
19lburrell
 
Aerospace Engineering Homework Help Guide – Expert Support for Academic Success
Aerospace Engineering Homework Help Guide – Expert Support for Academic SuccessAerospace Engineering Homework Help Guide – Expert Support for Academic Success
Aerospace Engineering Homework Help Guide – Expert Support for Academic Success
online college homework help
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024
INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024
INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024
Quiz Club of PSG College of Arts & Science
 
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFAMCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
PUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for HealthPUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for Health
JonathanHallett4
 
GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdf
GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdfGENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdf
GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdf
Quiz Club of PSG College of Arts & Science
 
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
businessweekghana
 
Module_2_Types_and_Approaches_of_Research (2).pptx
Module_2_Types_and_Approaches_of_Research (2).pptxModule_2_Types_and_Approaches_of_Research (2).pptx
Module_2_Types_and_Approaches_of_Research (2).pptx
drroxannekemp
 
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit..."Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
AlionaBujoreanu
 
IPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdf
IPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdfIPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdf
IPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdf
Quiz Club of PSG College of Arts & Science
 
PUBH1000 Slides - Module 12: Advocacy for Health
PUBH1000 Slides - Module 12: Advocacy for HealthPUBH1000 Slides - Module 12: Advocacy for Health
PUBH1000 Slides - Module 12: Advocacy for Health
JonathanHallett4
 
How to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 WebsiteHow to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 Website
Celine George
 
Dastur_ul_Amal under Jahangir Key Features.pptx
Dastur_ul_Amal under Jahangir Key Features.pptxDastur_ul_Amal under Jahangir Key Features.pptx
Dastur_ul_Amal under Jahangir Key Features.pptx
omorfaruqkazi
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
IMPACT_OF_SOCIAL-MEDIA- AMONG- TEENAGERS
IMPACT_OF_SOCIAL-MEDIA- AMONG- TEENAGERSIMPACT_OF_SOCIAL-MEDIA- AMONG- TEENAGERS
IMPACT_OF_SOCIAL-MEDIA- AMONG- TEENAGERS
rajaselviazhagiri1
 
How to Manage Manual Reordering Rule in Odoo 18 Inventory
How to Manage Manual Reordering Rule in Odoo 18 InventoryHow to Manage Manual Reordering Rule in Odoo 18 Inventory
How to Manage Manual Reordering Rule in Odoo 18 Inventory
Celine George
 
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdfAntepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Dr H.K. Cheema
 
114P_English.pdf114P_English.pdf114P_English.pdf
114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf
114P_English.pdf114P_English.pdf114P_English.pdf
paulinelee52
 
libbys peer assesment.docx..............
libbys peer assesment.docx..............libbys peer assesment.docx..............
libbys peer assesment.docx..............
19lburrell
 
Aerospace Engineering Homework Help Guide – Expert Support for Academic Success
Aerospace Engineering Homework Help Guide – Expert Support for Academic SuccessAerospace Engineering Homework Help Guide – Expert Support for Academic Success
Aerospace Engineering Homework Help Guide – Expert Support for Academic Success
online college homework help
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFAMCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
PUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for HealthPUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for Health
JonathanHallett4
 
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
businessweekghana
 
Module_2_Types_and_Approaches_of_Research (2).pptx
Module_2_Types_and_Approaches_of_Research (2).pptxModule_2_Types_and_Approaches_of_Research (2).pptx
Module_2_Types_and_Approaches_of_Research (2).pptx
drroxannekemp
 
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit..."Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
AlionaBujoreanu
 
PUBH1000 Slides - Module 12: Advocacy for Health
PUBH1000 Slides - Module 12: Advocacy for HealthPUBH1000 Slides - Module 12: Advocacy for Health
PUBH1000 Slides - Module 12: Advocacy for Health
JonathanHallett4
 
How to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 WebsiteHow to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 Website
Celine George
 
Dastur_ul_Amal under Jahangir Key Features.pptx
Dastur_ul_Amal under Jahangir Key Features.pptxDastur_ul_Amal under Jahangir Key Features.pptx
Dastur_ul_Amal under Jahangir Key Features.pptx
omorfaruqkazi
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
IMPACT_OF_SOCIAL-MEDIA- AMONG- TEENAGERS
IMPACT_OF_SOCIAL-MEDIA- AMONG- TEENAGERSIMPACT_OF_SOCIAL-MEDIA- AMONG- TEENAGERS
IMPACT_OF_SOCIAL-MEDIA- AMONG- TEENAGERS
rajaselviazhagiri1
 
Ad

Javascript analysis

  • 2. THE SCOPE • JavaScript Objects • JavaScript Functions • JavaScript DataTypes
  • 3. JavaScript Objects INTRODUCTION TO JAVASCRIPT OBJECTS • JavaScript is designed on a simple object-based paradigm. An object is a collection of properties. In JavaScript almost everything is an object. Here are some of the examples of JavaScript objects • Numbers can be objects (or primitive data treated as objects) • Strings can be objects (or primitive data treated as objects) • Dates are always objects • Math's are always objects • Regular expressions are always objects • Arrays are always objects • Functions are always objects • Objects are objects
  • 4. Objective Overview • Objects in JavaScript, just as in many other programming languages, can be compared to objects in real life. (Example : Car/person )The concept of objects in JavaScript can be understood with real life, tangible objects. • EXAMPLE. A cup is an object, with properties. A cup has a color, a design, weight, a material it is made of, etc.The same way, JavaScript objects can have properties, which define their characteristics.
  • 5. Further Explanations • Basically you can see, Objects are variables too. But objects can contain many values.The values are written as name: value pairs (name and value separated by a colon) • Example • var person = { firstName:"Uchitha ", lastName:"Bandara", age:25, eyeColor:"blue" };
  • 6. Creating Objects in JavaScript There are different ways to create new objects: but • Define and create a single object, using an object literal. • Define and create a single object, with the keyword new. • Define an object constructor, and then create objects of the constructed type.
  • 7. How to Use an Object Literal. • This is the easiest way to create a JavaScript Object. Using an object literal, you both define and create an object in one statement. An object literal is a list of name: value pairs (like age:25) inside curly braces {}. • Example • var person = {firstName:"Uchitha", lastName:"Bandara", age:25, eyeColor:"blue"};
  • 8. How to Use the JavaScript Keyword “new” The following example also creates a new JavaScript object with four properties: Example var person = new Object (); person.firstName = "Uchitha "; person.lastName = "Bandara"; person.age = 25; person.eyeColor = "blue";
  • 9. Using an Object Constructor The examples above are limited in many situations.They only create a single object. Sometimes we like to have an "object type" that can be used to create many objects of one type.The standard way to create an "object type" is to use an object constructor function: Example function person(first, last, age, eye) { this.firstName = first; this.lastName = last; this.age = age; this.eyeColor = eye; } var myFather = new person("John", "Doe", 50, "blue"); var myMother = new person("Sally", "Rally", 48, "green");
  • 10. JavaScript Functions A JavaScript function is a block of code designed to perform a particular task. A JavaScript function is executed when "something" invokes it (calls it).You can reuse code: Define the code once, and use it many times.You can use the same code many times with different arguments, to produce different results Syntax A JavaScript function is defined with the function keyword, followed by a name, followed by parentheses () Function names can contain letters, digits, underscores, and dollar signs (same rules as variables). The parentheses may include parameter names separated by commas: (parameter1, parameter2, ...) The code to be executed, by the function, is placed inside curly brackets: { }
  • 11. Function Invocation The code inside the function will execute when "something" invokes (calls) the function: • When an event occurs (when a user clicks a button) • When it is invoked (called) from JavaScript code • Automatically (self invoked)
  • 12. Function Return When JavaScript reaches a return statement, the function will stop executing. If the function was invoked from a statement, JavaScript will "return" to execute the code after the invoking statement. Functions often compute a return value.The return value is "returned" back to the "caller":
  • 13. Functions Used asVariables Example We can use: var text = "The temperature is " + toCelsius(77) + " Celsius"; Instead of: var x = toCelsius(32); var text = "The temperature is " + x+ " Celsius";
  • 14.  JavaScript allows the same variable to contain different types of data values.  Primitive data types – String : a sequence of alphanumeric characters – Number: integer & floating-point numbers – Boolean: logical values “true” or “false”  Composite data types (or Complex data types) – Object : a named collection of data – Array : a sequence of values  Special data types – Null : an initial value is assigned – Undefined: the variable has been created by not yet assigned a value JavaScript Data Types :
  • 15. String Data Type Ex: var crsName = “MIT“ ; // Using double quotes var crsName = ‘MIT‘ ; // Using single quotes var result = “ It's nice "; // Single quote inside double quotes var result = “ It is called ‘B.Sc in MIT‘ "; // Single quotes inside double quotes var result = ‘ It is called " B.Sc in MIT“ '; // Double quotes inside single quotes  A string variable can store a sequence of alphanumeric characters, spaces and special characters.  String can also be enclosed in single quotation marks (‘) or in double quotation marks (“).
  • 16.  It is an important part of any programming language for doing arithmetic calculations.  JavaScript supports: – Integers: A positive or negative number with no decimal places.  Ranged from –253 to 253 – Floating-point numbers: usually written in exponential notation.  3.1415…, 2.0e11 Number Data Type
  • 17. <script language=“JavaScript”> var integerVar = 100; var floatingPointVar = 3.0e10; // floating-point number 30000000000 document.write(integerVar); document.write(floatingPointVar); </script>  The integer 100 and the number 30,000,000,000 will be appeared in the browser window.
  • 18.  A Boolean value is a logical value of either true or false. (yes/no, on/off)  Often used in decision making and data comparison.  In JavaScript, we can use the words “true” and “false” directly to indicate Boolean values.  Booleans are often used in conditional testing.  Ex: var x = true; var y = false; Boolean Data Type
  • 19.  An Array contains a set of data represented by a single variable name.  Arrays in JavaScript are represented by the Array Object, we need to “new Array()” to construct this object.  The first element of the array is “Array[0]” until the last one Array[i-1]. Array :
  • 20. <html> <script language="JavaScript"> Car = new Array(3); Car[0] = "Ford"; Car[1] = "Toyota"; Car[2] = "Honda"; document.write(Car[0] + "<br>"); document.write(Car[1] + "<br>"); document.write(Car[2] + "<br>"); </script> </html>
  • 21.  JavaScript objects are written with curly braces.  Object properties are written as name:value pairs, separated by commas.  An object is a thing, anything, just as things in the real world. – E.g. {cars, dogs, money, books, … }  All objects have properties. – Cars have wheels. – Browser has a name and version number. var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"}; Object :
  • 22.  In JavaScript, a variable without a value, has the value undefined.  An “undefined” value is returned when you attempt to use a variable that has not been defined or you have declared but you forgot to provide with a value.  var person; //Value is undefined, type is undefined  Null refers to “nothing”  We can declare and define a variable as “null” if you want absolutely nothing in it, but you just don’t want it to be “undefined”.  var person = null; //Value is null, but type is still an object Undefined & Null
  翻译: