Thanks to visit codestin.com
Credit goes to www.scribd.com

64% found this document useful (28 votes)
48K views2 pages

ECMAScript6 Hands On

The document defines functions for finding the maximum of two values, summing a list of values, initializing states and greeting variables, returning a string with the sum of two numbers, defining a Car class with a constructor and method to return distance traveled, and using Symbols to define private properties on an object. It exports these functions and objects for use in other code.

Uploaded by

Anzal Malik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
64% found this document useful (28 votes)
48K views2 pages

ECMAScript6 Hands On

The document defines functions for finding the maximum of two values, summing a list of values, initializing states and greeting variables, returning a string with the sum of two numbers, defining a Car class with a constructor and method to return distance traveled, and using Symbols to define private properties on an object. It exports these functions and objects for use in other code.

Uploaded by

Anzal Malik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

let maximum = (a,b) => { if(a>b){


return a;}
else {
return b;
}
}

2.
const sum = (...args) => { var result=0;
args.forEach(function(args){
result+=args;})
return result;
}

3.
const states=[];
var [Chennai,Chandigarh]=[['Tamilnadu'],['Punjab','Haryana']];

module.exports = {states:[Chennai,Chandigarh]};

4.
Const greet= (name)=>{
return "Hello "+ name;
}

5.
const sum = (a,b) => {

return `The sum of ${a} and ${b} is ${a+b}`;

}
module.exports = {sum}

6.
class Car{
constructor(name,distance){
this.name=name;
this.distance=distance;
}
carDistance() {
return `${this.name} had travelled for ${this.distance} miles`;
}

let Car1 = new Car('Audi', 100);


const msg = Car1.carDistance();
console.log(msg);
module.exports = {msg}

7.
let email = Symbol();
let Employee = {
name : "rajesh",
phone :9800000000,
[email] : "[email protected]"
};

let allKeys = Reflect.ownKeys(Employee);


let privateKeys = Object.getOwnPropertySymbols(Employee);
let publicKeys = Object.getOwnPropertyNames(Employee);

module.exports = {Employee, allKeys, privateKeys, publicKeys}

You might also like