LoginSignup
0
0

More than 5 years have passed since last update.

文字列を一文字ずつ分割して反復(Array.from 利用)

Posted at

こんにちは。
文字列を一文字ずつ分割して反復させ、オブジェクトを作ってみました。Array.from() を利用しました。

var abc = {};
Array.from('abc', (v, i) => {abc[v]=i;});
  // Array.from('abc').forEach((v, i) => {abc[v]=i;});
console.log(abc); // => {a: 0, b: 1, c: 2}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0