Path to Code
Begin Your Salesforce Coding Adventure
Episode 15
Basics of JavaScript
Jitendra Zaa
Salesforce MVP
Sr Technical Architect
23x Certified
@Jitendra Zaa
Speaker
Some House Rules
• Please mute your mic
• Keep adding questions in Zoom Q&A Window
• No question is too small
• Questions will be answered in last 15 mins
Agenda
• Introduction to JavaScript
• Hoisting
• var vs let vs const
• Different ways to write functions
• Arrow Functions
• Recursion
• Arguments.Callee
• Memoization
• Promises
History of JavaScript
1995
• Mocha created by Brendan Eich in 10 days
• Renamed to LiveScript Officially
• To piggyback popularity of Java, renamed to JavaScript
• Worried about Java Trademark, Microsoft released its own version
of JavaScript as JScript
1996
• Worried about future and standardization , Ecma group was
introduced to decide feature and capabilities of language
• EcmaScript was trademarked by Ecma group to define the standard
of JavaScript
Basics of JavaScript
Hoisting
Hoisting
The process of assigning variable declarations a default value of
undefined during the creation phase is called Hoisting.
Demo 1
Hoisting
Var
Var :
function scoped
undefined when accessing a variable before it’s declared
let
let :
block scoped
ReferenceError when accessing a variable before it’s declared
const
const :
block scoped
ReferenceError when accessing a variable before it’s declared
Can’t be reassigned
Demo 2
Different ways to write functions
Demo 3
Sequence of Method matters ?
Demo 4
Recursion
Demo 5
Arguments.Callee
Arrow Functions
Arrow Function
var multiplyES5 = function(x, y) {
return x * y;
};
const multiplyES6 = (x, y) =>
{ return x * y };
Memoization
Memoization is programming practice in which returned results from
functions are saved in cache, thus boosting the performance of long
running / iterative methods.
Demo 6
Memoization and Arrow Methods
Promises
Are Asynchronous
Has three states
1. Pending
2. Fulfilled
3. Rejected
Reference
• Secrets of Javascript by John Resig
• Hoisting
• Arrow Functions
Q&A
Next Episode 16
Getting Started with Lightning Web Components
Thanks

Episode 15 - Basics of Javascript