Skip to content

Instantly share code, notes, and snippets.

@suntong
Created January 12, 2020 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suntong/8fc6f099d39e32514b3c6c8406a6568b to your computer and use it in GitHub Desktop.
Save suntong/8fc6f099d39e32514b3c6c8406a6568b to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/cubarot
<!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">
function getCoordinates(element) {
let x, y, z;
// X: { x, y, z } = { 1, 2, 3 }
x = 1
y = 2
z = 3
// do stuff to get coordinates
return [x, y, z];
}
{
const [x, y, z] = getCoordinates();
console.log(x, y, z)
}
function getXYZ() {
let x, y, z;
// X: { x, y, z } = { 1, 2, 3 }
x = 1
y = 2
z = 3
// do stuff to get coordinates
return {x:x, y:y, z:z};
}
{
const {x, y, z} = getXYZ();
console.log(x, y, z)
}
{
const {x, y1, z} = getXYZ();
console.log(x, y1, z)
}
</script>
<script id="jsbin-source-javascript" type="text/javascript">function getCoordinates(element) {
let x, y, z;
// X: { x, y, z } = { 1, 2, 3 }
x = 1
y = 2
z = 3
// do stuff to get coordinates
return [x, y, z];
}
{
const [x, y, z] = getCoordinates();
console.log(x, y, z)
}
function getXYZ() {
let x, y, z;
// X: { x, y, z } = { 1, 2, 3 }
x = 1
y = 2
z = 3
// do stuff to get coordinates
return {x:x, y:y, z:z};
}
{
const {x, y, z} = getXYZ();
console.log(x, y, z)
}
{
const {x, y1, z} = getXYZ();
console.log(x, y1, z)
}
</script></body>
</html>
function getCoordinates(element) {
let x, y, z;
// X: { x, y, z } = { 1, 2, 3 }
x = 1
y = 2
z = 3
// do stuff to get coordinates
return [x, y, z];
}
{
const [x, y, z] = getCoordinates();
console.log(x, y, z)
}
function getXYZ() {
let x, y, z;
// X: { x, y, z } = { 1, 2, 3 }
x = 1
y = 2
z = 3
// do stuff to get coordinates
return {x:x, y:y, z:z};
}
{
const {x, y, z} = getXYZ();
console.log(x, y, z)
}
{
const {x, y1, z} = getXYZ();
console.log(x, y1, z)
}
@suntong
Copy link
Author

suntong commented Jan 12, 2020

1
2
3
1
2
3
1
undefined
3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment