We can have spaces in object properties in ES2016
Example:
let employee = { "first name" : "madhu",
"last name" : "sudhan" };
console.log(employee["first name"];
let ln = "last name";
let employee = {"first name" : "madhu",
[ln] : "sudhan" };
console.log(employee);
console.log(employee["last name"]);
De-structuring Array:
Example:
let employee = ["madhu","talakok","male"];
let [firstname, lastname, gend="female"] = employee;
console.log(firstname); // madhu is printed.
console.log(gend); // male is printed.
De-structuring Objects( instead of fname we can use f):
Example:
let employee = { fname : "madhu",
lname : "sudhan" };
let { fname : f, lname:l} = employee;
console.log(employee.f); // prints madhu.
String Templates(using backtick ` key):
let mname = "sudhan";
console.log("madhu"+mname+"talakok");
// to avoid + in string
console.log(`madhu ${mname} talakok`);
let finalString = `madhu ${mname} talakok
gajwel
india`;
console.log(finalString); // spaces also considered with backtick
For Loop:
let colors = ["red","green","blue"];
for(let index of colors)
console.log(colors[index]); // output is red green blue
for (let color of colors)
console.log(color); // output is red green blue
Example:
let employee = { "first name" : "madhu",
"last name" : "sudhan" };
console.log(employee["first name"];
let ln = "last name";
let employee = {"first name" : "madhu",
[ln] : "sudhan" };
console.log(employee);
console.log(employee["last name"]);
De-structuring Array:
Example:
let employee = ["madhu","talakok","male"];
let [firstname, lastname, gend="female"] = employee;
console.log(firstname); // madhu is printed.
console.log(gend); // male is printed.
De-structuring Objects( instead of fname we can use f):
Example:
let employee = { fname : "madhu",
lname : "sudhan" };
let { fname : f, lname:l} = employee;
console.log(employee.f); // prints madhu.
String Templates(using backtick ` key):
let mname = "sudhan";
console.log("madhu"+mname+"talakok");
// to avoid + in string
console.log(`madhu ${mname} talakok`);
let finalString = `madhu ${mname} talakok
gajwel
india`;
console.log(finalString); // spaces also considered with backtick
For Loop:
let colors = ["red","green","blue"];
for(let index of colors)
console.log(colors[index]); // output is red green blue
for (let color of colors)
console.log(color); // output is red green blue
Very informative ! Indian cyber Army gives Best Ethical Hacking Training in noida in view of current industry principles that causes participants to anchor positions in their fantasy occupations at MNCs.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteBreaking news ! Reserve Bank of India’s (RBI) deadline given to banks to snap the ties with entities that cope with crypto currencies finally ends. Ever since the ban was obligatory, there was sentiment that the crypto currency market can survive the RBI ban.
ReplyDelete