Necessary javascript math, number,string methods

3 min readMay 5, 2021

The string is a very powerful fundamental functional datatype in programming. The string is a sequence of is used to represent the text form rather than javascript, various string methods are used which make the developer’s life easier. some of the powerful javascript methods are given below:

1.charAt(): The charAt() method return individual characters of a returns a new takes an index as a parameter. if there is no index is provided as a parameter then the default value is 0.charAt() returns a string representing the character at the specific index. if the supplied index is out of range then javascript returns an empty value.

Syntax: charAT(index)


const name = “sama”;

const index = 3;


//expected value ‘a’

2.concat():The concat() method concatenates two different string into a new one.It took one or more strings as argument and returns a new does not change or effect the original just concates the string.if the passed arguments are not the string type concat() method convert them into string type and concates them.

Syntax:concat(str) or concat(str1,str2)


const firstName = “khadiza”;

const lastName = “sama”

console.log(firstName.concat(“ “,lastName);

//expected output khadiza sama

3.slice():slice() method took a portion of string and return it into new does not change or affect the original take two parameter as is the begin index and other is end index.the end index is optional.if the parameter is negative the position is counted from the end of the string.

Syntax:slice(begin index,end index)


const name = “khadiza morioum sama”

const newName = name.slice(8,-4)


//expected output morioum

NUMBER: the number is a primitive data type of javascript programming. Basically, it defines the number type value such as decimal, integer, float, etc. there are some methods of number. some of them are given below:

1.isNAN():isNAN() method is used to determine whether a value is not a number or not. it returns true or false as output. if the given value is NAN this function returns true otherwise false. the isNAN() function converts the tested value to a number, then tests it.


2.parseFloat():parseFloat() is a method that parses string from an argument and returns it in a floating number. it took string as a parameter.if the number cannot be converted it returns a NAN.



parseFloat(“45”) ;

//expected value 45

3.parseInt():parseInt() is a method that parses a string from an argument and returns it in a whole number. spaces are allowed but only the first number is took string as a parameter. if the argument is not a string then it can be converted into a string using tostring() method. if the number cannot be converted it returns a NAN.

Syntax: number.parseInt(string)



//expected value 50

MATH: It allows users to perform mathematical operations on numbers. it's not a functional object. it's not also a constructor works with numbers. the are some methods of math. some of them are given below:

1.Math.abs():the abs() method returns a absolute value of a does not matter if the passed value inside the abs() method is negative or always returns the absolute value. if the passed value is null then it returns NAN.

Syntax: math.abs(x)



//expected value 9


//expected value NAN

2.Math.ceil():this function always returns a value that is rounded up to its nearest largest integer.if the passed value is null then I return does not give NAN error.

Syntax: Math.ceil(x)



//expected value 6

3.Math.round():this function take a floating point number as parameter and return it as nearest integer.round() is a static method of math.

Syntax: Math.round(x);



//expected value 6

4.Math.min(): this method returns the number with the lowest value. this is a static method. this takes numbers as parameters. if the parameter is not a number it converted it into a number but if it cant be converted then this method returns NAN.



const a=4 ;

const b= 7;

const c = Math.min(a,b);

//expected value of c is 4;

this list covered some of javascript string,number and math methods.however many of other methods are not covered in this list such as indexOf,lastIndexOf,substr,math.floor,etc.

Hope you have enjoyed reading this article and found this article helpful.if you have enjoyed this then follow me on LinkedIn.