JAVASCRIPT destructure json array objects javascript - Net-Raft.com

Welcome aboard! We are happy you are here and wish you good net-raft!




Just a Web Code Solution

destructure a json array of objects in javascript


 107

Show ResultJAVASCRIPT


1

<!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>


By     Created   
The power of the user (%)
69%



The most helpful JAVASCRIPT solutions

How to get client machine name or computer name with javascript ?How to get client machine name or computer name with javascript ?JAVASCRIPT

Click to see more ...

  4.8K     383

get client hostname javascriptget client hostname javascriptJAVASCRIPT

Click to see more ...

  2.6K     254

detect ie javascriptdetect ie javascriptJAVASCRIPT

Click to see more ...

  1.6K     159

Create fireworks using javascriptCreate fireworks using javascriptJAVASCRIPT

Click to see more ...

  1.5K     113

create 3d barrel using javascriptcreate 3d barrel using javascriptJAVASCRIPT

Click to see more ...

  1.4K     99

get ip address javascriptget ip address javascriptJAVASCRIPT

Click to see more ...

  783     74

how to create foreach class using javascript ?how to create foreach class using javascript ?JAVASCRIPT

Click to see more ...

  769     73

create qr code javascriptcreate qr code javascriptJAVASCRIPT

Click to see more ...

  544     71

how to create the connect to a database with ADODB using javascript ?how to create the connect to a database with ADODB using javascript ?JAVASCRIPT

Click to see more ...

  489     59

get filename using javascript get filename using javascript JAVASCRIPT

Click to see more ...

  479     56