Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
              
            
!

CSS

              
                
              
            
!

JS

              
                // # iterableなオブジェクトを用意する
// iterableなオブジェクト
const iterable = {};

// iterableなオブジェクトはiteratorを持つ = [Symbol.iterator]()メソッドを実行するとiteratorを返す
iterable[Symbol.iterator] = () => {
  // iteratorオブジェクト
  const iterator = {};
  let count = 1;
  // iteratorオブジェクトは.next()メソッドを持つ
  // .next()メソッドを実行するとiteratorResultオブジェクトを返す
  iterator.next = () => {
    // iteratorResultオブジェクトは.valueプロパティと.doneプロパティを持っている
    // .valueプロパティはイテレータから取り出した値
    // .doneプロパティは値を取り出し終えたかの真偽値
    const iteratorResult = (count <= 10)
      ? {value: count++, done: false}
      : {value: undefined, done: true};
    return iteratorResult
  }
  return iterator;
}

// # iteratorから順番に値を取り出す
// iterableなオブジェクトからiteratorを取得する
const iterator = iterable[Symbol.iterator]();
let iteratorResult;

while(true) {
  // 順番に値を取り出す
  iteratorResult = iterator.next();
  // 取り出し終えたらbreak
  if(iteratorResult.done) break;
  console.log(iteratorResult.value);
}

// # for-ofを使う
for(let v of iterable) console.log(v);

/*
# iterableなオブジェクトの種類

* 配列
* 配列の.keys(), .entries()
* 文字列
* イテレータ自身
* ジェネレータ
* Arguments
* TypedArray
* Map
* Set

# iterableなオブジェクトの利用

* for-of
* 配列リテラル
* Array.from
* 引数渡し
* 分割代入
* Map
* Set
* WeakMap
* WeakSet

*/
              
            
!
999px

Console