// undefined nullの違い
typeof undefined // undefined
typeof null // object
null === undefined // false
null == undefined // true
// javaScriptよく使うデータ型
typeof "John" // string
typeof 3.14 // number
typeof NaN // number
typeof false // boolean
typeof [1,2,3,4] // object
typeof {name:'John', age:34} // object
typeof new Date() // object
typeof function () {} // function
typeof myCar // undefined
typeof null // object
// コンストラクタconstructor
例:
<body>
<p id="test"></p>
<script>
var pTest = document.getElementById("test");
pTest.innerHTML =
"john".constructor + "<br>" +
(3.14).constructor + "<br>" +
false.constructor + "<br>" +
[1,2,3,4].constructor + "<br>" +
{name:'john', age:34}.constructor + "<br>" +
new Date().constructor + "<br>" +
function () {}.constructor;
</script>
</body>
// 上記<p id="test"></p>内容
function String() { [native code] }
function Number() { [native code] }
function Boolean() { [native code] }
function Array() { [native code] }
function Object() { [native code] }
function Date() { [native code] }
function Function() { [native code] }
More than 1 year has passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme