Answers for "check if type of variable is string"

1

typescript if variable is string

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

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 "check if type of variable is string"

Code answers related to "Javascript"

Browse Popular Code Answers by Language