1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

console.logで[Object]が出たとき

Posted at

背景

console.log(value);
→[object Object]

こういうことが多々あるが、中身を見たい。

いろんな解法

中身を文字列化する
console.log(JSON.stringify(value));

{"name":"hogehoge","discription":"paopao"}
console.dirでJSONの中身を確認する
console.dir(value);

{"name":"hogehoge","discription":"paopao"}

次のが一番かっこいいかも。

util.format
console.log('%o', obj);

{"name":"hogehoge","discription":"paopao"}

お疲れ様でした。

わからないところ、間違っているところ、もっといい方法がある場合は、コメントでもDMでも教えてください。

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?