SlideShare a Scribd company logo
Javascript: Conceptos básicos
Nuestras
locaciones
Nuestros
Panelistas
Jorge Bernal
Senior Engineer
Laura Rodrigo
Marketing Analyst
Contenido
 Coercion
 Scope
 Hoisting
 Closures
QUESTIONS?
#JSBelatrixCoercion
3 < 2 < 1
True False
3 < 2 // false
false <1 // coercion
0 < 1 // true
QUESTIONS?
#JSBelatrix
var str = "123";
parseInt(str, 10); // 123
Number(str); // 123
+str; // 123
var num = 789;
num.toString(); // "789"
String(num); // "789“
var a = 42;
var b = a + ""; // "42"
var c = "3.14";
var d = c - 0; // 3.14
var e = null;
if (a) {
console.log('here'); // here
}
while (e) {
console.log('never runs');
}
Explicit Implicit
QUESTIONS?
#JSBelatrix
"5" == "5" // "5" === "5"
"5" == 5 // !ToNumber("5") == 5
true == 5 // !ToNumber(true) == 5
"5" == {} // 5" == ToPrimitive({})
undefined == null // true
+0 === -0 // true
5 === 5 // true
"Hello" === "hello" // false
{a: 'hi'} === {a: 'hi'} // false
Abstract Equality Sctrict Equality
(==) (===)
QUESTIONS?
#JSBelatrixScope
function b() {
}
function a() {
b();
}
a();
QUESTIONS?
#JSBelatrix
function b() {
var myVar;
}
function a() {
var myVar = 2;
b();
}
var myVar = 1;
a();
myVar
undefined
myVar
2
myVar
1
QUESTIONS?
#JSBelatrix
myVar
undefined
myVar
2
myVar
1
function b() {
console.log(myVar);
}
function a() {
var myVar = 2;
b();
}
var myVar = 1;
a();
Reference to
Outer
Environment
Reference to
Outer
Environment
QUESTIONS?
#JSBelatrix
myVar
2
myVar
1
function b() {
console.log(myVar);
}
function a() {
var myVar = 2;
b();
}
var myVar = 1;
a();
Reference to
Outer
Lexical
Environment
QUESTIONS?
#JSBelatrix
function a() {
function b() {
console.log(myVar);
}
var myVar = 2;
b();
}
var myVar = 1;
a();
b(); //ReferenceError
myVar
2
myVar
1
Reference to
Outer
Lexical
Environment
QUESTIONS?
#JSBelatrix
var foo = true;
if (foo) {
let bar = foo * 2;
bar = something( bar );
console.log( bar );
}
console.log( bar ); // ReferenceError
Let
QUESTIONS?
#JSBelatrix
var foo = true;
if (foo) {
var a = 2;
const b =3;
a = 3; // Works
b = 4; // Error
}
console.log( a ); // 3
console.log( b ); // ReferenceError
Const
QUESTIONS?
#JSBelatrixHoisting
a = 2;
var a;
console.log(a);
var a;
a = 2;
console.log(a);
console.log(a);
var a = 2;
var a;
console.log(a);
a = 2;
// 2
// undefined
QUESTIONS?
#JSBelatrix
foo();
function foo () {
console.log(a); // undefined
var a = 2;
}
function foo () {
var a;
console.log(a); // undefined
a = 2;
}
foo();
QUESTIONS?
#JSBelatrix
foo(); // TypeError
bar(); // ReferenceError
var foo = function bar() {
// ...
};
var foo
foo(); // TypeError
bar(); // ReferenceError
foo = function () {
// ...
};
QUESTIONS?
#JSBelatrix
foo(); // 1
var foo;
function foo () {
console.log(1);
}
foo = function () {
console.log(2);
};
function foo () {
console.log(1);
}
foo(); // 1
foo = function () {
console.log(2);
};
QUESTIONS?
#JSBelatrixClosures
Closure: Cuando
una función es
capaz de recordar y
acceder a su scope,
incluso cuándo se
ejecuta fuera del
scope.
function foo() {
var a = 2;
function bar() {
console.log(a);
}
return bar;
}
var baz = foo();
baz(); // 2
QUESTIONS?
#JSBelatrix
function wait(message) {
setTimeout( function timer() {
console.log(message);
}, 1000);
}
wait('Hello, closure!');
QUESTIONS?
#JSBelatrix
function foo() {
var something = "cool";
var another = [1, 2, 3];
function doSomething() {
console.log( something );
}
function doAnother() {
console.log( another.join( " ! " ) );
}
}
Module Pattern
function CoolModule() {
var something = "cool";
var another = [1, 2, 3];
function doSomething() {
console.log( something );
}
function doAnother() {
console.log( another.join( " ! " ) );
}
return {
doSomething: doSomething,
doAnother: doAnother
};
}
var foo = CoolModule();
foo.doSomething(); // cool
foo.doAnother(); // 1 ! 2 ! 3
Revealing Module Pattern QUESTIONS?
#JSBelatrix
References
 https://tc39.github.io/ecma262/
 You Don't Know JS (book series) - Kyle Simpson
 JavaScript: Understanding the Weird Parts - Anthony Alicea
¿Preguntas?
¡Muchas Gracias!
www.belatrixsf.com

More Related Content

PDF
Exceptions in PHP
PPT
Intro to c programming
PDF
Php radomize
KEY
Good Evils In Perl (Yapc Asia)
PDF
Prototypal inheritance in JavaScript
PDF
5 c control statements looping
PDF
Regular Expressions: JavaScript And Beyond
Exceptions in PHP
Intro to c programming
Php radomize
Good Evils In Perl (Yapc Asia)
Prototypal inheritance in JavaScript
5 c control statements looping
Regular Expressions: JavaScript And Beyond

What's hot (20)

PPSX
C lecture 3 control statements slideshare
DOCX
Stack prgs
PPTX
Elements of C++11
PPTX
C Language - Switch and For Loop
PDF
Java 스터디 강의자료 - 1차시
PPTX
PHP5.3 を使うのはやめよう
ODP
Perl exceptions lightning talk
PDF
Linux shell script-1
PDF
C++ Undefined Behavior (Code::Dive 2016)
PDF
Beware: Sharp Tools
PDF
Regular Expressions in Javascript
PDF
Elegant Ways of Handling PHP Errors and Exceptions
PDF
What's in Groovy for Functional Programming
PPT
Questions typedef and macros
PPSX
Break and continue statement in C
PDF
Control structuresin c
ODP
null Pune meet - Application Security: Code injection
DOCX
C program to implement linked list using array abstract data type
C lecture 3 control statements slideshare
Stack prgs
Elements of C++11
C Language - Switch and For Loop
Java 스터디 강의자료 - 1차시
PHP5.3 を使うのはやめよう
Perl exceptions lightning talk
Linux shell script-1
C++ Undefined Behavior (Code::Dive 2016)
Beware: Sharp Tools
Regular Expressions in Javascript
Elegant Ways of Handling PHP Errors and Exceptions
What's in Groovy for Functional Programming
Questions typedef and macros
Break and continue statement in C
Control structuresin c
null Pune meet - Application Security: Code injection
C program to implement linked list using array abstract data type
Ad

Similar to Javascript: Conceptos básicos (20)

PPTX
Workshop 1: Good practices in JavaScript
PDF
JavaScript 2016 for C# Developers
PDF
2013-06-15 - Software Craftsmanship mit JavaScript
PDF
2013-06-24 - Software Craftsmanship with JavaScript
PDF
Javascript essentials
PDF
Workshop 10: ECMAScript 6
PDF
Javascript - The Good, the Bad and the Ugly
PDF
Static types on javascript?! Type checking approaches to ensure healthy appli...
PDF
ECMAScript2015
PPTX
NetPonto - The Future Of C# - NetConf Edition
PDF
Fundamental JavaScript [UTC, March 2014]
PDF
Headless Js Testing
PDF
Hacking Parse.y with ujihisa
PPTX
Academy PRO: ES2015
PPTX
Typescript barcelona
PDF
Clean & Typechecked JS
PPTX
Introduction to Javascript
PPTX
Groovy
PDF
Swift - the future of iOS app development
PDF
JavaScript for PHP developers
Workshop 1: Good practices in JavaScript
JavaScript 2016 for C# Developers
2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-24 - Software Craftsmanship with JavaScript
Javascript essentials
Workshop 10: ECMAScript 6
Javascript - The Good, the Bad and the Ugly
Static types on javascript?! Type checking approaches to ensure healthy appli...
ECMAScript2015
NetPonto - The Future Of C# - NetConf Edition
Fundamental JavaScript [UTC, March 2014]
Headless Js Testing
Hacking Parse.y with ujihisa
Academy PRO: ES2015
Typescript barcelona
Clean & Typechecked JS
Introduction to Javascript
Groovy
Swift - the future of iOS app development
JavaScript for PHP developers
Ad

More from Belatrix Software (20)

PPTX
Top 10 riesgos de las aplicaciones móviles
PPTX
Pruebas continuas con cypress en la era DevOps
PDF
Navigating the new world ushered in overnight by COVID-19
PDF
Multitenancy con múltiples Bases de Datos
PPTX
Desarrollando AWS Alexa Skills con Java
PPTX
Creando Animaciones en React Native
PDF
Microservicios con spring
PPTX
RPA: Sistemas de información para optimizar procesos de negocios
PPTX
Estrategias para alcanzar la Transformación Digital
PPTX
Testing de Aplicaciones Móviles, Públicas, Masivas y Críticas
PPTX
Api NodeJS con PureScript
PPTX
Machine Learning vs. Deep Learning
PPTX
Metodologías de CSS
PPTX
Los retos de un tester ágil
PPTX
IoT + voice assistants = posibilidades infinitas
PPTX
Lleva tus aplicaciones móviles a otro nivel con Flutter
PPTX
Microservicios con Net Core y Azure Service Fabric
PPTX
Micro Frontends: Rompiendo el monolito en las aplicaciones Web
PDF
Predictions 2019: Digital journeys are well on their way
PPTX
Integrando Test Driven Development en aplicaciones React
Top 10 riesgos de las aplicaciones móviles
Pruebas continuas con cypress en la era DevOps
Navigating the new world ushered in overnight by COVID-19
Multitenancy con múltiples Bases de Datos
Desarrollando AWS Alexa Skills con Java
Creando Animaciones en React Native
Microservicios con spring
RPA: Sistemas de información para optimizar procesos de negocios
Estrategias para alcanzar la Transformación Digital
Testing de Aplicaciones Móviles, Públicas, Masivas y Críticas
Api NodeJS con PureScript
Machine Learning vs. Deep Learning
Metodologías de CSS
Los retos de un tester ágil
IoT + voice assistants = posibilidades infinitas
Lleva tus aplicaciones móviles a otro nivel con Flutter
Microservicios con Net Core y Azure Service Fabric
Micro Frontends: Rompiendo el monolito en las aplicaciones Web
Predictions 2019: Digital journeys are well on their way
Integrando Test Driven Development en aplicaciones React

Recently uploaded (20)

PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Computer Software and OS of computer science of grade 11.pptx
PPTX
L1 - Introduction to python Backend.pptx
PPTX
Introduction to Artificial Intelligence
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPT
Introduction Database Management System for Course Database
PDF
medical staffing services at VALiNTRY
PPTX
assetexplorer- product-overview - presentation
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
Digital Strategies for Manufacturing Companies
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
System and Network Administraation Chapter 3
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Navsoft: AI-Powered Business Solutions & Custom Software Development
Which alternative to Crystal Reports is best for small or large businesses.pdf
CHAPTER 2 - PM Management and IT Context
Wondershare Filmora 15 Crack With Activation Key [2025
Computer Software and OS of computer science of grade 11.pptx
L1 - Introduction to python Backend.pptx
Introduction to Artificial Intelligence
Design an Analysis of Algorithms II-SECS-1021-03
VVF-Customer-Presentation2025-Ver1.9.pptx
Introduction Database Management System for Course Database
medical staffing services at VALiNTRY
assetexplorer- product-overview - presentation
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Digital Strategies for Manufacturing Companies
Reimagine Home Health with the Power of Agentic AI​
System and Network Administraation Chapter 3
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx

Javascript: Conceptos básicos