SlideShare a Scribd company logo
1 of 28
Download to read offline
JavaScript Essentials for
Ember Development
Leo Hernandez
@leojh
@leojh
A little about me...
● I work at Third Wave http://thirdwave.it
● I live in South Florida
● I remember when JavaScript was the redheaded stepchild
● Most of my career has been in .Net
● Been focusing heavily on Ember development for the past
year
● I mentor others at ThirdWave on JavaScript and Ember
@leojh
This Talk is Mostly for
Ember or JavaScript
beginners
@leojh
For the Rest of you… it’ll
probably be Old Hat
@leojh
If there is one thing that you should get
from this talk ….
@leojh
If there is one thing that you should take
from this talk ….
Use
@leojh
If there is one thing that you should take
from this talk ….
Use Use
two
@leojh
Why ES6?
@leojh
Essentially modernizes JavaScript
@leojh
Essentially modernizes JavaScript
String Interpolation
Namespacing
Lambda Expressions
Nice var scoping
Default parameters
Iterators
Classes
… and more
@leojh
ES5 - String Formatting
confirmPerson = function(name, state) {
var message = "Please confirm that your name is: " + name + "rn";
message += "and that you live in: " + state + "rn";
message += "and that you are not a robot.";
return confirm(message);
};
confirmPerson('Leo', 'Florida');
@leojh
ES6 - String Formatting
var confirmPerson = function(name, state) {
var message = `Please confirm that your name is: ${name}
and that you live in: ${state}
and that you are not a robot.`;
return confirm(message);
};
confirmPerson('Leo', 'Florida');
@leojh
ES6 - Lambda Expressions
let square = x => x * x;
[1,2,3,4,5].map(num => num * num);
[1,2,3,4,5].forEach(num => {
console.log(num);
})
//Important to note that 'this' keyword is preserved
@leojh
ES6 - Use const / let over var
// Use let var and const over var
// var is function scopes
// let/const are blocked scope
function() {
for (var i=0; i<=10; i++) {
var l = i;
}
console.log(l);
};
@leojh
ES6 - Default parameters
function sayMsg(msg='This is a default message.') {
console.log(msg);
}
sayMsg();
sayMsg('This is a different message!');
@leojh
Let’s talk about ...
@leojh
Use high-order functions
Use lambda expressions
Eschew imperative code
@leojh
Before we proceed, let’s review Closures
function outerFunc() {
var name = "Mozilla";
function innerFunc() {
alert(name);
}
return innerFunc();
};
In Brief:
Closures are a language in which variables scoped in an outer/parent function are
available to the child/inner function
@leojh
Eschew imperative code
Stop using:
Switch Statements
For loops
While loops
… and general imperative programming
… find the right high order function to be succinct in your code
@leojh
Use High Order functions instead of imperative code
.forEach() - iterates over a set
.map() - projects a set
.filter() - narrows down a set based on the predicate
.find() - returns first match in a set based on the predicate
.any() - returns true if match is found based on the predicate
.every() - returns true if match is found for all elements in the set (predicate also)
Ember gives us some additional nifty functions so we can avoid the predicate f()
@leojh
Nifty High Order Functions in Ember
.mapBy() - pass in name of a field
.filterBy() - pass in value name of field and value to match
.findBy() - pass in value name of field and value to match
.isAny() - pass in value name of field and value to match
.isEvery() - pass in value name of field and value to match
@leojh
Something even more nifty - Computed Macros
Allow you to use common High Order Functions as observables in your Ember
objects.
import Ember from 'ember';
export default Ember.Service.extend({
items: Ember.computed.alias('model')
subTotal: Ember.computed.sum('items.price'),
});
@leojh
Promises …
@leojh
You should really understand promises
A large part of the Ember framework is based on Promises
When you Provide a model to a Route - That’s a promise
Anytime you go fetch data from the server on Ember Data - That’s a promise
Promises let you circumvent Callback Hell
Sometimes you need to create your own Promises
@leojh
If you’re asking what Callback Hell Is
@leojh
Ember.RSVP
Become Familiar with the Ember.RSVP namespace
Read the Docs for the RSVP lib https://github.com/tildeio/rsvp.js/
ES6/RSVP syntax for creating a Promise
var promise = new Ember.RSVP.Promise(resolve, reject => {
// do your async work
//if it succeeds, call:
resolve(value);
//if it fails, call:
reject(error);
});
Other Tips
//Use truthy/falsey
let leo = null;
if (leo === null) {}
if (leo === typeof("undefined")) { }
if (leo) {}
//Coerce to boolean
let hasLength = "12345".length; //will return length
let hasLength = !!"12345".length; //will return true
//Defaults
let name = this.get('name') ? this.get('name') : 'No Name';
let name = this.get('name') || 'No Name';
@leojh
Thank you!
@leojh

More Related Content

What's hot

WorkinOnTheRailsRoad
WorkinOnTheRailsRoadWorkinOnTheRailsRoad
WorkinOnTheRailsRoadwebuploader
 
Workin ontherailsroad
Workin ontherailsroadWorkin ontherailsroad
Workin ontherailsroadJim Jones
 
Episode 8 - Path To Code - Integrate Salesforce with external system using R...
Episode 8  - Path To Code - Integrate Salesforce with external system using R...Episode 8  - Path To Code - Integrate Salesforce with external system using R...
Episode 8 - Path To Code - Integrate Salesforce with external system using R...Jitendra Zaa
 
Intro To Ror
Intro To RorIntro To Ror
Intro To Rormyuser
 
How Symfony Changed My Life
How Symfony Changed My LifeHow Symfony Changed My Life
How Symfony Changed My LifeMatthias Noback
 
Ruby Programming Introduction
Ruby Programming IntroductionRuby Programming Introduction
Ruby Programming IntroductionAnthony Brown
 
Node.js: CAMTA Presentation
Node.js: CAMTA PresentationNode.js: CAMTA Presentation
Node.js: CAMTA PresentationRob Tweed
 
Coding Best Practices
Coding Best PracticesCoding Best Practices
Coding Best Practicesmh_azad
 
Asynchronous I/O in Python 3
Asynchronous I/O in Python 3Asynchronous I/O in Python 3
Asynchronous I/O in Python 3Feihong Hsu
 
Intro to Ruby on Rails
Intro to Ruby on RailsIntro to Ruby on Rails
Intro to Ruby on Railselpizoch
 
Constructor and encapsulation in php
Constructor and encapsulation in phpConstructor and encapsulation in php
Constructor and encapsulation in phpSHIVANI SONI
 
Tech Webinar: AUMENTARE LA SCALABILITÀ DELLE WEB APP CON SERVLET 3.1 ASYNC I/O
Tech Webinar: AUMENTARE LA SCALABILITÀ DELLE WEB APP CON SERVLET 3.1 ASYNC I/OTech Webinar: AUMENTARE LA SCALABILITÀ DELLE WEB APP CON SERVLET 3.1 ASYNC I/O
Tech Webinar: AUMENTARE LA SCALABILITÀ DELLE WEB APP CON SERVLET 3.1 ASYNC I/OCodemotion
 

What's hot (20)

WorkinOnTheRailsRoad
WorkinOnTheRailsRoadWorkinOnTheRailsRoad
WorkinOnTheRailsRoad
 
Workin ontherailsroad
Workin ontherailsroadWorkin ontherailsroad
Workin ontherailsroad
 
vb script
vb scriptvb script
vb script
 
PHP Loops and PHP Forms
PHP  Loops and PHP FormsPHP  Loops and PHP Forms
PHP Loops and PHP Forms
 
Episode 8 - Path To Code - Integrate Salesforce with external system using R...
Episode 8  - Path To Code - Integrate Salesforce with external system using R...Episode 8  - Path To Code - Integrate Salesforce with external system using R...
Episode 8 - Path To Code - Integrate Salesforce with external system using R...
 
Intro To Ror
Intro To RorIntro To Ror
Intro To Ror
 
How Symfony Changed My Life
How Symfony Changed My LifeHow Symfony Changed My Life
How Symfony Changed My Life
 
Ruby Programming Introduction
Ruby Programming IntroductionRuby Programming Introduction
Ruby Programming Introduction
 
Node.js: CAMTA Presentation
Node.js: CAMTA PresentationNode.js: CAMTA Presentation
Node.js: CAMTA Presentation
 
Lesson 6 php if...else...elseif statements
Lesson 6   php if...else...elseif statementsLesson 6   php if...else...elseif statements
Lesson 6 php if...else...elseif statements
 
Coding Best Practices
Coding Best PracticesCoding Best Practices
Coding Best Practices
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
Ruby programming
Ruby programmingRuby programming
Ruby programming
 
Asynchronous I/O in Python 3
Asynchronous I/O in Python 3Asynchronous I/O in Python 3
Asynchronous I/O in Python 3
 
Intro to Ruby on Rails
Intro to Ruby on RailsIntro to Ruby on Rails
Intro to Ruby on Rails
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 
Overview of CoffeeScript
Overview of CoffeeScriptOverview of CoffeeScript
Overview of CoffeeScript
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
Constructor and encapsulation in php
Constructor and encapsulation in phpConstructor and encapsulation in php
Constructor and encapsulation in php
 
Tech Webinar: AUMENTARE LA SCALABILITÀ DELLE WEB APP CON SERVLET 3.1 ASYNC I/O
Tech Webinar: AUMENTARE LA SCALABILITÀ DELLE WEB APP CON SERVLET 3.1 ASYNC I/OTech Webinar: AUMENTARE LA SCALABILITÀ DELLE WEB APP CON SERVLET 3.1 ASYNC I/O
Tech Webinar: AUMENTARE LA SCALABILITÀ DELLE WEB APP CON SERVLET 3.1 ASYNC I/O
 

Similar to JavaScript Essentials for Ember development

Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPtutorialsruby
 
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPtutorialsruby
 
PHP Basics Ebook
PHP Basics EbookPHP Basics Ebook
PHP Basics EbookSwanand Pol
 
PHP-03-Functions.ppt
PHP-03-Functions.pptPHP-03-Functions.ppt
PHP-03-Functions.pptJamers2
 
An SEO’s Intro to Web Dev PHP
An SEO’s Intro to Web Dev PHPAn SEO’s Intro to Web Dev PHP
An SEO’s Intro to Web Dev PHPTroyfawkes
 
Php tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPhp tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPrinceGuru MS
 
JavaScript Cheatsheets with easy way .pdf
JavaScript Cheatsheets with easy way .pdfJavaScript Cheatsheets with easy way .pdf
JavaScript Cheatsheets with easy way .pdfranjanadeore1
 
Lambda Expressions in Java 8
Lambda Expressions in Java 8Lambda Expressions in Java 8
Lambda Expressions in Java 8icarter09
 
1669958779195.pdf
1669958779195.pdf1669958779195.pdf
1669958779195.pdfvenud11
 
Introductionto Xm Lmessaging
Introductionto Xm LmessagingIntroductionto Xm Lmessaging
Introductionto Xm LmessagingLiquidHub
 
1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_master1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_masterjeeva indra
 
Flickr Php
Flickr PhpFlickr Php
Flickr Phproyans
 

Similar to JavaScript Essentials for Ember development (20)

Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHP
 
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHP
 
PHP Basics Ebook
PHP Basics EbookPHP Basics Ebook
PHP Basics Ebook
 
phptutorial
phptutorialphptutorial
phptutorial
 
phptutorial
phptutorialphptutorial
phptutorial
 
Introduction to-php
Introduction to-phpIntroduction to-php
Introduction to-php
 
PHP-03-Functions.ppt
PHP-03-Functions.pptPHP-03-Functions.ppt
PHP-03-Functions.ppt
 
PHP-03-Functions.ppt
PHP-03-Functions.pptPHP-03-Functions.ppt
PHP-03-Functions.ppt
 
An SEO’s Intro to Web Dev PHP
An SEO’s Intro to Web Dev PHPAn SEO’s Intro to Web Dev PHP
An SEO’s Intro to Web Dev PHP
 
Php tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPhp tutorial from_beginner_to_master
Php tutorial from_beginner_to_master
 
JavaScript Cheatsheets with easy way .pdf
JavaScript Cheatsheets with easy way .pdfJavaScript Cheatsheets with easy way .pdf
JavaScript Cheatsheets with easy way .pdf
 
Lambda Expressions in Java 8
Lambda Expressions in Java 8Lambda Expressions in Java 8
Lambda Expressions in Java 8
 
1669958779195.pdf
1669958779195.pdf1669958779195.pdf
1669958779195.pdf
 
How DSL works on Ruby
How DSL works on RubyHow DSL works on Ruby
How DSL works on Ruby
 
Introductionto Xm Lmessaging
Introductionto Xm LmessagingIntroductionto Xm Lmessaging
Introductionto Xm Lmessaging
 
Python master class part 1
Python master class part 1Python master class part 1
Python master class part 1
 
1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_master1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_master
 
All of Javascript
All of JavascriptAll of Javascript
All of Javascript
 
Flickr Php
Flickr PhpFlickr Php
Flickr Php
 
Php, mysq lpart1
Php, mysq lpart1Php, mysq lpart1
Php, mysq lpart1
 

More from Leo Hernandez

Everyday Functional Programming in JavaScript
Everyday Functional Programming in JavaScriptEveryday Functional Programming in JavaScript
Everyday Functional Programming in JavaScriptLeo Hernandez
 
Everyday Functional Programming in JavaScript
Everyday Functional Programming in JavaScriptEveryday Functional Programming in JavaScript
Everyday Functional Programming in JavaScriptLeo Hernandez
 
Binary Concepts Review
Binary Concepts ReviewBinary Concepts Review
Binary Concepts ReviewLeo Hernandez
 
Octal and Hexadecimal Numbering Systems
Octal and Hexadecimal Numbering SystemsOctal and Hexadecimal Numbering Systems
Octal and Hexadecimal Numbering SystemsLeo Hernandez
 
Programming Paradigms
Programming ParadigmsProgramming Paradigms
Programming ParadigmsLeo Hernandez
 
ES6 - Make JavaScript Great for the First Time
ES6 - Make JavaScript Great for the First TimeES6 - Make JavaScript Great for the First Time
ES6 - Make JavaScript Great for the First TimeLeo Hernandez
 
Developing Single Page Apps with Ember.js
Developing Single Page Apps with Ember.jsDeveloping Single Page Apps with Ember.js
Developing Single Page Apps with Ember.jsLeo Hernandez
 
Tech 101 @ delray tech spaces
Tech 101 @ delray tech spacesTech 101 @ delray tech spaces
Tech 101 @ delray tech spacesLeo Hernandez
 

More from Leo Hernandez (12)

Everyday Functional Programming in JavaScript
Everyday Functional Programming in JavaScriptEveryday Functional Programming in JavaScript
Everyday Functional Programming in JavaScript
 
Everyday Functional Programming in JavaScript
Everyday Functional Programming in JavaScriptEveryday Functional Programming in JavaScript
Everyday Functional Programming in JavaScript
 
Binary Addition
Binary AdditionBinary Addition
Binary Addition
 
Binary Concepts Review
Binary Concepts ReviewBinary Concepts Review
Binary Concepts Review
 
Character Sets
Character SetsCharacter Sets
Character Sets
 
Octal and Hexadecimal Numbering Systems
Octal and Hexadecimal Numbering SystemsOctal and Hexadecimal Numbering Systems
Octal and Hexadecimal Numbering Systems
 
Programming Paradigms
Programming ParadigmsProgramming Paradigms
Programming Paradigms
 
ES6 - Make JavaScript Great for the First Time
ES6 - Make JavaScript Great for the First TimeES6 - Make JavaScript Great for the First Time
ES6 - Make JavaScript Great for the First Time
 
Developing Single Page Apps with Ember.js
Developing Single Page Apps with Ember.jsDeveloping Single Page Apps with Ember.js
Developing Single Page Apps with Ember.js
 
Tech 101 @ delray tech spaces
Tech 101 @ delray tech spacesTech 101 @ delray tech spaces
Tech 101 @ delray tech spaces
 
JavaScript ES6
JavaScript ES6JavaScript ES6
JavaScript ES6
 
Intro to ember.js
Intro to ember.jsIntro to ember.js
Intro to ember.js
 

Recently uploaded

[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
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...apidays
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
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 DiscoveryTrustArc
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)Samir Dash
 
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 ModelDeepika Singh
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
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 Pakistandanishmna97
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 

Recently uploaded (20)

[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
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...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
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
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
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
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 

JavaScript Essentials for Ember development

  • 1. JavaScript Essentials for Ember Development Leo Hernandez @leojh @leojh
  • 2. A little about me... ● I work at Third Wave http://thirdwave.it ● I live in South Florida ● I remember when JavaScript was the redheaded stepchild ● Most of my career has been in .Net ● Been focusing heavily on Ember development for the past year ● I mentor others at ThirdWave on JavaScript and Ember @leojh
  • 3. This Talk is Mostly for Ember or JavaScript beginners @leojh
  • 4. For the Rest of you… it’ll probably be Old Hat @leojh
  • 5. If there is one thing that you should get from this talk …. @leojh
  • 6. If there is one thing that you should take from this talk …. Use @leojh
  • 7. If there is one thing that you should take from this talk …. Use Use two @leojh
  • 10. Essentially modernizes JavaScript String Interpolation Namespacing Lambda Expressions Nice var scoping Default parameters Iterators Classes … and more @leojh
  • 11. ES5 - String Formatting confirmPerson = function(name, state) { var message = "Please confirm that your name is: " + name + "rn"; message += "and that you live in: " + state + "rn"; message += "and that you are not a robot."; return confirm(message); }; confirmPerson('Leo', 'Florida'); @leojh
  • 12. ES6 - String Formatting var confirmPerson = function(name, state) { var message = `Please confirm that your name is: ${name} and that you live in: ${state} and that you are not a robot.`; return confirm(message); }; confirmPerson('Leo', 'Florida'); @leojh
  • 13. ES6 - Lambda Expressions let square = x => x * x; [1,2,3,4,5].map(num => num * num); [1,2,3,4,5].forEach(num => { console.log(num); }) //Important to note that 'this' keyword is preserved @leojh
  • 14. ES6 - Use const / let over var // Use let var and const over var // var is function scopes // let/const are blocked scope function() { for (var i=0; i<=10; i++) { var l = i; } console.log(l); }; @leojh
  • 15. ES6 - Default parameters function sayMsg(msg='This is a default message.') { console.log(msg); } sayMsg(); sayMsg('This is a different message!'); @leojh
  • 16. Let’s talk about ... @leojh
  • 17. Use high-order functions Use lambda expressions Eschew imperative code @leojh
  • 18. Before we proceed, let’s review Closures function outerFunc() { var name = "Mozilla"; function innerFunc() { alert(name); } return innerFunc(); }; In Brief: Closures are a language in which variables scoped in an outer/parent function are available to the child/inner function @leojh
  • 19. Eschew imperative code Stop using: Switch Statements For loops While loops … and general imperative programming … find the right high order function to be succinct in your code @leojh
  • 20. Use High Order functions instead of imperative code .forEach() - iterates over a set .map() - projects a set .filter() - narrows down a set based on the predicate .find() - returns first match in a set based on the predicate .any() - returns true if match is found based on the predicate .every() - returns true if match is found for all elements in the set (predicate also) Ember gives us some additional nifty functions so we can avoid the predicate f() @leojh
  • 21. Nifty High Order Functions in Ember .mapBy() - pass in name of a field .filterBy() - pass in value name of field and value to match .findBy() - pass in value name of field and value to match .isAny() - pass in value name of field and value to match .isEvery() - pass in value name of field and value to match @leojh
  • 22. Something even more nifty - Computed Macros Allow you to use common High Order Functions as observables in your Ember objects. import Ember from 'ember'; export default Ember.Service.extend({ items: Ember.computed.alias('model') subTotal: Ember.computed.sum('items.price'), }); @leojh
  • 24. You should really understand promises A large part of the Ember framework is based on Promises When you Provide a model to a Route - That’s a promise Anytime you go fetch data from the server on Ember Data - That’s a promise Promises let you circumvent Callback Hell Sometimes you need to create your own Promises @leojh
  • 25. If you’re asking what Callback Hell Is @leojh
  • 26. Ember.RSVP Become Familiar with the Ember.RSVP namespace Read the Docs for the RSVP lib https://github.com/tildeio/rsvp.js/ ES6/RSVP syntax for creating a Promise var promise = new Ember.RSVP.Promise(resolve, reject => { // do your async work //if it succeeds, call: resolve(value); //if it fails, call: reject(error); });
  • 27. Other Tips //Use truthy/falsey let leo = null; if (leo === null) {} if (leo === typeof("undefined")) { } if (leo) {} //Coerce to boolean let hasLength = "12345".length; //will return length let hasLength = !!"12345".length; //will return true //Defaults let name = this.get('name') ? this.get('name') : 'No Name'; let name = this.get('name') || 'No Name'; @leojh