<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nicolas Rodriguez</title>
    <description>The latest articles on DEV Community by Nicolas Rodriguez (@rodr0245).</description>
    <link>https://dev.to/rodr0245</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F729283%2F0779fe48-43b2-4c74-bbc6-a111b7789d6b.jpeg</url>
      <title>DEV Community: Nicolas Rodriguez</title>
      <link>https://dev.to/rodr0245</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rodr0245"/>
    <language>en</language>
    <item>
      <title>JavaScript:     Number.isNaN() vs isNaN()</title>
      <dc:creator>Nicolas Rodriguez</dc:creator>
      <pubDate>Mon, 18 Oct 2021 14:41:14 +0000</pubDate>
      <link>https://dev.to/rodr0245/javascript-numberisnan-vs-isnan-m2d</link>
      <guid>https://dev.to/rodr0245/javascript-numberisnan-vs-isnan-m2d</guid>
      <description>&lt;p&gt;This is a quick tutorial about &lt;code&gt;Number.isNaN&lt;/code&gt; and &lt;code&gt;isNaN()&lt;/code&gt; from Javascript.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Number.isNaN&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;Number.isNaN&lt;/code&gt; is a JavaScript method which simply finds out if whatever value passed is a number or not (&lt;code&gt;NaN&lt;/code&gt;).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'use strict'
console.log(Number.isNaN(420));   // false, IT IS a number
console.log(Number.isNaN('NaN')); // true, it is NOT a number
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Number.isNaN&lt;/code&gt; is usually used in functions to determine if a value passed to a function is a number and is able to process or pass that number on to other functions. The following function is a simple &lt;code&gt;if&lt;/code&gt; statement that uses both &lt;code&gt;Number.isNaN&lt;/code&gt; and &lt;code&gt;isNaN&lt;/code&gt; in order to determine if the passed value is a number and then prints out which type of of &lt;code&gt;NaN&lt;/code&gt; is used.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'use strict'

let numberNaNvsNaN = function (yourValue) { 
    if (isNaN(yourValue)) { 
        return yourValue + ' isNaN determines it is NOT number';
    }
    if (Number.isNaN(yourValue)) { 
        return yourValue + ' Number.isNaN() determines it is NOT a number';
    }
}

console.log(numberNaNvsNaN(NaN));
console.log(typeOfNaN('5dogs'));

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;It is important to remember that both Number.isNaN and isNaN will always return a boolean value, &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;isNaN&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;isNaN&lt;/code&gt; is also used to determine if a value is a number or not, but doesn't always behave the same way when it is passed non-numeric values because it tries to convert non-numeric values, this makes it less useful than Number.IsNaN.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// List of arguments that are NOT numbers but isNaN fails to recognize this.
console.log(isNaN(undefined));
console.log(isNaN('cat')); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
