SlideShare a Scribd company logo
Mohammed Irfan
 JavaScript is a stripped down version of Java 
 JavaScript does not exist outside browsers 
 JavaScript is inconsistent and buggy 
 JavaScript is not object-orientated
 Birth of Mocha, then rename to LiveScript 
 Netscape and Sun collaboration for Java in 
browsers; 
 LiveScript gets renamed to JavaScript 
 IE team reverse engineers JavaScript to JScript 
 Browser war begins 
 Standardization of JavaScript at ECMA; 
ECMAScript becomes the official name 
 Rise of Ajax 
 JavaScript libraries emerge 
 ECMAScript 5
 Semicolon insertion 
 typeof and instanceof 
 with and eval 
 == and != 
 new
 Loose Typing 
 Dynamic Objects 
 Object / Array Literals 
 Functions / Lambdas
 Self 
 prototypal inheritance 
 dynamic objects 
 Scheme 
 lambda 
 loose typing 
 Java 
 syntax 
 conventions 
 Perl 
 regular expressions
 Numbers 
 Strings 
 Booleans 
 Objects 
 Functions
 Number 
 String 
 Boolean 
 Object 
 Function 
 Array 
 Date 
 RegExp 
 Null 
 Undefined
 Only one number type 
 No integers 
 64-bit floating point IEEE-754 (aka “Double”) 
 Numbers are Objects
(a + b) + c === a + (b + c) 
Produces false for some values of a, b, c. 
Integers under 9007199254740992 (9 
quadrillion) are ok. 
9007199254740992 === 9007199254740992 + 1
a = 0.1; 
b = 0.2; 
c = 0.3; 
(a + b) + c === a + (b + c) 
> false
 Special number: Not a Number 
 Result of undefined or erroneous operations 
 Toxic: any arithmetic operation with NaN as an 
input will have NaN as a result 
 NaN is not equal to anything, including NaN 
 NaN === NaN is false 
 NaN !== NaN is true
 A sequence of 0 or more 16-bit Unicode 
characters 
 No separate character type 
 Characters are represented as strings with length 
of 1 
 Strings are immutable 
 Similar strings are equal ( === ) 
 String literals can use single or double quotes with 
 escapement. 
 Strings are Objects
> "hello".charAt(0) 
h 
> "hello, world".replace("hello", 
"goodbye") 
goodbye, world 
> "hello".toUpperCase() 
HELLO
 null = deliberately no value 
 undefined = no value assigned yet 
 Variables declared but not initialized 
 Object/array members that don't exist
 Boolean type: true or false 
 Everything else is “truthy” or “falsy” 
 0, "", NaN, null and undefined are falsy 
 Everything else is truthy 
 Boolean operations: &&, || and !
 Simple key-value pairs, like: 
 HashMaps in Java 
 Associative arrays in PHP 
 Key is a string; value can be anything 
 Key is unique within an object
var obj = new Object(); 
Or 
var obj = {}; 
These are semantically equivalent; the second is 
called object literal syntax and is more 
convenient.
obj.name = "My Name" 
var name = obj.name; 
Or 
obj["name"] = "My Name"; 
var name = obj["name"]; 
Semantically equivalent; the second uses strings 
so can be decided at run-time (and can be 
used for reserved words)
var obj = { 
name: "Carrot", 
"for": "Max", 
details: { 
color: "orange", 
size: 12 
} 
} 
> obj.details.color 
Orange 
> obj["details"]["size"] 
12
Iterate over the keys of an object: 
var obj = { 'name': 'Simon', 'age': 25 
}; 
for (var attr in obj) { 
alert (attr + ' = ' + obj[attr]); 
} 
Not to be used with Arrays
 A special type of object: Keys are whole numbers, 
not strings. 
 Use [] syntax, just like objects 
> var a = new Array(); 
> a[0] = "dog"; 
> a[1] = "cat"; 
> a[2] = "hen“; 
> a.length 
3 
 No such thing as “Associative Arrays”
More convenient notation: 
> var a = ["dog", "cat", "hen"]; 
> a.length 
3 
var a = [10, "dog", false, "elephant"]; 
(you can have mixed content in arrays)
> var a = ["dog", "cat", "hen"]; 
> a[100] = "fox"; 
> a.length 
101 
typeof a[90] == 'undefined' 
array.length is always one more than the 
highest index 
The safest way to append new items is: 
a[a.length] = item;
 New variables are declared using the var 
keyword: 
 var a; 
 var name = "my name"; 
 If you declare a variable without assigning it to 
anything, its value is undefined. 
 If you forget the var, you get a global variable. 
 Never, ever do this – not even if you mean it.
 Global variables are visible everywhere 
 Blocks do not have scope 
 Variables defined inside blocks are hoisted to 
the top and are visible outside the block 
 Functions have scope 
 Variables defined inside function are visible 
throughout the function and its inner functions
var a; 
//... 
function F() { 
var b; 
//... 
function N() { 
var c; 
//... 
}; 
}
 Three different purposes of functions: 
 as sub-routine / procedure 
 as lambda (a block of executable code) 
 as object constructor 
 Functions are first-class: 
 can be assigned to a variable 
 can be passed as argument to any function 
 can be returned from any function 
 can be a member of any object 
 can be created at run time 
 Functions can be created inside another function
function add(x, y) { 
var total = x + y; 
return total; 
} 
var add = function(x, y) { 
var total = x + y; 
return total; 
}; 
var add = function some_func(x, y) { 
var total = x + y; 
return total; 
}; 
If nothing is explicitly returned, return value is undefined
 Parameters: “They’re more like... Guidelines” 
 Missing parameters are treated as undefined: 
> add() 
NaN // addition on undefined 
 You can pass in more arguments than 
expected: 
> add(2, 3, 4) 
5 // added the first two; 4 was ignored
The arguments special variable provides access to arguments as an 
array-like object 
function add() { 
var sum = 0; 
for (var i = 0, j = arguments.length; i < j; i++) { 
sum += arguments[i]; 
} 
return sum; 
} 
> add(2, 3, 4, 5) 
14
$('#some-id').click(function(evt) { 
// do something on click event 
};
var add = function(x) { 
return function(y) { 
return x + y; 
}; 
};
function Person(name) { 
this.name = name; 
this.getName = function() { 
return this.name; 
}; 
} 
var person = new Person("some one"); 
person.getName(); 
> some one

More Related Content

What's hot

JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript Objects
Reem Alattas
 
Haskell for data science
Haskell for data scienceHaskell for data science
Haskell for data science
John Cant
 
Functional programming in JavaScript
Functional programming in JavaScriptFunctional programming in JavaScript
Functional programming in JavaScript
Joseph Smith
 
Functional Programming in Javascript - IL Tech Talks week
Functional Programming in Javascript - IL Tech Talks weekFunctional Programming in Javascript - IL Tech Talks week
Functional Programming in Javascript - IL Tech Talks week
yoavrubin
 
Javascript arrays
Javascript arraysJavascript arrays
Javascript arrays
Hassan Dar
 
Scala Back to Basics: Type Classes
Scala Back to Basics: Type ClassesScala Back to Basics: Type Classes
Scala Back to Basics: Type Classes
Tomer Gabel
 
Reasoning about laziness
Reasoning about lazinessReasoning about laziness
Reasoning about lazinessJohan Tibell
 
Introduction to Functional Programming in JavaScript
Introduction to Functional Programming in JavaScriptIntroduction to Functional Programming in JavaScript
Introduction to Functional Programming in JavaScript
tmont
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)
Jonas Bonér
 
Library functions in c++
Library functions in c++Library functions in c++
Library functions in c++
Neeru Mittal
 
Python programming: Anonymous functions, String operations
Python programming: Anonymous functions, String operationsPython programming: Anonymous functions, String operations
Python programming: Anonymous functions, String operations
Megha V
 
Programming in Scala: Notes
Programming in Scala: NotesProgramming in Scala: Notes
Programming in Scala: Notes
Roberto Casadei
 
Functional Programming with JavaScript
Functional Programming with JavaScriptFunctional Programming with JavaScript
Functional Programming with JavaScript
WebF
 
Introducing Assignment invalidates the Substitution Model of Evaluation and v...
Introducing Assignment invalidates the Substitution Model of Evaluation and v...Introducing Assignment invalidates the Substitution Model of Evaluation and v...
Introducing Assignment invalidates the Substitution Model of Evaluation and v...
Philip Schwarz
 
The Functional Programming Triad of Folding, Scanning and Iteration - a first...
The Functional Programming Triad of Folding, Scanning and Iteration - a first...The Functional Programming Triad of Folding, Scanning and Iteration - a first...
The Functional Programming Triad of Folding, Scanning and Iteration - a first...
Philip Schwarz
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance HaskellJohan Tibell
 
Why Haskell
Why HaskellWhy Haskell
Why Haskell
Susan Potter
 
Joy of scala
Joy of scalaJoy of scala
Joy of scala
Maxim Novak
 
Algorithm and Programming (Array)
Algorithm and Programming (Array)Algorithm and Programming (Array)
Algorithm and Programming (Array)
Adam Mukharil Bachtiar
 
Functional Programming by Examples using Haskell
Functional Programming by Examples using HaskellFunctional Programming by Examples using Haskell
Functional Programming by Examples using Haskell
goncharenko
 

What's hot (20)

JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript Objects
 
Haskell for data science
Haskell for data scienceHaskell for data science
Haskell for data science
 
Functional programming in JavaScript
Functional programming in JavaScriptFunctional programming in JavaScript
Functional programming in JavaScript
 
Functional Programming in Javascript - IL Tech Talks week
Functional Programming in Javascript - IL Tech Talks weekFunctional Programming in Javascript - IL Tech Talks week
Functional Programming in Javascript - IL Tech Talks week
 
Javascript arrays
Javascript arraysJavascript arrays
Javascript arrays
 
Scala Back to Basics: Type Classes
Scala Back to Basics: Type ClassesScala Back to Basics: Type Classes
Scala Back to Basics: Type Classes
 
Reasoning about laziness
Reasoning about lazinessReasoning about laziness
Reasoning about laziness
 
Introduction to Functional Programming in JavaScript
Introduction to Functional Programming in JavaScriptIntroduction to Functional Programming in JavaScript
Introduction to Functional Programming in JavaScript
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)
 
Library functions in c++
Library functions in c++Library functions in c++
Library functions in c++
 
Python programming: Anonymous functions, String operations
Python programming: Anonymous functions, String operationsPython programming: Anonymous functions, String operations
Python programming: Anonymous functions, String operations
 
Programming in Scala: Notes
Programming in Scala: NotesProgramming in Scala: Notes
Programming in Scala: Notes
 
Functional Programming with JavaScript
Functional Programming with JavaScriptFunctional Programming with JavaScript
Functional Programming with JavaScript
 
Introducing Assignment invalidates the Substitution Model of Evaluation and v...
Introducing Assignment invalidates the Substitution Model of Evaluation and v...Introducing Assignment invalidates the Substitution Model of Evaluation and v...
Introducing Assignment invalidates the Substitution Model of Evaluation and v...
 
The Functional Programming Triad of Folding, Scanning and Iteration - a first...
The Functional Programming Triad of Folding, Scanning and Iteration - a first...The Functional Programming Triad of Folding, Scanning and Iteration - a first...
The Functional Programming Triad of Folding, Scanning and Iteration - a first...
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance Haskell
 
Why Haskell
Why HaskellWhy Haskell
Why Haskell
 
Joy of scala
Joy of scalaJoy of scala
Joy of scala
 
Algorithm and Programming (Array)
Algorithm and Programming (Array)Algorithm and Programming (Array)
Algorithm and Programming (Array)
 
Functional Programming by Examples using Haskell
Functional Programming by Examples using HaskellFunctional Programming by Examples using Haskell
Functional Programming by Examples using Haskell
 

Similar to The JavaScript Programming Language

An introduction to javascript
An introduction to javascriptAn introduction to javascript
An introduction to javascript
MD Sayem Ahmed
 
Powerful JavaScript Tips and Best Practices
Powerful JavaScript Tips and Best PracticesPowerful JavaScript Tips and Best Practices
Powerful JavaScript Tips and Best Practices
Dragos Ionita
 
Basics of Javascript
Basics of JavascriptBasics of Javascript
Basics of Javascript
Universe41
 
fundamentals of JavaScript for students.ppt
fundamentals of JavaScript for students.pptfundamentals of JavaScript for students.ppt
fundamentals of JavaScript for students.ppt
dejen6
 
JavaScript(Es5) Interview Questions & Answers
JavaScript(Es5)  Interview Questions & AnswersJavaScript(Es5)  Interview Questions & Answers
JavaScript(Es5) Interview Questions & Answers
Ratnala Charan kumar
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
Bui Kiet
 
Java script advance-auroskills (2)
Java script advance-auroskills (2)Java script advance-auroskills (2)
Java script advance-auroskills (2)
BoneyGawande
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypesVarun C M
 
Javascript 101
Javascript 101Javascript 101
Javascript 101
Shlomi Komemi
 
JavaScript Basics - GameCraft Training
JavaScript Basics - GameCraft TrainingJavaScript Basics - GameCraft Training
JavaScript Basics - GameCraft Training
Radoslav Georgiev
 
Ajax and JavaScript Bootcamp
Ajax and JavaScript BootcampAjax and JavaScript Bootcamp
Ajax and JavaScript Bootcamp
AndreCharland
 
