Skip to content

Instantly share code, notes, and snippets.

@mishelen
Created March 13, 2016 15:49
Show Gist options
  • Save mishelen/7e6ade047ed624fb83e9 to your computer and use it in GitHub Desktop.
Save mishelen/7e6ade047ed624fb83e9 to your computer and use it in GitHub Desktop.
красивый пример деструктурирующего присваивания. Т.е. можно присваивать итерируемые объекты.
function* fibs() {
var a = 0;
var b = 1;
while (true) {
yield a;
[a, b] = [b, a + b];
}
}
var [first, second, third, fourth, fifth, sixth] = fibs();
console.log(sixth);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment