Welcome aboard! We are happy you are here and wish you good net-raft!
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
function old_destructure() {
// old
var person = {
name: 'joe black',
age: 25,
role: 'web developer'
}
var name = person.name;
var age = person.age;
var role = person.role;
alert("old: " + name);
}
function es6_destructure() {
// ES6
let person = {
name: 'joe black',
age: 25,
address:{
street: 'welcome st.',
city: 'york',
pincode: 421210
}
}
let {address: {pincode}} = person;
alert("ES6: " + pincode);
alert("ES6: " + person.name);
}
</script>
<button onclick="old_destructure()">old</button>
<button onclick="es6_destructure()">ES6</button>
</body>
</html>
The most helpful JAVASCRIPT solutions
How can I get the last day and the next day in javascript ?JAVASCRIPT Click to see more ... 5.8K 507