Professional Documents
Culture Documents
JavaScript - 04 - ES6
JavaScript - 04 - ES6
Error:
undefined
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