Wie pro http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf, JavaScript 6 Typen: undefined
, null
, boolean
, string
, number
und object
.JavaScript-Typ
var und;
console.log(typeof und); // <-- undefined
var n = null;
console.log(typeof n); // <--- **object**!
var b = true;
console.log(typeof b); // <-- boolean
var str = "myString"
console.log(typeof str); // <-- string
var int = 10;
console.log(typeof int); // <-- number
var obj = {}
console.log(typeof obj); // <-- object
Frage 1:
Warum null vom Typ object
statt null
?
Frage 2:
Was funktioniert?
var f = function() {};
console.log(typeof f); // <-- function
Variable f
hat Typ function
. Warum ist es in der Spezifikation nicht als separater Typ spezifiziert?
Danke,
+1 in der Spezifikation zu graben, für ganzheitliche Aufklärung suchen. –