Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to check data type of javascript variable

let counter = 120; // counter is a number
console.log(typeof(counter)); // "number"

counter = false;   // counter is now a boolean
console.log(typeof(counter)); // "boolean"

counter = "Hi";   // counter is now a string
console.log(typeof(counter)); // "string"Code language: JavaScript (javascript)
Comment

check data type in js

typeof("string"); //string
typeof(123); //number
Comment

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
Comment

check data type in js

typeof("iAmAString");//This should return 'string'
//NO camelCase, as it is a JS Keyword
Comment

js check data type

typeof(variable)
Comment

check data type in js

var x = "Hello World";
typeof x; // "string"
Comment

PREVIOUS NEXT
Code Example
Javascript :: perform database transaction with sequelize 
Javascript :: javascript cahnge colour of strokerect 
Javascript :: nuxt looks for npm_modules on express 
Javascript :: get keys of object in an array 
Javascript :: js paste 
Javascript :: sample json 
Javascript :: put 0 in front of month number javascript 
Javascript :: disable scroll react 
Javascript :: input in javascript 
Javascript :: how to get selected value of dynamically created dropdown in jquery 
Javascript :: removeclass multiple 
Javascript :: react useeffect 
Javascript :: javascript style onclick 
Javascript :: event.target data-target 
Javascript :: how to control playback speed in javascript 
Javascript :: cancel button in react js 
Javascript :: jquery offsetheight 
Javascript :: input field take only number and one comma 
Javascript :: simplebar react 
Javascript :: angular 9 form value changes 
Javascript :: loop array in javascript 
Javascript :: tailwind hover dont work 
Javascript :: open modal in jqwuery 
Javascript :: jquery validation plugin google recaptcha 
Javascript :: multiple line string in jquery 
Javascript :: javascript assignment operators 
Javascript :: angular filter ngfor 
Javascript :: sls invoke local 
Javascript :: add property to object conditionally 
Javascript :: string contains character javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =