Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

isNaN

function milliseconds(x) {
  if (isNaN(x)) {
    return 'Not a Number!';
  }
  return x * 1000;
}

console.log(milliseconds('100F'));
// expected output: "Not a Number!"

console.log(milliseconds('0.0314E+2'));
// expected output: 3140
Comment

isNan

const fail = 10 / "zero"; 
console.log(fail); //   NaN (Not a Number)
console.log(isNaN(fail)); // true
console.log(isNaN(10)); // false
console.log(isNaN('10')); // false
console.log(isNaN('blabla')); // true
console.log(isNaN(true)); // false
console.log(1.7976931348623157e+308 * 1000); //  Infinity
console.log(1.7976931348623157e+308 * -1000); // - Infinity
console.log(10 / 0); // Infinity
console.log(isFinite(123)); // true
Comment

isNaN

isNaN("Hello")  // Returns true
isNaN(345)   // Returns false
isNaN('1')  // Returns false, since '1' is converted to Number type which results in 0 ( a number) 
isNaN(true) // Returns false, since true converted to Number type results in 1 ( a number)
isNaN(false) // Returns false
isNaN(undefined) // Returns true
Comment

PREVIOUS NEXT
Code Example
Javascript :: js get dropdown value 
Javascript :: es6 spread assign nested object 
Javascript :: dot notation vs bracket notation 
Javascript :: what is react reveal 
Javascript :: js print objects 
Javascript :: hide element 
Javascript :: findindex method javascript 
Javascript :: js console log 
Javascript :: javascript make http request 
Javascript :: longest string 
Javascript :: npm i images=pdf 
Javascript :: pdf js 
Javascript :: FTP download local file 
Javascript :: write !important in react 
Javascript :: vuetify use selected value 
Javascript :: nodejs temp file 
Javascript :: validator.js 
Javascript :: inch to cm 
Javascript :: change parent state from child use effect in react js 
Javascript :: named parameters 
Javascript :: how to sort an array in js 
Javascript :: javascript test cases 
Javascript :: typeorm in 
Javascript :: react native svg size 
Javascript :: react native image picker 
Javascript :: js str split 
Javascript :: react navbar responsive 
Javascript :: express example 
Javascript :: How To Use Multiple Styles in REACT 
Javascript :: const in javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =