ECMAScript6 – ES6 – Fresco Play – T factor – Hands-On – Symbols – Destructuring Content – Classes – Arrow Functions Answers.

Disclaimer: The primary purpose of providing this solution is to assist and support anyone who are unable to complete these courses due to a technical issue or a lack of expertise. This website’s information or data are solely for the purpose of knowledge and education.
Make an effort to understand these solutions and apply them to your Hands-On difficulties. (It is not advisable that copy and paste these solutions).
Symbols:
Symbols are new unique, immutable, primitive data type just like Number, String and Boolean.
Hands-Ons-Answer:
let email = Symbol() ;
let Employee = { name: ‘rajesh’, phone:’9800000000′, [email]: ‘rajesh@gmail.com};
let allKeys = Reflect.ownKeys(Employee);
let privateKeys = Object.getOwnPropertySymbols(Employee);
let publicKeys = Object.getOwnPropertyNames( Employee) ;
Module.exports = { Employee, allKeys, privateKeys, publicKeys }
Destructuring Content:
Destructuring is a convenient way of extracting multiple values from data stored in array or objects into distinct variable.
Hands-Ons-Answer:
Const [Chennai, Chandigarh] = [[ ‘Tamilnadu’ ], [ ‘Punjab’, ‘Haryana’ ]];
Module.exports = { Chennai, Chandigarh }
Class in ES6:
Class is justice syntactical sugar over JavaScript prototype based inheritance ES6 classes provide simple and clear syntax for creating objects and deal with inheritance.
Hands-Ons-Answer:
class Car {
constructor(x, y)
{
this.x = x;
this.y = y;
}
carDistance()
{
return `${this.x} had travelled for ${this.y} miles`
}
}
let Car1 = new Car(‘Audi’s, 100);
const msg = Car1.carDistance() ;
module.exports = {msg}
Arrow Function:
Arrow functions in ES6 are the modified and abbreviated syntax of JavaScript functions. Also arrow functions or less verbose than the traditional function expressions.
Hands-Ons-Answer:
const sum = (…args) => {
var sumval = 0;
args.foreach(function(arg)
{
Sum += arg;
}) ;
Return sum;
}
Read more: – ECMAScript6 Fresco Play Essentials Hands-On Solutions | TCS Fresco Play