9
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

文字列を連想配列(オブジェクト) or 配列に変換する。

Last updated at Posted at 2013-08-09

文字列→オブジェクト変換

var str = 'Hello World';
var obj = Object.prototype.valueOf.call(str);
console.log(obj);
> {0: "H", 1: "e", 2: "l", 3: "l", 4: "o", 5: " ", 6: "W", 7: "o", 8: "r", 9: "l", 10: "d"}

さらに配列に変換

var array = Array.prototype.slice.call(obj);
console.log(array);
>["H", "e", "l", "l", "o", " ", "W", "o", "r", "l", "d"]
9
8
2

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
9
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?