type of variable js
// get type of variable
var number = 1
var string = 'hello world'
var dict = {a: 1, b: 2, c: 3}
console.log(typeof number) // number
console.log(typeof string) // string
console.log(typeof dict) // object
type of variable js
// get type of variable
var number = 1
var string = 'hello world'
var dict = {a: 1, b: 2, c: 3}
console.log(typeof number) // number
console.log(typeof string) // string
console.log(typeof dict) // object
data type in javascript
var age = 18; // number
var name = "Jane"; // string
var name = {first:"Jane", last:"Doe"}; // object
var truth = false; // boolean
var sheets = ["HTML","CSS","JS"]; // array
var a; typeof a; // undefined
var a = null; // value null
check data type in js
typeof("string"); //string
typeof(123); //number
javascript data types
/*
The latest ECMAScript standard defines nine types:
Six Data Types that are primitives, checked by typeof operator:
undefined : typeof instance === "undefined"
Boolean : typeof instance === "boolean"
Number : typeof instance === "number"
String : typeof instance === "string"
BigInt : typeof instance === "bigint"
Symbol : typeof instance === "symbol"
Structural Types:
Object : typeof instance === "object". Special non-data but Structural type for any constructed object instance also used as data structures: new Object, new Array, new Map, new Set, new WeakMap, new WeakSet, new Date and almost everything made with new keyword;
Function : a non-data structure, though it also answers for typeof operator: typeof instance === "function". This is merely a special shorthand for Functions, though every Function constructor is derived from Object constructor.
Structural Root Primitive:
null : typeof instance === "object". Special primitive type having additional usage for its value: if object is not inherited, then null is shown;
*/
javascript data types
/*JavaScript data types*/
//string
var string = 'ASCII text';
//int
var integer = 123456789;
//float
var float = 123.456;
//boolean, can be true or false
var t = true;
var f = false;
//undefined
var undef;//defaults to undefined
var undef = undefined;//not common, use null
//null
var nul = null;
//array
var arr = ['Hello','my','name','is','Dr.Hippo',123,null];
//object
var person = {'name':'John Smith','age':27};
//function
var fun = function(){
return 42;
}
javascript data types
let x = "16" + "Volvo";
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us