JavaScript 目次 - ray88’s diary
JavaScript Objectオブジェクト - ray88’s diary
JavaScript Objectの凍結と封印 freezeメソッド・sealメソッド - ray88’s diary
function myFunction(){ //toStringメソッド:オブジェクトを表す文字列を返す //constructorプロパティ:オブジェクトを生成したクラス(コンストラクタ関数)を返す const obj = new Object(); console.log(obj.toString());//[object Object] console.log(obj.constructor);//[Function: Object] //オブジェクト const person = {name:'Bob',age:25}; console.log(person.toString());//[object Object] console.log(person.constructor);//[Function:Object] //数値 const number = 123; console.log(number.toString());123 console.log(number.constructor);//[Function:Number] //Dateオブジェクト const d = new Date(); console.log(d.toString());//Tue Jul 21 2020 11:09:29 GMT+0900(日本標準時) console.log(d.constructor);//[Function:Date] //配列 const array = [10,30,20,40]; console.log(array.toString());//10,30,20,40 console.log(array.constructor);//[Function:Array] }