SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Downloaden Sie, um offline zu lesen
let
let$vs$var
let:"block&scope
var:"func%on'scope
Scope&1
var language = 'javascript';
if (true) {
var team = 'AppCenter';
let company = 'concur';
}
console.log(language);
console.log(team);
console.log(company);
Scope&1&(Answer)
var language = 'javascript';
if (true) {
var team = 'AppCenter';
let company = 'concur';
}
console.log(language); // 'javascript'
console.log(team); // 'AppCenter'
console.log(company); // ReferenceError: company is not defined
Loop$1
for (var i=1; i<=5; i++) {
let j = i;
setTimeout(function() {
console.log(i, j);
},500);
}
Loop$1$(Answer)
for (var i=1; i<=5; i++) {
let j = i;
setTimeout(function() {
console.log(i, j);
},500);
}
// 6, 1
// 6, 2
// 6, 3
// 6, 4
// 6, 5
Loop$w/Let
for (let i=1; i<=5; i++) {
setTimeout(function() {
console.log(i);
},500);
}
Loop$w/Let$(Answer)
for (let i=1; i<=5; i++) {
setTimeout(function() {
console.log(i);
},500);
}
//"1
//"2
//"3
//"4
//"5
Mul$ple'Declara$on
let version = 'ES 5';
var library = 'Angluar'
if (true) {
let version = 'ES 6';
var library = 'React';
console.log(version);
}
console.log(version);
console.log(library);
Mul$ple'Declara$on'(Answer)
let version = 'ES 5';
var library = 'Angluar'
if (true) {
let version = 'ES 6';
var library = 'React';
console.log(version); // 'ES 6'
}
console.log(version); // 'ES 5'
console.log(library); // 'React'
To#the#Top!
if (true) {
console.log(bar);
console.log(foo);
var bar;
let foo;
}
To#the#Top!#(Answer)
if (true) {
console.log(bar); // undefined
console.log(foo); // ReferenceError: foo is not defined
var bar;
let foo;
}
let!is!not!hoisted.!The!area!between!the!beginning!of!the!block!
and!the!variable!declara6on!is!called!the!"temporal*dead*zone"
Support
• Chrome(41+
• node.js(12+((with(66harmony)
• node --harmony --use-strict
• io.js
• Babel((Transpiler)
• IE11
h"p://kangax.github.io/compat3table/es6/
Why?
• Principle)of)least)privilege
• avoid'collisions
• fewer'hacks'(no'IIFEs)
• no'hois7ng
Going&Forward
• Grab&a&transpiler&and&start&using&let&today!
• h5ps://babeljs.io/
or
• Pay%a&en)on%to%the%scope%your%variables%have%and%any%hacks%
you're%using%to%create%a%smaller%scope
ES6 Let

Weitere ähnliche Inhalte

Was ist angesagt?

The Australian-The Deal Magazine
The Australian-The Deal MagazineThe Australian-The Deal Magazine
The Australian-The Deal Magazine
drocallaghan
 
Code sources des fonctions table cp
Code sources des fonctions table cpCode sources des fonctions table cp
Code sources des fonctions table cp
idhem110
 

Was ist angesagt? (20)

An Introduction to PHP... and Why It's Yucky!
An Introduction to PHP... and Why It's Yucky!An Introduction to PHP... and Why It's Yucky!
An Introduction to PHP... and Why It's Yucky!
 
Perl 5.28 new features
Perl 5.28 new featuresPerl 5.28 new features
Perl 5.28 new features
 
I, For One, Welcome Our New Perl6 Overlords
I, For One, Welcome Our New Perl6 OverlordsI, For One, Welcome Our New Perl6 Overlords
I, For One, Welcome Our New Perl6 Overlords
 
Angular server-side communication
Angular server-side communicationAngular server-side communication
Angular server-side communication
 
6 things about perl 6
6 things about perl 66 things about perl 6
6 things about perl 6
 
PHP - RAQ (Rarely Asked Questions!)
PHP - RAQ (Rarely Asked Questions!)PHP - RAQ (Rarely Asked Questions!)
PHP - RAQ (Rarely Asked Questions!)
 
The Australian-The Deal Magazine
The Australian-The Deal MagazineThe Australian-The Deal Magazine
The Australian-The Deal Magazine
 
Remote IP Power Switches
Remote IP Power SwitchesRemote IP Power Switches
Remote IP Power Switches
 
Playing nice with others
Playing nice with othersPlaying nice with others
Playing nice with others
 
Perl v5.26 Features (AmsterdamX.pm)
Perl v5.26 Features (AmsterdamX.pm)Perl v5.26 Features (AmsterdamX.pm)
Perl v5.26 Features (AmsterdamX.pm)
 
Nigel hamilton-megameet-2013
Nigel hamilton-megameet-2013Nigel hamilton-megameet-2013
Nigel hamilton-megameet-2013
 
Javascript Common Mistakes
Javascript Common MistakesJavascript Common Mistakes
Javascript Common Mistakes
 
Code sources des fonctions table cp
Code sources des fonctions table cpCode sources des fonctions table cp
Code sources des fonctions table cp
 
Siddhi CEP 2nd sideshow presentation
Siddhi CEP 2nd sideshow presentationSiddhi CEP 2nd sideshow presentation
Siddhi CEP 2nd sideshow presentation
 
6 more things about Perl 6
6 more things about Perl 66 more things about Perl 6
6 more things about Perl 6
 
FizzBuzzではじめるテスト
FizzBuzzではじめるテストFizzBuzzではじめるテスト
FizzBuzzではじめるテスト
 
Phpbase
PhpbasePhpbase
Phpbase
 
IsTrue(true)?
IsTrue(true)?IsTrue(true)?
IsTrue(true)?
 
Zend Framework
Zend FrameworkZend Framework
Zend Framework
 
A Lifecycle Of Code Under Test by Robert Fornal
A Lifecycle Of Code Under Test by Robert FornalA Lifecycle Of Code Under Test by Robert Fornal
A Lifecycle Of Code Under Test by Robert Fornal
 

Andere mochten auch

Costs decisionmaking
Costs decisionmakingCosts decisionmaking
Costs decisionmaking
Reema Theresa
 
台灣田野調查座標記錄
台灣田野調查座標記錄台灣田野調查座標記錄
台灣田野調查座標記錄
公共電視
 
Comic de spiderman y batman
Comic de spiderman y batmanComic de spiderman y batman
Comic de spiderman y batman
cris20de
 
Steko presentazione_ Professor Maurizio Galluzzo
Steko presentazione_ Professor Maurizio GalluzzoSteko presentazione_ Professor Maurizio Galluzzo
Steko presentazione_ Professor Maurizio Galluzzo
giovanni fiamminghi
 
Pendidikan islam di malaysia
Pendidikan islam di malaysiaPendidikan islam di malaysia
Pendidikan islam di malaysia
Ayu Faizah
 

Andere mochten auch (19)

Fat Arrow (ES6)
Fat Arrow (ES6)Fat Arrow (ES6)
Fat Arrow (ES6)
 
2015.02.14 溯源-b水的探索
2015.02.14 溯源-b水的探索2015.02.14 溯源-b水的探索
2015.02.14 溯源-b水的探索
 
Tram fascicolo web
Tram fascicolo webTram fascicolo web
Tram fascicolo web
 
Costs decisionmaking
Costs decisionmakingCosts decisionmaking
Costs decisionmaking
 
Taiwan現場目擊2014.08
Taiwan現場目擊2014.08Taiwan現場目擊2014.08
Taiwan現場目擊2014.08
 
Taiwan台灣環境檔案報導
Taiwan台灣環境檔案報導Taiwan台灣環境檔案報導
Taiwan台灣環境檔案報導
 
Taiwan 台灣環境檔案報導集錦Pdf
Taiwan 台灣環境檔案報導集錦PdfTaiwan 台灣環境檔案報導集錦Pdf
Taiwan 台灣環境檔案報導集錦Pdf
 
台灣環境檔案Taiwan
台灣環境檔案Taiwan台灣環境檔案Taiwan
台灣環境檔案Taiwan
 
2012.09.07退潮 映後座談
2012.09.07退潮 映後座談2012.09.07退潮 映後座談
2012.09.07退潮 映後座談
 
Abadlia spécificités de l'enseignement des littératures franco en fle
Abadlia   spécificités de l'enseignement des littératures franco en fleAbadlia   spécificités de l'enseignement des littératures franco en fle
Abadlia spécificités de l'enseignement des littératures franco en fle
 
After the third world
After the third worldAfter the third world
After the third world
 
我們的島 環境透視
我們的島 環境透視我們的島 環境透視
我們的島 環境透視
 
Raylyne bourne
Raylyne bourne  Raylyne bourne
Raylyne bourne
 
First week of school powerpoint
First week of school powerpointFirst week of school powerpoint
First week of school powerpoint
 
台灣田野調查座標記錄
台灣田野調查座標記錄台灣田野調查座標記錄
台灣田野調查座標記錄
 
Comic de spiderman y batman
Comic de spiderman y batmanComic de spiderman y batman
Comic de spiderman y batman
 
Steko presentazione_ Professor Maurizio Galluzzo
Steko presentazione_ Professor Maurizio GalluzzoSteko presentazione_ Professor Maurizio Galluzzo
Steko presentazione_ Professor Maurizio Galluzzo
 
Horizon baru
Horizon baruHorizon baru
Horizon baru
 
Pendidikan islam di malaysia
Pendidikan islam di malaysiaPendidikan islam di malaysia
Pendidikan islam di malaysia
 

Ähnlich wie ES6 Let

Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
Kang-min Liu
 
PHP and Rich Internet Applications
PHP and Rich Internet ApplicationsPHP and Rich Internet Applications
PHP and Rich Internet Applications
elliando dias
 
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developers
Stoyan Stefanov
 
Javascript: the important bits
Javascript: the important bitsJavascript: the important bits
Javascript: the important bits
Chris Saylor
 
Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPress
wpnepal
 
Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02
Seri Moth
 
jQuery: out with the old, in with the new
jQuery: out with the old, in with the newjQuery: out with the old, in with the new
jQuery: out with the old, in with the new
Remy Sharp
 
Cakefest 2010: API Development
Cakefest 2010: API DevelopmentCakefest 2010: API Development
Cakefest 2010: API Development
Andrew Curioso
 

Ähnlich wie ES6 Let (20)

Test-driven JavaScript Development - OPITZ CONSULTING - Tobias Bosch - Stefa...
Test-driven JavaScript Development - OPITZ CONSULTING -  Tobias Bosch - Stefa...Test-driven JavaScript Development - OPITZ CONSULTING -  Tobias Bosch - Stefa...
Test-driven JavaScript Development - OPITZ CONSULTING - Tobias Bosch - Stefa...
 
Security Challenges in Node.js
Security Challenges in Node.jsSecurity Challenges in Node.js
Security Challenges in Node.js
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
 
How to test complex SaaS applications - The family july 2014
How to test complex SaaS applications - The family july 2014How to test complex SaaS applications - The family july 2014
How to test complex SaaS applications - The family july 2014
 
PHP Unit Testing
PHP Unit TestingPHP Unit Testing
PHP Unit Testing
 
Angular promises and http
Angular promises and httpAngular promises and http
Angular promises and http
 
PHP and Rich Internet Applications
PHP and Rich Internet ApplicationsPHP and Rich Internet Applications
PHP and Rich Internet Applications
 
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developers
 
You promise?
You promise?You promise?
You promise?
 
symfony & jQuery (PUG)
symfony & jQuery (PUG)symfony & jQuery (PUG)
symfony & jQuery (PUG)
 
Javascript: the important bits
Javascript: the important bitsJavascript: the important bits
Javascript: the important bits
 
Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPress
 
Modern Perl
Modern PerlModern Perl
Modern Perl
 
Workshop 5: JavaScript testing
Workshop 5: JavaScript testingWorkshop 5: JavaScript testing
Workshop 5: JavaScript testing
 
Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter Scott
 
jQuery: out with the old, in with the new
jQuery: out with the old, in with the newjQuery: out with the old, in with the new
jQuery: out with the old, in with the new
 
Cakefest 2010: API Development
Cakefest 2010: API DevelopmentCakefest 2010: API Development
Cakefest 2010: API Development
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5
 
AngularJS Testing Strategies
AngularJS Testing StrategiesAngularJS Testing Strategies
AngularJS Testing Strategies
 

Kürzlich hochgeladen

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 

Kürzlich hochgeladen (20)

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 

ES6 Let