1
0

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 3 years have passed since last update.

new 演算子で生成したインスタンスのオブジェクト名取得

Last updated at Posted at 2020-11-04

インスタンス.constructor.nameでオブジェクト名を参照できる。

function Foo() {};
let foo = new Foo();

console.log(foo.constructor.name);
//=> 'Foo'

参考
Function.name - JavaScript | MDN
new 演算子 - JavaScript | MDN

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?