調べ方
オブジェクトと表現したときは,クラス,インスタンス,両方をさす。
オブジェクトが,どのクラスのインスタンスかを調べる
<html>
<script>
a = new Date()
console.log(a.constructor.name) // a が,Date クラスのインスタンスと分かる
</script>
</html>
クラスの親クラスを調べる
<html>
<script>
a = new Date()
console.log(a.constructor.name) // インスタンスのクラスが分かる
console.log(a.__proto__.__proto__.constructor.name) // さらにそのクラスの親クラスが分かる
</script>
</html>
- 最終更新:2020-10-29 11:25:44