**Some useful technique of using Number and String in JavaScript**

--

JavaScript is a lightweight, interpreted programming language.

Number: Number is a type in javaScript. The range of number value is=From (253 − 1) to 253–1.

The largest positive number in JavaScript = **(253–1).**

To see in editor=

The largest positive number in JavaScript = **–(253–1).**

To see in editor=

infinity and Infinity number

JavaScript has infinity and Infinity number:

Infinity number = **1/0 ,**

-Infinity number = **-1/0**

**Topics are:**

Convert to another type

We can convert any other types of number value to an integer value. Example:

§ Convert binary to decimal number =

§ Convert string to number=

§ Convert octal to number:

Math.abs(x)

We can find the absolute value of a number using Math.abs

Math.ceil(x) , Math.floor(x)

To get the upper and lower integer value of a floating-point number, use ceil and floor

Math.max(x,y,…), Math.min(x,y,…)

Find the minimum and maximum number from **numbers** =

Find the minimum and maximum number from an **Array** =

We can find the minimum number in the same way.

Math.random()

We can find a random number in an array. To find a random number

Math.round()

We can find around value. The **Math.round()** function returns the value of a number rounded to the nearest integer.

Math.sqrt()

The **Math.sqrt()** function returns the square root of a number. Sqr value is the root value of a number. We can find it by using sqrt(). But it must be a number.

String:A

string isa data type used in programming language. It is a set of characters that can also contain spaces and numbers.

**Topics are:**

String values have to put in** “ ” / ‘ ’/` `.**

Example:

concat()

It is used to add to a string

includes(word)

includes is used to check if the word is there or not.

indexOf(“word”)

to find the position of the word or letter.

**sentence.replace(‘the_word_to_be_replaced’,’replaced_word’))**

To replace a word or sentence. Example:

**String.substr(position1,position2)**

String.trim()

Trim removes all space, tab, break space, etc.