Skip to content

JavaScript Data Type

1. What is isNaN

The isNaN() function is used to determine whether a value is an illegal number (Not-a-Number) or not.

JS
isNaN("Hello"); // true
isNaN("100"); // false

JS
Math.sqrt(-1); // NaN
parseInt("Hello"); // NaN

2. What is the purpose of isFinite function

The isFinite() function is used to determine whether a number is a finite, legal number. It returns false if the value is +infinity, -infinity, or NaN (Not-a-Number), otherwise it returns true.

JS
isFinite(Infinity); // false
isFinite(NaN); // false
isFinite(-Infinity); // false

isFinite(100); // true

3. What is the difference between native, host and user objects

Native objects are objects that are part of the JavaScript language defined by the ECMAScript specification. For example, String, Math, RegExp, Object, Function etc core objects defined in the ECMAScript spec. Host objects are objects provided by the browser or runtime environment (Node). For example, window, XmlHttpRequest, DOM nodes etc are considered as host objects. User objects are objects defined in the javascript code. For example, User objects created for profile information.