SlideShare una empresa de Scribd logo
1 de 29
JavaScript
The World's Most Misunderstood Programming Language
http://www.neticy.com
http://www.joke4me.com
robbin@gmail.com
 Basic knowledge
 Dynamic language and functional language
 JavaScript frameworks and applications
 Debug and experiences of development
Basic Knowledge
Literal notation
Keywords
Functions
OOP
DOM/HTML
Literal notation in languages
A literal value is any part of a statement or expression that is to be
used exactly as it is, rather than as a variable or a script element.
You use literals to represent values in JavaScript. These are fixed
values, not variables, that you literally provide in your script. This
section describes the following types of literals:
a. Array Literals
b. Boolean Literals
c. Floating-Point Literals
d. Integers
e. Object Literals (JSON)
f. String Literals
g. Regex Literals
e.g. PHP/Java/C#: String, Integer, Boolean.
Python: String, Dictionary , List, Tuple
typeof
instanceof
this
in
undefined /null
delete
try/catch/finally/throw
|| &&
Keywords
typeof
" number" 、 "string" 、 "boolean" 、 "object" 、 "functio
n" 、 "undefined “.
If you just declare a variable, the default value of the variable
is ‘undefined’.
Always wrong if you are using an undefined variable.
e.g. var s = s || {};
||
Return the “true-like” variable, if both of them are true, return
the first. ( Equal ? : )
&&
Return the “false-like” variable, if both of them are true, return
the second.
instanceof
Check if the instance is initialized from that function/class.
Check if the prototype of some class/function is in the chain of
some object.
e.g. obj instanceof ClassA
Since every object has a prototype chain, the operation of
“instanceof” is to check if the ClassA’s prototype is in the
chain of obj.
So it could be “true” for many Class to one object.
Code snippet
Every object has a constructor property.
Every function/class has a prototype property which is an object,
that is to say, it is an instance of function(class).
Discussion: how to check if a variable is array?
in
Return a boolean value which specifies if the first variable is a
property/element of the second variable.
console.log(‘2’ in [1,2,3]);
console.log(‘join’ in [1,2,3]);
console.log(‘top’ in window);
undefined/null
If you just declare a variable, there the value of the variable is
‘undefined’.
Null is defined, the value of null is null.
var d;
if(d == undefined) console.log('fff');
delete
Make a variable undefined.
Delete a property of an object.
var a = ‘tt’; delete a;
try/catch/finally/throw
try { aaa ;} catch(e) { console.log(e); }finally { console.log('ff');}
It is not a good idea to hide an error
only if you know what you are doing.
throw
Raise an exception.
this
Dynamic language / Lazy evaluation
“this” means what this is.
Compare the differences of “this” in JavaScript/PHP/C#
Change ‘this’ via “apply” and “call” functions.
More detail will be the code analysis.
Trivial Code Snippet
Functions
Execute function
setTimeout/setInterval
eval
call/apply
Execute function
call/apply
setTimeout/setInterval
Mutil threads simulation in JavaScript.
Animate effect in JavaScript.
eval
apply/call
Specify a new current instance as the ‘this’ object.
The difference of them is the arguments.
{prototype library source code}
bind: function() {
if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this;
var __method = this, args = $A(arguments), object = args.shift();
return function() {
return __method.apply(object, args.concat($A(arguments)));
}
}
a.bind(b, …);
Source Code Analysis
Inheritance and creating class in
Prototype Library.
OOP/Inheritance
There are 3 ways to implement inheritance.
a.prototype chain
b.Properties copy
c.Using apply/call functions
Source Code Analysis
Inheritance in YUI and Mootools
JScript (IE)
SpiderMonkey(FF)
JavaScriptCore(Safari)
linear_b(Opera)
DOM/HTML
JavaScript Engine
While JavaScript is the programming language which will allow you to
operate on the DOM objects and to manipulate them programmatically, the
DOM will provide you with methods and properties to retrieve, modify,
update, and delete parts of the document you are working on.
If a web page were a piece of imported Swedish furniture, the DOM would
be the illustrations of the parts - the shelves, bolts, Allen wrenches and
screwdrivers.
The Document Object Model, a language-neutral set of interfaces
Keywords: W3C DOM Level1 and DOM Level2, XML, SAX
HTML DOM STRUCTURE
Html type nodeType name nodeType value
Element Node.ELEMENT_NODE 1 Element Node
Text Node.TEXT_NODE 3 Text Node
Document Node.DOCUMENT_NODE 9 document
Comment Node.COMMENT_NODE 8 Comment
DocumentFragment Node.DOCUMENT_FRAGMENT_NODE 11 Fragment
Attr Node.ATTRIBUTE_NODE 2 Attribute
The NodeType and NodeType Value
e.g. alert(document.nodeType);
ELEMENT_NODE                                  1
ATTRIBUTE_NODE                             2
TEXT_NODE                                          3
CDATA_SECTION_NODE                  4
ENTITY_REFERENCE_NODE             5
ENTITY_NODE                                      6
PROCESSING_INSTRCTION_NODE        7
COMMENT_NODE                              8
DOCUMENT_NODE                             9
DOCUMENT_TYPE_NODE                10
DOCUMENT_FRAGMENT_NODE    11
NOTATION_NODE                               12
All The NodeType and NodeType Value
createAttribute()
createComment()
createElement()
createTextNode()
getElementById()
getElementsByTagName()
Document Methods
getAttribute()
getAttributeNode()
getElementsByTabName()
hasAttribute()
removeAttribute()
removeAttributeNode()
setAttribute()
setAttributeNode()
Element Methods
attributes
childNodes
firstChild
lastChild
nextSibling
nodeName
nodeType
parentNode
previousSibling
appendChild()
cloneNode()
hasChildNodes()
insertBefore()
removeChild()
replaceChild()
Node Properties & Methods
What’s the differences between Node and Element ?
The theory of DOM can be applied to other every
dom manipulation, and other languages.
e.g. XML, XHTML, WML…
e.g. PHP, Java, C#...
Ref erence: http://www.w3schools.com
Thank you!
http://neticy.com
http://www.joke4me.com
Robbin.joe@gmail.com
Happy Tiger Year!

Más contenido relacionado

La actualidad más candente

Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)
jeffz
 
Overview of c language
Overview of c languageOverview of c language
Overview of c language
shalini392
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
Amir Ali
 

La actualidad más candente (20)

DIWE - Programming with JavaScript
DIWE - Programming with JavaScriptDIWE - Programming with JavaScript
DIWE - Programming with JavaScript
 
Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...
Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...
Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...
 
Type Checking JavaScript
Type Checking JavaScriptType Checking JavaScript
Type Checking JavaScript
 
All You Need to Know About Type Script
All You Need to Know About Type ScriptAll You Need to Know About Type Script
All You Need to Know About Type Script
 
Polymorphism in C++
Polymorphism in C++Polymorphism in C++
Polymorphism in C++
 
C++ concept of Polymorphism
C++ concept of  PolymorphismC++ concept of  Polymorphism
C++ concept of Polymorphism
 
07. Virtual Functions
07. Virtual Functions07. Virtual Functions
07. Virtual Functions
 
Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)
 
Polymorphism Using C++
Polymorphism Using C++Polymorphism Using C++
Polymorphism Using C++
 
002. Introducere in type script
002. Introducere in type script002. Introducere in type script
002. Introducere in type script
 
Back to the Future with TypeScript
Back to the Future with TypeScriptBack to the Future with TypeScript
Back to the Future with TypeScript
 
Overview of c language
Overview of c languageOverview of c language
Overview of c language
 
Ppt of c++ vs c#
Ppt of c++ vs c#Ppt of c++ vs c#
Ppt of c++ vs c#
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Shapeless- Generic programming for Scala
Shapeless- Generic programming for ScalaShapeless- Generic programming for Scala
Shapeless- Generic programming for Scala
 
Basic Javascript
Basic JavascriptBasic Javascript
Basic Javascript
 
Function overloading and overriding
Function overloading and overridingFunction overloading and overriding
Function overloading and overriding
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
 
Introduction to Dart
Introduction to DartIntroduction to Dart
Introduction to Dart
 
Virtual function
Virtual functionVirtual function
Virtual function
 

Destacado

ՏԵՂԵԿԱՏՎԱԿԱՆ ԵՎ ՀԱՂՈՐԴԱԿՑԱԿԱՆ ՏԵԽՆՈԼՈԳԻԱՆԵՐԻ (ՏՀՏ) ԿԻՐԱՌՈՒՄՆ ՈՒՍՈՒՄՆԱԿԱՆ ԳՈՐ...
ՏԵՂԵԿԱՏՎԱԿԱՆ ԵՎ ՀԱՂՈՐԴԱԿՑԱԿԱՆ ՏԵԽՆՈԼՈԳԻԱՆԵՐԻ  (ՏՀՏ) ԿԻՐԱՌՈՒՄՆ ՈՒՍՈՒՄՆԱԿԱՆ ԳՈՐ...ՏԵՂԵԿԱՏՎԱԿԱՆ ԵՎ ՀԱՂՈՐԴԱԿՑԱԿԱՆ ՏԵԽՆՈԼՈԳԻԱՆԵՐԻ  (ՏՀՏ) ԿԻՐԱՌՈՒՄՆ ՈՒՍՈՒՄՆԱԿԱՆ ԳՈՐ...
ՏԵՂԵԿԱՏՎԱԿԱՆ ԵՎ ՀԱՂՈՐԴԱԿՑԱԿԱՆ ՏԵԽՆՈԼՈԳԻԱՆԵՐԻ (ՏՀՏ) ԿԻՐԱՌՈՒՄՆ ՈՒՍՈՒՄՆԱԿԱՆ ԳՈՐ...
Երևանի N198 ավագ դպրոց
 
Algoritmner
AlgoritmnerAlgoritmner
Algoritmner
Armine
 

Destacado (16)

ՏՏ Համայնքի Կոոպերատիվ | Credit Union for the IT Industry
ՏՏ Համայնքի Կոոպերատիվ | Credit Union for the IT IndustryՏՏ Համայնքի Կոոպերատիվ | Credit Union for the IT Industry
ՏՏ Համայնքի Կոոպերատիվ | Credit Union for the IT Industry
 
Presentation final-version Andranik Terzyan
Presentation final-version Andranik TerzyanPresentation final-version Andranik Terzyan
Presentation final-version Andranik Terzyan
 
Varo Presentation
Varo PresentationVaro Presentation
Varo Presentation
 
Super cars
Super carsSuper cars
Super cars
 
Algoritm
AlgoritmAlgoritm
Algoritm
 
Java script
Java scriptJava script
Java script
 
ՏԵՂԵԿԱՏՎԱԿԱՆ ԵՎ ՀԱՂՈՐԴԱԿՑԱԿԱՆ ՏԵԽՆՈԼՈԳԻԱՆԵՐԻ (ՏՀՏ) ԿԻՐԱՌՈՒՄՆ ՈՒՍՈՒՄՆԱԿԱՆ ԳՈՐ...
ՏԵՂԵԿԱՏՎԱԿԱՆ ԵՎ ՀԱՂՈՐԴԱԿՑԱԿԱՆ ՏԵԽՆՈԼՈԳԻԱՆԵՐԻ  (ՏՀՏ) ԿԻՐԱՌՈՒՄՆ ՈՒՍՈՒՄՆԱԿԱՆ ԳՈՐ...ՏԵՂԵԿԱՏՎԱԿԱՆ ԵՎ ՀԱՂՈՐԴԱԿՑԱԿԱՆ ՏԵԽՆՈԼՈԳԻԱՆԵՐԻ  (ՏՀՏ) ԿԻՐԱՌՈՒՄՆ ՈՒՍՈՒՄՆԱԿԱՆ ԳՈՐ...
ՏԵՂԵԿԱՏՎԱԿԱՆ ԵՎ ՀԱՂՈՐԴԱԿՑԱԿԱՆ ՏԵԽՆՈԼՈԳԻԱՆԵՐԻ (ՏՀՏ) ԿԻՐԱՌՈՒՄՆ ՈՒՍՈՒՄՆԱԿԱՆ ԳՈՐ...
 
