ES6 Destructuring and Template strings

var obj = { name:"X", surname: "Y" }

var { name, surname } = obj;

console.log("name", name);
console.log("surname", surname);

var values = ["Hey", "Hi", "Ssup"];
var [ x, y, z ] = values;

console.log("x", x);
console.log("y", y);
console.log("y", z);

// Template strings using backtics 
var str = `Value of x is ${x} and vallue of y is ${y}`;
console.log(str);

Comments

Popular posts from this blog

Inserting and Moving elements inside Ruby Array

Difference between Validations, Callbacks and Observers