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 :: delete cr eslint 
Javascript :: setinterval nodejs 
Javascript :: regex find lines containing two strings 
Javascript :: performance.now nodejs example 
Javascript :: get last day of month javascript 
Javascript :: kendo angular grid date format 
Javascript :: gitignore for angular 
Javascript :: express request path 
Javascript :: document ready 
Javascript :: random boolean javascript 
Javascript :: how to let a function execute after 5 seconds javascript 
Javascript :: Copy document DOM without reference 
Javascript :: js get first element by class 
Javascript :: validate aadhaar number in javascript 
Javascript :: random generating api for quotes 
Javascript :: replace all words in string jquery 
Javascript :: javascript check if objects are equal 
Javascript :: dd.mm.yyyy pattern regex 
Javascript :: javascript change class of item 
Javascript :: javascript set html value div 
Javascript :: how to empty an element in javascript 
Javascript :: neo4j delete node by id 
Javascript :: converting bytes into kb js 
Javascript :: detect keypress javascript 
Javascript :: mongodb create index unique 
Javascript :: how to execute javascript after c# function execute 
Javascript :: open page in new tab using jquery 
Javascript :: open submenu jquery 
Javascript :: js get last 4 digits 
Javascript :: loopback date greater than 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =