Skip to content

Instantly share code, notes, and snippets.

@mbifulco
Created March 28, 2019 12:37
Show Gist options
  • Save mbifulco/f71212825372085c6ac6cdc2abd920dc to your computer and use it in GitHub Desktop.
Save mbifulco/f71212825372085c6ac6cdc2abd920dc to your computer and use it in GitHub Desktop.
// source https://jsbin.com
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
'use strict';
var address = {
line1: '123 Fake Street',
line2: 'Apartment 12',
city: 'Springfield',
state: 'IL',
zip: '22223',
directions: {
contactNumber: '555-555-1212',
message: 'Knock on the front door, please',
editedBy: {
userId: '123445',
displayName: 'Milky Bee'
}
}
};
var zip = address.zip;
var _address$directions = address.directions;
var message = _address$directions.message;
var _address$directions$editedBy = _address$directions.editedBy;
var displayName = _address$directions$editedBy.displayName;
var userId = _address$directions$editedBy.userId;
console.log('my zip code is ' + zip);
console.log('special directions are ' + message);
console.log('directions last edited by ' + displayName + '<' + userId + '>');
</script>
<script id="jsbin-source-javascript" type="text/javascript">const address = {
line1: '123 Fake Street',
line2: 'Apartment 12',
city: 'Springfield',
state: 'IL',
zip: '22223',
directions: {
contactNumber: '555-555-1212',
message: 'Knock on the front door, please',
editedBy: {
userId: '123445',
displayName: 'Milky Bee',
}
}
};
const { zip } = address;
const {
directions : {
message,
editedBy: {
displayName,
userId,
},
}
} = address;
console.log(`my zip code is ${zip}`);
console.log(`special directions are ${message}`);
console.log(`directions last edited by ${displayName}<${userId}>`)</script></body>
</html>
'use strict';
var address = {
line1: '123 Fake Street',
line2: 'Apartment 12',
city: 'Springfield',
state: 'IL',
zip: '22223',
directions: {
contactNumber: '555-555-1212',
message: 'Knock on the front door, please',
editedBy: {
userId: '123445',
displayName: 'Milky Bee'
}
}
};
var zip = address.zip;
var _address$directions = address.directions;
var message = _address$directions.message;
var _address$directions$editedBy = _address$directions.editedBy;
var displayName = _address$directions$editedBy.displayName;
var userId = _address$directions$editedBy.userId;
console.log('my zip code is ' + zip);
console.log('special directions are ' + message);
console.log('directions last edited by ' + displayName + '<' + userId + '>');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment