# JavaScript Data Types || String, Number, Math, Array

--

**String -** indexOf(), lastIndexOf() **|| Number -** isNaN(), parseInt() **|| Math - **random(), sqrt() **|| Array - **concat(), every()

# What is JavaScript

The most used and popular programming language in the world is JavaScript. JavaScript is a client-side scripting language or many people call it a browser-side programming language. Originally it was an object oriental programming language, at first JavaScript could only work as a front-end but now JavaScript can work successfully in the backend. Since the advent of node.js, JavaScript has become easier to navigate as a backend

# JavaScript’ Method || String -> indexOf() & lastIndexOf()

## indexOf() :-

One method of JavaScript is indexOf(). If you pass data or value inside indexOf() and indexOf() works to find that particular data or value.

In other words, indexOf() is to find out whether the data or values inside indexOf() are in the previous sentence.

*~Returns the first data or value match as a result.~And if it can’t find any data or value, it returns -1 as a result.~indexOf() case sensitive. This means that the value you are looking for and where you are looking for must be the same sentence or word.*

**lastIndexOf() :-**

lastIndexOf() but works a bit like indexOf(). lastIndexOf() works in the same way to find particular data or values but only finds the last data or value.

This means that the last value of the sentence or word in the data or value inside the indexOf() returns as the result of the sentence or word lastIndexOf()

*~And if it can’t find any data or value, it returns -1 as a result.~lastIndexOf() case sensitive. This means that the value you are looking for and where you are looking for must be the same sentence or word.*

# JavaScript’s Method || Number -> NaN() & **isNaN()** & **parseInt()**

**NaN() :-**

JavaScript number is a method of data type NaN(). The full meaning of NaN() is Not a number. NaN() is the invalid type number. If you do not get any number as a result of checking the number of an experiment, it is NaN().

*~Returns the entire NaN () as a result if there is a NaN () in an object or an array~Syntax: — isNaN(value)*

## isNaN():-

NaN() and isNaN() work somewhat differently. If there is a non-numeric number inside isNaN() or a data type that is not a numeric number passed here, it converts that data and returns it to the number. That is, the isNaN () function is to convert non-numeric data types to numbers

*~If the number is valid after conversion, isNaN() returns false~If the number is invalid after conversion, isNaN () returns true and is a NaN () number*

## parseInt() :-

parseInt () is used to transfer / caste string number aggregate to decimal number. For example, the user can give you different types of inputs. Inputs can contain numbers and text together

The job of parseInt () is to only receive the number and not the rest of the letters and convert that input from string number to real number.

**Syntax: —**

*~*parseInt () usually receives two parameters.*~*The 1st parameter is the string received as input.

*Will convert from string number to real number and will convert 2nd parameter (octal, binary, hexadecimal, decimal) among themselves.*

~

~

# JavaScript’s Method || Math -> **random()** & **sqrt()**

## random() :-

The random () method of javascript is to represent one value at a time by rotating different types of values inside an array. random () is a method of JavaScript Math data Type

## sqrt() :-

Another important **Math** method of JavaScript is **sqrt ()**. This function returns the square root of a number

**Syntax: —**

*~Math.sqrt () is a math javascript object that returns the square root of x.~Math.sqrt (64) means the square value of 8 or the power of 8 to the power of 2.*

# JavaScript’s Method || Array **prototype** -> **concat() **& **every()**

## concat() :-

Another important Math method of JavaScript is concat()This method returns a new array consisting of the elements of the array on which you call it, followed by the elements of the arguments in the order they are passed.

You can pass multiple arguments to the ‘concat’ method. The arguments can be arrays, or data types like booleans, strings, and numbers.

**Syntax: —**

*~The concat() method creates a new array by merging (concatenating) existing arrays.~The concat() method does not change the existing arrays. It always returns a new array.~The concat() method can take any number of array arguments.*

## every() :-

Checks if each item in an array is true/false.

That is, checks each value from a specific array and returns true or false result if each condition is true or false

A complex array can return true or false results by checking the value of multiple objects from within

## some() :-

Checks whether any item within an array is true/false.

That is, it checks any one value from a particular array and returns a true or false result if a condition is true or false

A complex array can return true or false results by checking the value of multiple objects from within