Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript compare number to string

let string = "1";
let number = 1;
if (parseInt(string) === number){
  	// STRING AND NUMBER MATCHES
}
if (string == number){
  // STRING AND NUMBER MATCHES ALSO BECAUSE == instead of ===, means it won't compare datasets, only the content
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: update chart js with new data 
Javascript :: chartjs Uncaught ReferenceError: Utils is not defined 
Javascript :: how to get unique values from array in javascript without duplicate value 
Javascript :: javascript array reorder elements 
Javascript :: create an attribute for html with javascript 
Javascript :: regexp constructor javascript 
Javascript :: reset select form jquery 
Javascript :: 150 pound in kg 
Javascript :: jquery checkvalidity 
Javascript :: MongoNotConnectedError: Client must be connected before running operations 
Javascript :: regex match exact string 
Javascript :: check if var is NaN 
Javascript :: convert number to word crore/lakhs 
Javascript :: how to change text color in react 
Javascript :: react native onChangeText resize the background image 
Javascript :: how to access parent function from iframe 
Javascript :: react js multiple import 
Javascript :: add onclick event jquery button 
Javascript :: iterate through object array javascript 
Javascript :: JSON.parse() error handling 
Javascript :: reverse int js 
Javascript :: jquery add table row 
Javascript :: onclick toggle class react 
Javascript :: joi object id validation 
Javascript :: Fibonacci Recursive in js 
Javascript :: javascript download current html page 
Javascript :: regex for username 
Javascript :: formik validator in react 
Javascript :: vanilla javascript fade out 
Javascript :: float to currency js 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =