Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 33

JavaScript – ES6

R2S Academy - Internal Use 1


Content
1. Browsers support
2. The let & const Keyword
3. Arrow Functions
4. For...of Loop
5. Set Object
6. Map Object
7. Classes
8. Modules
9. Promises
10.Default Parameter Values
11. Function Rest Parameter
12.New String Methods
13.New Array Methods
14.New Math Methods
15.New Number Methods
16.ES 2016
17.ES 2017
18.ES 2018
1. Browsers support
2. The let & const Keyword
 The let keyword allows you to declare a variable
with block scope.
 The const keyword allows you to declare a constant.

Error:
undefined

Error: invalid assignment


3. Arrow Functions
 Arrow functions allows a short syntax for writing
function expressions. You don't need the function
keyword, the return keyword, and the curly brackets.
4. For...of Loop
 The JavaScript for…of statement loops through the
values of an iterable objects (such as Arrays,
Strings, Maps, …).
 Syntax

 Example
5. Set Object
 A JavaScript Set is a collection of unique values. A
Set can hold any value of any data type.
Property Description
size Returns the number elements in a Set

Method Description
new Set() Creates a new Set
add() Adds a new element to the Set
delete() Removes an element from a Set
has() Returns true if a value exists
clear() Removes all elements from a Set
forEach() Invokes a callback for each element
6. Map Object
 A Map holds key-value pairs where the keys can be
any datatype.
Property Description
size Returns the number elements in a Map

Method Description
new Map() Creates a new Map object
set() Sets the value for a key in a Map
get() Gets the value for a key in a Map
clear() Removes all the elements from a Map
delete() Removes a Map element specified by a key
has() Returns true if a key exists in a Map
forEach() Invokes a callback for each key/value pair in a Map
entries() Returns an iterator object with the [key, value] pairs in a Map
keys() Returns an iterator object with the keys in a Map
values() Returns an iterator object of the values in a Map
7. Classes
 A JavaScript class is not an object.
 It is a template for JavaScript objects.
Class Inheritance
8. Modules
person.js
teacher.js

index.js

index.html
Named & Default Exports
teacher.js

index.js
9. Promises
 A Promise is a JavaScript object that links
"Producing Code" and "Consuming Code".
 "Producing Code" can take some time and
"Consuming Code" must wait for the result.
 Syntax
10. Default Parameter Values
 ES6 allows function parameters to have default
values. The default values should start from right
continuously.
 Example
11. Function Rest Parameter
 The rest parameter (...) allows a function to treat an
indefinite number of arguments as an array.
 Example
12. New String Methods
Method Description
includes() Returns true if a string contains a specified value, otherwise false
startsWith() Returns true if a string begins with a specified value, otherwise false
endsWith() Returns true if a string ends with a specified value, otherwise false
13. New Array Methods
Method Description
find() Returns the value of the first array element that passes a test function
findIndex() Returns the index of the first array element that passes a test function.
14. New Math Methods
Method Description
trunc() Returns the integer part of x
sign() Returns if x is negative, null or positive
log2() Returns the base 2 logarithm of x
log10() Returns the base 10 logarithm of x
15. New Number Methods
Method Description
isInteger() Returns true if the argument is an integer.
isSafeInteger() Returns true if the argument is a safe integer. Safe integers are all
integers from -(2^53 - 1) to +(2^53 - 1).
ES 2016
New Operators
Operator Description
Exponentiation (**) Raises the first operand to the power of the second
exponentiation assig Raises the value of a variable to the power of the right
nment (**=) operand.
New Array Method
Method Description
includes() Check if an element is present in an array or not.
ES 2017
New String Method
Method Description
padStart Padding at the beginning of a string.
padEnd Padding at the end of a string.
New Object Methods
Method Description
entries Returns an array of the key/value pairs in an object.
values Returns a single dimension array of the object values.
Async Functions
ES 2018
Spread Operator
 Spread operator (...) allows us to quickly copy all or part of
an existing array or object into another array or object.
THE END

You might also like