Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
const countdown = {
  [Symbol.iterator]() {
    const iterator = {
      value: 10,
      done: false,
      next() {
        this.done = this.done || this.value < 0;
        if (this.done) {
          return { done: true };
        } else {
          return { done: false, value: this.value-- };
        }
      }
    };
    return iterator;
  }
};
for (const count of countdown) {
  console.log(count);
}
const [ten, nine, eight, ...rest] = countdown;
console.log(ten)
  //=> 10
console.log(nine)
  //=> 9
console.log(eight)
  //=> 8
console.log(rest)
  //=> [7, 6, 5, 4, 3, 2, 1]
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers