What JavaScript?
Remove your whats
of JavaScript
The Creation
Brendan Eich
Made JavaScript in 10 days.
Hence..
JavaScript
Simple to use.
It really doesn’t care
Semicolons are optional
Parameters may or may not be passed
It really doesn’t care
function getMessage(message) {
internalVariable = “The message is: ”
return internalVariable + message
}
var result = getMessage(“dogs are nice”, 123, undefined, “etc”)
console.log( result )
// this’d positively print “The message is: dogs are nice” without errors
It really doesn’t care
Order of execution isn’t the order written
It really doesn’t care
doSomething()
function doSomething() {
console.log( ‘doing something’ )
}
// This do works..
Weakly typed
All variables may contain anything.
var something = 5;
console.log(something); // shows a 5
function sayHi() {
return “Hi!”;
}
something = sayHi();
console.log(something); // shows hi!
Weakly typed
Weakly typed
Operations between types can be executed
Conversion on the fly will occur
Weakly typed
var firstValue = 0;
firstValue++; // increase the integer
console.log(firstValue); // shows 1
firstValue += “1”; // concatenates 1 with “1”
console.log(firstValue); // shows “11”
Discovering JS
Types
Conditionals
Types Conversion
Scope
Types
Undefined
Null
Boolean
String
Number
Object including Array
Type undefined
People say that undefined may change the value. I don’t care about that.
if (newVariable === undefined)
This is perfectly fine for my standards.
(function(undefined) {
console.log(undefined); // Prints the given string, my own undefined
})(“my own undefined”);
This is stupid. So I don’t care about undefined not being undefined.
Type null
Very common value in other languages.
Can be seen a lot retrieving data from APIs.
var received = null;
if (received === null) {} // True
if (!received) {} // True too
Type boolean
var that = true;
if (that === true) {} // This is silly
if (that) {} // This is better
if (that == false) {} // Same as the first, silly
if (!that) {} // This is great
Type string
var text = “There was a time”;
if (text != “”)
console.log(“Text is not empty”);
// Above code is far too silly, it can be simpler as below
if (text)
console.log(“Text is not empty”);
Type number
var luckNumber = 5;
if (luckNumber != 0)
console.log(“Number is not zero”);
// This can be easier:
if (luckNumber)
console.log(“Number is positive or negative, not zero”);
Type object
// Right way to initialize an object, not using new
var virtualObject = {};
if (virtualObject)
console.log(“Object exist”); // Even without attributes, it
exist
virtualObject.firstAttribute = 1234; // Add attribute
if (virtualObject.unexistingMethod) // Continue only if method available
virtualObject.unexistingMethod(); // Unknown method error prevented
Type object
var dogs = [];
if (dogs) // Object
actually exist
dogs.push(“Terry”); // Now has one
element
console.log(dogs); // Prints [“Terry”]
If (dogs.length) // Length won’t be
zero
console.log(“Array has elements”); // So this actually prints
Discovering JS
Types
Conditionals
Types Conversion
Scope
Conditionals
With or without brackets conditionals must
be understood.
Conditionals
if (typeof aName == “string” && aName != “”) {
console.log(“Say hello to ” + aName);
}
This is wrong, javascript has a conditional of 3 equals.
Do NEVER use the 2 equals.
2 sometimes are OK, 3 will be always OK. Use 3 equals always.
Conditionals
if (typeof aName === “string” && aName !== “”) {
console.log(“Say hello to ” + aName);
}
Now this is still pretty awful. If aName is integer 18 then you cannot print hello to
18.
Conditionals
if (aName !== “”) {
console.log(“Say hello to ” + aName);
}
Yet horrible, there is no need to ask for not empty string explicitly
when it can be simpler.
Conditionals
// From `if (typeof aName == “string” && aName != “”)`
// To
if (aName) {
console.log(“Say hello to ” + aName);
}
Simplicity is on our side. Take that [INSERT CORRECT STARS
WAR CHARACTER]!
Conditionals
ALWAYS USE 3 EQUALS
Types Conversion
Now we are entering to the fun side
JavaScript is well known for its types conversion table
Also for its logic tables
And for everything else, but not in the good way
More as a joke
So lets try to get a good laugh from it
Types conversion
“”+1234
Types conversion
“1234”
Types conversion
+“1.357”
Types conversion
1.357
Types conversion
!!“gaga”
Types conversion
true
Types conversion
!!0
Types conversion
false
Types conversion
!!undefined
Types conversion
false
Types conversion
!!dogs.length
Types conversion
false/true
Discovering JS
Types
Conditionals
Types Conversion
Scope
Scope
We can define a scope as a set of rules for storing variables in
some location, and for finding those variables at a later time.
Scope
Nested Scopes
JavaScripts starts at the currently executing scope, looks for the
variable there, then if not found, keeps going up one level, and so
on. If the outermost global scope is reached, the search stops,
whether it finds the variable or not.
Nested Scopes
What JS? Itself

More Related Content

PPTX
Switch case and looping
PPTX
Loops in java script
PPTX
JavaScript Loop: Optimization of Weak Typing
PDF
iOS Talks 1 - CodeCamp Osijek - Swift u praksi
PDF
C++ Course - Lesson 1
PPTX
Switch case and looping kim
PDF
Loops in JavaScript
PDF
Practical TypeScript
Switch case and looping
Loops in java script
JavaScript Loop: Optimization of Weak Typing
iOS Talks 1 - CodeCamp Osijek - Swift u praksi
C++ Course - Lesson 1
Switch case and looping kim
Loops in JavaScript
Practical TypeScript

What's hot (20)

DOCX
Mauro yaguachi
PDF
Vim Hacks
PDF
VIM for (PHP) Programmers
PPT
PPT
My programming final proj. (1)
PPTX
Javascript conditional statements
DOCX
Java loops
PDF
RubyConf Portugal 2014 - Why ruby must go!
PPTX
Loops in c
DOCX
Vb script tutorial
PDF
Csharp_Chap04
PPTX
Spf Chapter5 Conditional Logics
PPT
Java Programming: Loops
PDF
Elm @ DublinJS
PDF
Knee-deep in C++ s... code
PPT
Introduction to Javascript
PPTX
Spf Chapter4 Variables
PDF
Vim Hacks (OSSF)
PPT
SQL -PHP Tutorial
Mauro yaguachi
Vim Hacks
VIM for (PHP) Programmers
My programming final proj. (1)
Javascript conditional statements
Java loops
RubyConf Portugal 2014 - Why ruby must go!
Loops in c
Vb script tutorial
Csharp_Chap04
Spf Chapter5 Conditional Logics
Java Programming: Loops
Elm @ DublinJS
Knee-deep in C++ s... code
Introduction to Javascript
Spf Chapter4 Variables
Vim Hacks (OSSF)
SQL -PHP Tutorial
Ad

Viewers also liked (15)

PPTX
What js? Its environment
PPTX
3Com 3CRVH701396A
PPTX
3Com 3C95006PS-2
PDF
Ez cast dongle an hdmi dongle-based tv streamer
PPTX
Wellstream Processing sales presentation
PPTX
Bowel treatment cme credits
PDF
PDF
Cocktail Party Venues Perth - Raffles Hotel
PPTX
3Com 3C10384VCX
PPTX
3Com 3C400050
PPT
Instituto franciscano inmaculada concepcion
PPTX
3Com 792002 REV D2
PDF
Resolución del Juez Bonadio
PDF
Boosting your SW development with Devops
What js? Its environment
3Com 3CRVH701396A
3Com 3C95006PS-2
Ez cast dongle an hdmi dongle-based tv streamer
Wellstream Processing sales presentation
Bowel treatment cme credits
Cocktail Party Venues Perth - Raffles Hotel
3Com 3C10384VCX
3Com 3C400050
Instituto franciscano inmaculada concepcion
3Com 792002 REV D2
Resolución del Juez Bonadio
Boosting your SW development with Devops
Ad

Similar to What JS? Itself (20)

PPTX
LinkedIn TBC JavaScript 100: Intro
PPT
An introduction to javascript
PPTX
Javascript analysis
PPTX
Javascript basics
PPTX
JAVASCRIPT - LinkedIn
PDF
Unethical JavaScript - Giorgio Natili - Codemotion Rome 2017
PDF
02 JavaScript Syntax
PPTX
Unit - 4 all script are here Javascript.pptx
PDF
Javascript essentials
PPTX
Chapter 1 .pptx
PPTX
Java script.pptx v
PPTX
Javascript
PPT
JavaScript Data Types
PPTX
JavaScript 1 for high school
PDF
Java script summary
PDF
Javascript - The Good, the Bad and the Ugly
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
PDF
JavaScript for beginners
PDF
Javascript tutorial basic for starter
PDF
JavaScript introduction 1 ( Variables And Values )
LinkedIn TBC JavaScript 100: Intro
An introduction to javascript
Javascript analysis
Javascript basics
JAVASCRIPT - LinkedIn
Unethical JavaScript - Giorgio Natili - Codemotion Rome 2017
02 JavaScript Syntax
Unit - 4 all script are here Javascript.pptx
Javascript essentials
Chapter 1 .pptx
Java script.pptx v
Javascript
JavaScript Data Types
JavaScript 1 for high school
Java script summary
Javascript - The Good, the Bad and the Ugly
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
JavaScript for beginners
Javascript tutorial basic for starter
JavaScript introduction 1 ( Variables And Values )

Recently uploaded (20)

PDF
4 layer Arch & Reference Arch of IoT.pdf
PDF
Data Virtualization in Action: Scaling APIs and Apps with FME
PDF
Rapid Prototyping: A lecture on prototyping techniques for interface design
PDF
MENA-ECEONOMIC-CONTEXT-VC MENA-ECEONOMIC
PDF
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
PPTX
SGT Report The Beast Plan and Cyberphysical Systems of Control
PPTX
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
PDF
Human Computer Interaction Miterm Lesson
PDF
Ensemble model-based arrhythmia classification with local interpretable model...
PDF
Transform-Your-Streaming-Platform-with-AI-Driven-Quality-Engineering.pdf
PDF
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
PDF
CXOs-Are-you-still-doing-manual-DevOps-in-the-age-of-AI.pdf
PDF
Auditboard EB SOX Playbook 2023 edition.
PDF
“The Future of Visual AI: Efficient Multimodal Intelligence,” a Keynote Prese...
PDF
A symptom-driven medical diagnosis support model based on machine learning te...
PDF
zbrain.ai-Scope Key Metrics Configuration and Best Practices.pdf
PPTX
Build automations faster and more reliably with UiPath ScreenPlay
PDF
giants, standing on the shoulders of - by Daniel Stenberg
PDF
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
PPTX
MuleSoft-Compete-Deck for midddleware integrations
4 layer Arch & Reference Arch of IoT.pdf
Data Virtualization in Action: Scaling APIs and Apps with FME
Rapid Prototyping: A lecture on prototyping techniques for interface design
MENA-ECEONOMIC-CONTEXT-VC MENA-ECEONOMIC
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
SGT Report The Beast Plan and Cyberphysical Systems of Control
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
Human Computer Interaction Miterm Lesson
Ensemble model-based arrhythmia classification with local interpretable model...
Transform-Your-Streaming-Platform-with-AI-Driven-Quality-Engineering.pdf
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
CXOs-Are-you-still-doing-manual-DevOps-in-the-age-of-AI.pdf
Auditboard EB SOX Playbook 2023 edition.
“The Future of Visual AI: Efficient Multimodal Intelligence,” a Keynote Prese...
A symptom-driven medical diagnosis support model based on machine learning te...
zbrain.ai-Scope Key Metrics Configuration and Best Practices.pdf
Build automations faster and more reliably with UiPath ScreenPlay
giants, standing on the shoulders of - by Daniel Stenberg
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
MuleSoft-Compete-Deck for midddleware integrations

What JS? Itself

Editor's Notes

  • #2: TODO: put letter of code to code and mark comments in another color