25-functions.ppt
25-functions.ppt25-functions.ppt
25-functions.ppt
JyothiAmpally
 
ES6 General Introduction
ES6 General IntroductionES6 General Introduction
ES6 General IntroductionThomas Johnston
 
ScalaLanguage_ch_4_5.pptx
ScalaLanguage_ch_4_5.pptxScalaLanguage_ch_4_5.pptx
ScalaLanguage_ch_4_5.pptx
jkapardhi
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
Julie Iskander
 
Java Script Introduction
Java Script IntroductionJava Script Introduction
Java Script Introduction
jason hu 金良胡
 
Scala in a nutshell by venkat
Scala in a nutshell by venkatScala in a nutshell by venkat
Scala in a nutshell by venkat
Venkateswaran Kandasamy
 
JavaScript.pptx
JavaScript.pptxJavaScript.pptx
JavaScript.pptx
Govardhan Bhavani
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
Manvendra Singh
 

Similar to The JavaScript Programming Language (20)

An introduction to javascript
An introduction to javascriptAn introduction to javascript
An introduction to javascript
 
Powerful JavaScript Tips and Best Practices
Powerful JavaScript Tips and Best PracticesPowerful JavaScript Tips and Best Practices
Powerful JavaScript Tips and Best Practices
 
Basics of Javascript
Basics of JavascriptBasics of Javascript
Basics of Javascript
 
fundamentals of JavaScript for students.ppt
fundamentals of JavaScript for students.pptfundamentals of JavaScript for students.ppt
fundamentals of JavaScript for students.ppt
 
JavaScript(Es5) Interview Questions & Answers
JavaScript(Es5)  Interview Questions & AnswersJavaScript(Es5)  Interview Questions & Answers
JavaScript(Es5) Interview Questions & Answers
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
 
Java script advance-auroskills (2)
Java script advance-auroskills (2)Java script advance-auroskills (2)
Java script advance-auroskills (2)
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 
Javascript 101
Javascript 101Javascript 101
Javascript 101
 
JavaScript Basics - GameCraft Training
JavaScript Basics - GameCraft TrainingJavaScript Basics - GameCraft Training
JavaScript Basics - GameCraft Training
 
Ajax and JavaScript Bootcamp
Ajax and JavaScript BootcampAjax and JavaScript Bootcamp
Ajax and JavaScript Bootcamp
 
25-functions.ppt
25-functions.ppt25-functions.ppt
25-functions.ppt
 
ES6 General Introduction
ES6 General IntroductionES6 General Introduction
ES6 General Introduction
 
ScalaLanguage_ch_4_5.pptx
ScalaLanguage_ch_4_5.pptxScalaLanguage_ch_4_5.pptx
ScalaLanguage_ch_4_5.pptx
 
Scala for curious
Scala for curiousScala for curious
Scala for curious
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
 
Java Script Introduction
Java Script IntroductionJava Script Introduction
Java Script Introduction
 
Scala in a nutshell by venkat
Scala in a nutshell by venkatScala in a nutshell by venkat
Scala in a nutshell by venkat
 
JavaScript.pptx
JavaScript.pptxJavaScript.pptx
JavaScript.pptx
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
 

Recently uploaded

How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
varshanayak241
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
Sharepoint Designs
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
KrzysztofKkol1
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
Jelle | Nordend
 

Recently uploaded (20)

How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 

The JavaScript Programming Language

  • 2.  JavaScript is a stripped down version of Java  JavaScript does not exist outside browsers  JavaScript is inconsistent and buggy  JavaScript is not object-orientated
  • 3.  Birth of Mocha, then rename to LiveScript  Netscape and Sun collaboration for Java in browsers;  LiveScript gets renamed to JavaScript  IE team reverse engineers JavaScript to JScript  Browser war begins  Standardization of JavaScript at ECMA; ECMAScript becomes the official name  Rise of Ajax  JavaScript libraries emerge  ECMAScript 5
  • 4.  Semicolon insertion  typeof and instanceof  with and eval  == and !=  new
  • 5.  Loose Typing  Dynamic Objects  Object / Array Literals  Functions / Lambdas
  • 6.  Self  prototypal inheritance  dynamic objects  Scheme  lambda  loose typing  Java  syntax  conventions  Perl  regular expressions
  • 7.  Numbers  Strings  Booleans  Objects  Functions
  • 8.  Number  String  Boolean  Object  Function  Array  Date  RegExp  Null  Undefined
  • 9.  Only one number type  No integers  64-bit floating point IEEE-754 (aka “Double”)  Numbers are Objects
  • 10. (a + b) + c === a + (b + c) Produces false for some values of a, b, c. Integers under 9007199254740992 (9 quadrillion) are ok. 9007199254740992 === 9007199254740992 + 1
  • 11. a = 0.1; b = 0.2; c = 0.3; (a + b) + c === a + (b + c) > false
  • 12.  Special number: Not a Number  Result of undefined or erroneous operations  Toxic: any arithmetic operation with NaN as an input will have NaN as a result  NaN is not equal to anything, including NaN  NaN === NaN is false  NaN !== NaN is true
  • 13.  A sequence of 0 or more 16-bit Unicode characters  No separate character type  Characters are represented as strings with length of 1  Strings are immutable  Similar strings are equal ( === )  String literals can use single or double quotes with escapement.  Strings are Objects
  • 14. > "hello".charAt(0) h > "hello, world".replace("hello", "goodbye") goodbye, world > "hello".toUpperCase() HELLO
  • 15.  null = deliberately no value  undefined = no value assigned yet  Variables declared but not initialized  Object/array members that don't exist
  • 16.  Boolean type: true or false  Everything else is “truthy” or “falsy”  0, "", NaN, null and undefined are falsy  Everything else is truthy  Boolean operations: &&, || and !
  • 17.  Simple key-value pairs, like:  HashMaps in Java  Associative arrays in PHP  Key is a string; value can be anything  Key is unique within an object
  • 18. var obj = new Object(); Or var obj = {}; These are semantically equivalent; the second is called object literal syntax and is more convenient.
  • 19. obj.name = "My Name" var name = obj.name; Or obj["name"] = "My Name"; var name = obj["name"]; Semantically equivalent; the second uses strings so can be decided at run-time (and can be used for reserved words)
  • 20. var obj = { name: "Carrot", "for": "Max", details: { color: "orange", size: 12 } } > obj.details.color Orange > obj["details"]["size"] 12
  • 21. Iterate over the keys of an object: var obj = { 'name': 'Simon', 'age': 25 }; for (var attr in obj) { alert (attr + ' = ' + obj[attr]); } Not to be used with Arrays
  • 22.  A special type of object: Keys are whole numbers, not strings.  Use [] syntax, just like objects > var a = new Array(); > a[0] = "dog"; > a[1] = "cat"; > a[2] = "hen“; > a.length 3  No such thing as “Associative Arrays”
  • 23. More convenient notation: > var a = ["dog", "cat", "hen"]; > a.length 3 var a = [10, "dog", false, "elephant"]; (you can have mixed content in arrays)
  • 24. > var a = ["dog", "cat", "hen"]; > a[100] = "fox"; > a.length 101 typeof a[90] == 'undefined' array.length is always one more than the highest index The safest way to append new items is: a[a.length] = item;
  • 25.  New variables are declared using the var keyword:  var a;  var name = "my name";  If you declare a variable without assigning it to anything, its value is undefined.  If you forget the var, you get a global variable.  Never, ever do this – not even if you mean it.
  • 26.  Global variables are visible everywhere  Blocks do not have scope  Variables defined inside blocks are hoisted to the top and are visible outside the block  Functions have scope  Variables defined inside function are visible throughout the function and its inner functions
  • 27. var a; //... function F() { var b; //... function N() { var c; //... }; }
  • 28.  Three different purposes of functions:  as sub-routine / procedure  as lambda (a block of executable code)  as object constructor  Functions are first-class:  can be assigned to a variable  can be passed as argument to any function  can be returned from any function  can be a member of any object  can be created at run time  Functions can be created inside another function
  • 29. function add(x, y) { var total = x + y; return total; } var add = function(x, y) { var total = x + y; return total; }; var add = function some_func(x, y) { var total = x + y; return total; }; If nothing is explicitly returned, return value is undefined
  • 30.  Parameters: “They’re more like... Guidelines”  Missing parameters are treated as undefined: > add() NaN // addition on undefined  You can pass in more arguments than expected: > add(2, 3, 4) 5 // added the first two; 4 was ignored
  • 31. The arguments special variable provides access to arguments as an array-like object function add() { var sum = 0; for (var i = 0, j = arguments.length; i < j; i++) { sum += arguments[i]; } return sum; } > add(2, 3, 4, 5) 14
  • 32. $('#some-id').click(function(evt) { // do something on click event };
  • 33. var add = function(x) { return function(y) { return x + y; }; };
  • 34. function Person(name) { this.name = name; this.getName = function() { return this.name; }; } var person = new Person("some one"); person.getName(); > some one