Skip to content

Instantly share code, notes, and snippets.

@ramazankanbur
Created May 13, 2020 20:49
Show Gist options
  • Save ramazankanbur/0a681641cf9869af3f36930e82480636 to your computer and use it in GitHub Desktop.
Save ramazankanbur/0a681641cf9869af3f36930e82480636 to your computer and use it in GitHub Desktop.
var obj = function fn1() {
return { x: 'val1', y: 12, z: 'val2' };
};
//ES5
var resES5 = obj();
var x = resES5.x;
var y = resES5.y;
var z = resES5.z;
console.log(x, y, z);
//output
//val1 12 val2
//ES6
var { x, y, z } = obj();
console.log(x, y, z);
//output
//val1 12 val2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment