typeof javascript
What value it has What the output shows you
when you write |console.log(typeof(variable);
Undefined: "undefined"
Null: "object"
Boolean: "boolean"
Number: "number"
String: "string"
Function object: "function"
E4X XML object: "xml"
E4X XMLList object: "xml"
NodeList "Nodelist [more data]"
HTMLCollection "HTMLCollection(1) [more data]"
// C# program to illustrate the
// concept of typeof operator
using System;
class GFG {
// Here store Type as a field
static Type a = typeof(double);
// Main method
static void Main()
{
// Display the type of a
Console.WriteLine(a);
// Display the value type
Console.WriteLine(typeof(int));
// Display the class type
Console.WriteLine(typeof(Array));
// Display the value type
Console.WriteLine(typeof(char));
// Display the array reference type
Console.WriteLine(typeof(int[]));
}
}
//retourne le type de la variable
let number = 1;
let string = "bonjour";
let bool = true;
let dict = { a: 1, b:2 };
console.log(typeof(number));//renvoie Number
console.log(typeof(string));//renvoie String
console.log(typeof(bool));//renvoie Boolean
console.log(typeof(dict));//renvoie Object
//cas spécial
console.log(typeof(NaN));//NaN = Not A Number renvoie Number