Skip to content

Instantly share code, notes, and snippets.

@suntong suntong/index.html
Created Jan 12, 2020

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner 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
You can’t perform that action at this time.