📘 Premium Read: Access my best content on Medium member-only articles — deep dives into Java, Spring Boot, Microservices, backend architecture, interview preparation, career advice, and industry-standard best practices.
🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (176K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
- isNaN() – Stands for “is Not a Number”, if a variable is not a number, it returns true, else return false.
- typeof – If a variable is a number, it will return a string named “number”.
Using isNaN() Function
let num = 50;
if(isNaN(num)){
console.log(num + " is not a number");
}else{
console.log(num + " is a number");
}
let str = "javaguides";
if(isNaN(str)){
console.log(str + " is not a number");
}else{
console.log(str + " is a number");
}
50 is a number
javaguides is not a number
Using typeof Operator
let num = 50;
if(typeof num == 'number'){
console.log(num + " is a number");
}else{
console.log(num + " is not a number");
}
50 is a number
Comments
Post a Comment
Leave Comment