0
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 1 year has passed since last update.

javaScript_基本データ型とコンストラクタ

Last updated at Posted at 2022-08-03
// 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] }
0
0
1

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