էհմ
էհմէհմ
էհմ
 
Ինֆորմացիայի տեսակները, կոդավորումը:
Ինֆորմացիայի տեսակները, կոդավորումը:Ինֆորմացիայի տեսակները, կոդավորումը:
Ինֆորմացիայի տեսակները, կոդավորումը:
 
Yerevan School 198 - Safer Internet Armenia - Safe.am
Yerevan School 198 - Safer Internet Armenia - Safe.am Yerevan School 198 - Safer Internet Armenia - Safe.am
Yerevan School 198 - Safer Internet Armenia - Safe.am
 
Vanadzor Secondary School after Raffi N 19
Vanadzor Secondary School after Raffi N 19Vanadzor Secondary School after Raffi N 19
Vanadzor Secondary School after Raffi N 19
 
Hishoxutiun
HishoxutiunHishoxutiun
Hishoxutiun
 
Etwinning live
Etwinning liveEtwinning live
Etwinning live
 
School 154 Safer Internet Armenia - Safe.am
School 154 Safer Internet Armenia - Safe.amSchool 154 Safer Internet Armenia - Safe.am
School 154 Safer Internet Armenia - Safe.am
 
Algoritm
AlgoritmAlgoritm
Algoritm
 
Algoritmner
AlgoritmnerAlgoritmner
Algoritmner
 

Similar a Master in javascript

javascript
javascript javascript
javascript
Kaya Ota
 
Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02
Sopheak Sem
 
Java Intro
Java IntroJava Intro
Java Intro
backdoor
 
JavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayJavaScript in Object-Oriented Way
JavaScript in Object-Oriented Way
Chamnap Chhorn
 
Douglas Crockford Presentation Goodparts
Douglas Crockford Presentation GoodpartsDouglas Crockford Presentation Goodparts
Douglas Crockford Presentation Goodparts
Ajax Experience 2009
 

Similar a Master in javascript (20)

JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
 
Ajax and JavaScript Bootcamp
Ajax and JavaScript BootcampAjax and JavaScript Bootcamp
Ajax and JavaScript Bootcamp
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
javascript
javascript javascript
javascript
 
Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02
 
Java Intro
Java IntroJava Intro
Java Intro
 
JavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayJavaScript in Object-Oriented Way
JavaScript in Object-Oriented Way
 
JavaScript Basics - GameCraft Training
JavaScript Basics - GameCraft TrainingJavaScript Basics - GameCraft Training
JavaScript Basics - GameCraft Training
 
"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues
 
oojs
oojsoojs
oojs
 
JavaScript(Es5) Interview Questions & Answers
JavaScript(Es5)  Interview Questions & AnswersJavaScript(Es5)  Interview Questions & Answers
JavaScript(Es5) Interview Questions & Answers
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
 
JavsScript OOP
JavsScript OOPJavsScript OOP
JavsScript OOP
 
Oop java
Oop javaOop java
Oop java
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller Columns
 
Douglas Crockford Presentation Goodparts
Douglas Crockford Presentation GoodpartsDouglas Crockford Presentation Goodparts
Douglas Crockford Presentation Goodparts
 
About Python
About PythonAbout Python
About Python
 
jsbasics-slide
jsbasics-slidejsbasics-slide
jsbasics-slide
 
Scala in a nutshell by venkat
Scala in a nutshell by venkatScala in a nutshell by venkat
Scala in a nutshell by venkat
 

Último

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Master in javascript

Notas del editor

  1. inheritance_apply_call_prototype.html