JavaScript array every method | checks if all elements pass a test

JavaScript array every method is used to tests whether all elements in the array pass the test implemented by the provided function. It returns a true for a pass and a false for failure. The advantage of this method is if you want to derive a single Boolean value from multiple elements in an array. Read More…


JavaScript toFixed method | Rounding number to specified decimals

JavaScript toFixed method formats a number with a specific number of digits to the right of the decimal. This means you can set numbers to a fixed decimal length. Note: It converts a number into a string and rounding to a specified number of decimals. Zero added a decimal point if the given number of Read More…


JavaScript toPrecision method | format a number to a specific precision or length

JavaScript toPrecision is used to format a number to a specific precision or length. Basically, it’s a specified length of number. Note: JS toPrecision method returns a string representing the Number object to the specified precision/length. Syntax Example of JavaScript toPrecision method Example of How to JavaScript Format a number into a specified length. Output: Read More…


JavaScript includes method | Array and String example

JavaScript includes() method work with Array and String. Where it used with String to determines whether a string contains the characters of a specified string. And in Array determines whether an array contains a specified element. Examples of JavaScript includes Let’s the example of includes() method with Array and Strings. JavaScript array includes an example check if an Read More…


JavaScript String includes method | Search one string into another string

JavaScript String includes a method used to determines whether a searching string contains found within another string. It will return a true if the string contains the characters otherwise false. Note: The JS includes() method is case sensitive Syntax Parameter Values searchvalue: The string to search for. start: At which position to start the search, optional Read More…


Number isinteger JavaScript Method | check var/value is an integer or not

Number isinteger JavaScript Method is used to know whether a value an integer or not? You have to pass the value into an isinteger() function and its return boolean value, true if the value is of the type Number. Otherwise, it returns false. Syntax Parameter Values A single parameter value value to be tested. Return Value Read More…


JavaScript foreach method | Loop and break Example

JavaScript foreach method is used in Array to Iterate through its items. This means its provided function once for each element of the array. Note: the function is not executed for array elements without values. Syntax Parameter Values array:- A array on which the .forEach() function was called. (Optional) index:- Array index of the current element. (Optional) element:- Read More…


JavaSript string indexof method | finds string and index

The JavaSript string indexof method returns the position of specified (search) value in a string. It returns the index value of the first occurrence search string. Note: The indexOf() method is case sensitive. Syntax Parameter Values searchvalue:- A Search value. (Required) start:- At which position to start the search. It’s optional and Default values is 0. Read More…


Math floor JavaScript | Rounds a number down and returns an integer value

JavaScript floor Method is used to Round a number down to its nearest integer. It required a single parameter value which is the number you want to be rounded to its nearest integer. The Math.floor() function returns the largest integer less than or equal to a given number. Note: If the passed argument is an integer, the value will not Read More…


Math random JavaScript Generate the Whole number

JavaScript Math Random method returns a random number (floating) between 0 (inclusive),  and 1 (exclusive). To get the integer number you have to use Math.floor() function with it. Example: How to use Math.random() Output: Q: How to Generate Random Whole Numbers with JavaScript? Answer: It’s easy and useful to generate random decimals or whole numbers. Read More…