javascript : Object.isNaN([nanValue])

 

javascript : Object.isNaN([nanValue])


Target:

Applicable with any javascript Object Variable that holds numeric value .


Description :

It checks variable value if it is not a numeric value, NaN or infinity then it return true otherwise false. When nanValue is passed as argument then it convert the value in numeric if it's result is NaN then return nanValue otherwise converted Numeric value.


Note: If nanValue is not passed then it return true/false.
If nanValue is passed then it convert value in numeric and return either Numeric value or nanValue.

another way to check whether variable holds numeric value or Nan or infinity
also convert the string to number if conversion failed then it return argument value nanValue



Syntax:

Object.isNaN([nanValue])

return true/false or converted Numeric/nanValue


Usase:

  1. var obj = 55;
    obj.isNaN()
    It return false.
  2. var obj = 55/0;
    obj.isNaN()
    It return true.
  3. var obj = 'a5.5';
    obj.isNaN()
    It return true.
  4. var obj = 55;
    obj.isNaN(0)
    It return 55.
  5. var obj = 55/0;
    obj.isNaN(0)
    It return 0.
  6. var obj = 'a5.5';
    obj.isNaN(0)
    It return 0.
  7. var obj = [1,2,3];
    obj.isNaN()
    It return true.
  8. var obj = [1,2,3];
    obj.isNaN(-1)
    It return -1.


Download MYJS.js

MyJs is a collection of java script extension methods that enhances the JavaScript objects, class object, DOM element, domElementsCollections, Date, String, Number and other data type. 

Include in you project landing page (master page) and it will extends your DOM and JavaScript Objects.

Comments

Popular posts from this blog

javascript : String.right

javascript : String.left

javascript : .nextAll()