JavaScript array sort method | Sorts items order of an Array

JavaScript array sort method is used to sorting Array items in the given order. A sorted Array can be any order (as per given/need) like, alphabetic or numeric, and either ascending or descending. Note: Be default a sort() method sorts the values as strings in alphabetical and ascending order and changes the original array. Syntax Read More…


JavaScript isNull | How to Check for null

The value null represents the object value or variable value is don’t have any value(“No value”). There is no isNull function in JavaScript script to find without value objects. However you can build your own isNull() function with some logics. Examples of Check null in JavaScript Let’s see the example of it:- Code JavaScript check Read More…


JavaScript empty array | Check and Clear Examples

You can check JavaScript empty array doing by check for undefined first and then the length of it, if the length is zero then the array is empty. If you want to clear/empty an array in JavaScript, then there are multiple ways to it like Substituting with a new array, Setting the length prop to Read More…


JavaScript check if var is empty | Length and equality operator

Use equality operator to check if var is empty in JavaScript. Also, value.length is also a good approach but should be used in the case of a string. If the value is a number, value.length will return 0 Examples of JavaScript check if var is empty Let’s see the how to check it with examples:- Read More…


JavaScript checking null | Using equality operator

In JS null value means no value or absence of a value. Checking null in Javascript is easy, you can use the equality operator == or strict equality operator === (also called identity operator). Examples of JavaScript checking null Is the variable null? A code of Using equality operator to check null in JS. Note: Abstract Equality Comparison (==, also called Read More…


JavaScript check undefined | typeof and equality operator

If the variable declared without assigned any value then its initial value is undefined. You can use the typeof operator or if statement to check the value undefined in JavaScript. Undefined variable Example of JavaScript check undefined HTML example code of comparing a variable using if statement. It works with modern browsers. Use the equality Read More…


JavaScript IsNumeric function like jQuery?

How to write isNumber() in JavaScript? First, there is no function like isNumeric in pure JavaScript. But jQuery has this function to check the integers. but you could add your own function like below example: Complete Example of JavaScript IsNumeric HTML example code:-

Output: NOTE: Since parseInt() is not a proper way to check for numeric it should Read More…


isNaN JavaScript function | Check value is NaN(Not a Number)

The isNaN() Function used to determine whether the passed value is NaN(Not a Number)/illegal number in JavaScript. The global isNaN() function, converts the tested (given) value to a Number, then tests it. Syntax

Parameter Values The value which is to be tested for NaN. Return Value This function returns true if the value equates to Read More…


Convert NaN to 0 in JavaScript | Using isNan() method OR other method

Use isNan() method to Convert NaN to 0 in javascript. This method checks the given number is NaN or not. NaN means in JavaScript is “Not a Number”. When you can expect the NaN Error in JS? One of the common situations when you try to convert string number to number but the string has Read More…


JavaScript parseFloat() method | convert string to float number

JavaScript parseFloat() used to convert a string into a floating-point number. The parseFloat() is an inbuilt function in JavaScript, which parses a string and returns a floating-point number. Syntax

Parameter Values String Value converted to a floating point number. Return value It returns a floating-point Number or if can’t be converted then the function returns NaN Read More…