ECMAScript FrescoPlay
ECMAScript FrescoPlay
TC39, is the committee that drafts the ECMAScript specifications. They follow a yearly model for
defining new standards, where new features are added as they are approved, rather than waiting till
all features are ready. Thus ES7 will contain all features proposed and approved in 2016.
🔹 Course Covers:
Block scope (let and const)
Default, Rest and Spread parameters
Destructuring
Arrow Functions
Template Literals
ClassesandModules
Public
Public
Promise
Maps and Sets
Symbols
Transpiling
Freeze
Const doesn't make objects immutable. To make object immutable, use the freeze()
function.
Using freeze()
const car = Object.freeze({ name: 'Benz', class: 'c' })car.class =
's'console.log(car) // { name: 'Benz', class: 'c' }
Challenge 1: Max of
let maximum = (a,b) => {
if (a > b) {
return a;
} else {
return b;
Public
Public
module.exports = {maximum}
Types of Parameters:
1.Default Parameter
2.REST Parameter
3.Spread Parameter
SPREAD PARAMETER
🚩 Destructing content :
Destruction Handson:
Public
Public
🚩 Arrow Functions:
Arrow functions in ES6 are the modified and abbreviated syntax of JavaScript
functions.
These functions make use of => token and hence known as Fat Arrow functions.
Also, Arrow functions are less verbose than the traditional function expressions.
Way 1:
====
let add=(a,b)=>a+b;
//add function in single statement
Way 2:
=====
let add=(a,b)=>{
return a+b;
}
//add function with paranthesis
Way :1
=====
let numbers=[2,3,4,5,6,7];
let doubled=numbers.map(function(n){
return n*2;
});
console.log(doubled;)
Way :2
=====
let numbers=[2,3,4,5,6,7];
let doubled=numbers.map(n=>n*2);
console.log(doubled;)
This Keyword:
let person={
name:'Pazhani',
sayName:() => {
console.log('Hi i am $(this.name)');
}
}
Public
Public
person.sayName();
showHobbies:function(){
this.hobbies.forEach( hobby => {
console.log(`${this.name} likes ${hobby}`)
});
}
}
person.showHobbies();
Way 1:
let name='Pazhani';
console.log('His name is ' +name+ 'and he is working in TCS');
Way 2:
let name='Pazhani';
console.log('His name is ${name} and he is working in TCS');
🚩 Class in ES6:
class User{
constructor (username,email,password){
this.username=username;
this.email=email;
this.password=password;
}
register(){
console.log(this.username+' is now registered');
Public
Public
static countUsers(){
console.log('There are 50 users');
}
}
Set Handson
let myArray=[10,28,45,12];
let mySet=new Set(myArray);
mySet.add('Pazhani');
mySet.add(91.11);
mySet.add('100');
mySet.delete('100');
//mySet.clear();
console.log(mySet.size);
Set Output:
Map Handson
let myMap=new Map([['a1','Hello'],['b1','Goodbye']]);
myMap.set('c3','Foo');
Public
Public
myMap.delete('a1');
console.log(myMap.size);
console.log(myMap);
Map Output:
WeakSet Handson
let carWeakSet=new WeakSet();
let car1={
make: 'Honda',
model: 'Civic'
}
carWeakSet.add(car1);
let car2={
make: 'Toyota',
model: 'Camry'
}
carWeakSet.add(car2);
carWeakSet.delete(car1);
console.log(carWeakSet);
WeakSet Output:
WeakMap Handson
let carWeakMap=new WeakMap();
let key1={
id:1
}
let key2={
id:2
}
let car1={
make: 'Honda',
model: 'Civic'
}
let car2={
make: 'Toyota',
model: 'Camry'
}
carWeakMap.set(key1,car1);
carWeakMap.set(key2,car2);
console.log(carWeakMap);
carWeakMap.delete(key1);
console.log(carWeakMap);
Public
Public
🚩 Symbols:
🚩 Modules:
🚩 Promise:
🚩 Generators:
🚩 Transpiling:
Public
Public
continue and stay updated about the new features that will be added in future versions of
ECMAScript.
Public