Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

gettype js

typeof variable;
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 :: Read only directories in node 
Javascript :: how to make graphql request in axios 
Javascript :: react change button color on hover 
Javascript :: split a string every n characters javascript 
Javascript :: javascript reading query parameter 
Javascript :: can immigrants vote in uk 
Javascript :: legacy react start 
Javascript :: how to create an anchor tag in javascript 
Javascript :: create react app in existing folder 
Javascript :: detect mobile device 
Javascript :: react localstorage remove item 
Javascript :: brackets not autocompleting in js file in vscode 
Javascript :: moving a item fro index to another index, javascript 
Javascript :: react native get route name 
Javascript :: javascript upload json 
Javascript :: angular usehash not working 
Javascript :: react router catch all 404 
Javascript :: redirect angular 
Javascript :: javascript to convert rgb to hsl 
Javascript :: random word generator from alphabets javascript 
Javascript :: react native button 
Javascript :: Chart is not a constructor 
Javascript :: jquery append after 
Javascript :: retrieve object array value based on key 
Javascript :: jquery on click 
Javascript :: How to change htm h1 from nodejs 
Javascript :: textbox text change jquery 
Javascript :: how to encode a string in javascript 
Javascript :: motify react native 
Javascript :: remove array empty values javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =