SlideShare a Scribd company logo
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
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPT
Teaching material agriculture food technology
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Approach and Philosophy of On baking technology
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Empathic Computing: Creating Shared Understanding
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
A Presentation on Artificial Intelligence
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Reach Out and Touch Someone: Haptics and Empathic Computing
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Review of recent advances in non-invasive hemoglobin estimation
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
A comparative analysis of optical character recognition models for extracting...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Teaching material agriculture food technology
MIND Revenue Release Quarter 2 2025 Press Release
Approach and Philosophy of On baking technology
NewMind AI Weekly Chronicles - August'25-Week II
Empathic Computing: Creating Shared Understanding
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
The AUB Centre for AI in Media Proposal.docx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Network Security Unit 5.pdf for BCA BBA.
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
A Presentation on Artificial Intelligence
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...

What JS? Itself

Editor's Notes

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