Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

gettype js

typeof variable;
Comment

js get type of variable

typeof variable;
Comment

how to get type of variable in javascript

> typeof "foo"
"string"
> typeof true
"boolean"
> typeof 42
"number"
Comment

javascript get type of var

typeof operando
Comment

js get type


function gettype(data) {
            let itemType = Object.prototype.toString.call(data)
            let type = ''

            switch (itemType) {
                case "[object Null]":
                    type = 'Null';
                    break;

                case "[object Object]":
                    type = 'Object';
                    break;

                case "[object Array]":
                    type = 'Array';
                    break;

                case "[object String]":
                    type = 'String';
                    break;

                case "[object Boolean]":
                    type = 'Boolean';
                    break;

                case "[object Number]":
                    type = 'Number';
                    break;
            }

            return type
        }
Comment

js get type

 Object.prototype.toString.call(data)
Comment

PREVIOUS NEXT
Code Example
Javascript :: new function in javascript 
Javascript :: multiple refs react 
Javascript :: js get elements in array from x to y 
Javascript :: is javascript object oriented 
Javascript :: iterating over a string 
Javascript :: angular route 
Javascript :: inch to cm 
Javascript :: addeventlistener js 
Javascript :: filtering jquery 
Javascript :: how to install react js 
Javascript :: named parameters 
Javascript :: !! js 
Javascript :: structure data in javascript 
Javascript :: es6 class 
Javascript :: Group item by date 
Javascript :: javascript Using Math.max() on an Array 
Javascript :: jqueyr get parent 
Javascript :: javascript object/function which you want to proxy 
Javascript :: what is prototype in javascript 
Javascript :: passport middleware check if authenticated 
Javascript :: react functional component 
Javascript :: how to remove an object from javascript array 
Javascript :: convert string to array with condition javascirpt 
Javascript :: method function difference 
Javascript :: mongoose save return id 
Javascript :: javascript benchmark 
Javascript :: cookie-parser get cookie 
Javascript :: react routes not found on refresh 
Javascript :: object constructor js 
Javascript :: array unshift 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =