Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

string check javascript

if (typeof myVar === 'string') { /* code */ };
Comment

js test if string

if (typeof string === 'string') { /* code */ };
Comment

check if string javascript

it is better to check with isFinite() rather than typeof or isNAN() 
check this:
var name="somename",trickyName="123", invalidName="123abc";
typeof name == typeof trickyName == typeof invalidName == "string"
isNAN(name)==true
isNAN(trickyName)==false
isNAN(invalidName)==true
where:
isFinite(name) == false
isFinite(trickyName)== true
isFinite(invalidName)== true  
so we can do:
if(!isFinite(/*any string*/))
  console.log("it is string type for sure")
notice that:
	isFinite("asd123")==false
	isNAN("asd123")==true
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript click event notifications 
Javascript :: find email domain javascript 
Javascript :: sum of number using reduce 
Javascript :: console.table javascript 
Javascript :: vue js default prop 
Javascript :: fillstyle 
Javascript :: javascript loop through array of objects 
Javascript :: inarray javascript 
Javascript :: javascript sleep function 
Javascript :: jquery $(...)..each() is not a function 
Javascript :: how to check div is display:none or block in javascript 
Javascript :: immutable array sort javascript 
Javascript :: moment js year only 
Javascript :: how to set state when change viewport react 
Javascript :: file input change event not firing angular 
Javascript :: for each js 
Javascript :: aos js cdn 
Javascript :: javascript create element in a new line 
Javascript :: discord.js how to use subcommands 
Javascript :: vue chart nuxt 
Javascript :: jqurey cdn 
Javascript :: committing parts of a file git 
Javascript :: get first word of string js 
Javascript :: select add option js 
Javascript :: parseint() js 
Javascript :: vs code is showing 5k untracked files when nothing is changed from last commit 
Javascript :: electron file association 
Javascript :: get buffer from file javascript 
Javascript :: javascript remove all style values in div 
Javascript :: install react js 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =