Answers for "how to check if a variable is of type string in javascript"

0

check type string javascript

if (typeof myVar === 'string' || myVar instanceof String)
// it's a string
else
// it's something else
Posted by: Guest on October-15-2020
6

js check if variable is string

if (typeof myVar === 'integer'){
    //I am indeed an integer
}

if (typeof myVar === 'boolean'){
    //I am indeed a boolean
}
Posted by: Guest on March-19-2020

Code answers related to "how to check if a variable is of type string in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language