For developed in Javascript, methods that developer needs to know

Asfakur Rahman
3 min readMay 5, 2021

JavaScript is a text-based programming language that used for both on the client-side and server-side, that allows user to make web pages more interactive. Where HTML and CSS are languages that give structure and style to web pages, JavaScript gives web pages interactive elements that engage a user to develop more and more. Common examples of JavaScript that people might use every day in the search bar on Facebook, Youtube, or Twitter.

Here are some of the built-in function that needs to know for a Javascript developer:

String:

  1. String.toLowerCase():

This function is used to convert a string from uppercase to lowercase. String value doesn’t affect but it’s all uppercase value converted to lowercase.

Example:

const topic = 'I LIVED IN DHAKA';
console.log(topic.toLowerCase()); //output: 'i lived in dhaka'

2. String.toUpperCase():

This function is used to convert a string from lowercase to uppercase. String value doesn’t affect but it’s all lowercase value converted to uppercase.

Example:

const topic1 = 'my name is khan';
console.log(topic1.toUpperCase()); //output: 'MY NAME IS KHAN'

3. String.toString():

This function is basically use for convert one type of string format to another type of string format.

Example:

const strObject = new String('afternoon');console.log(strObject);
//output: String { "afternoon" }
console.log(strObject.toString());
//output: "afternoon"

4. String.replace():

String.replace method is used toreplace the specific part or all part of the string. This replacement changes the pattern of the string.

Example:

let var= /earth;
let var1= 'Earth are round, and earth are big.';
let newVar = str.replace(var, 'moon');
console.log(newVar); //output: moon are round, and moon are big.

5.String.slice():

This method unzips a part of a string and returns it as a new string, which is the modified version of the original string.

Example:

let str1 = 'Good morning everyone', // the length is 21.
str2 = str1.slice(2, 11),
console.log(str2) //output: od morning

6. String.concat():

This concat() method adding the string that is used as arguments with the calling string and returns as a new string.

Example:

let var = 'Hi...'
console.log(var.concat('Sayem', ' How are you dude?'))
// Hi...Sayem, How are you dude?

Math:

  1. Math.abs():

This method returns the absolute value of a number. For example, it returns y if y is positive or zero, and the negation value of y if y is negative.

Example:

Math.abs('-5');     // output: 5
Math.abs(-6); // output: 6
Math.abs(null); // output: 0
Math.abs(''); // output: 0
Math.abs([]); // output: 0
Math.abs([8]); // output: 8
Math.abs([5,6]); // output: NaN
Math.abs({}); // output: NaN
Math.abs('hello'); // output: NaN
Math.abs(); // output: NaN

2. Math.ceil():

This method is used for rounded up a number to the next largest integer value.

Example:

Math.ceil(.67);    //output: 1
Math.ceil(5); //output: 5
Math.ceil(9.12); //output: 10
Math.ceil(-0.05); //output: -0
Math.ceil(-7); //output: -7
Math.ceil(-2.004); //output: -2

3. Math.floor():

This function is used for returns the largest integer less than or equal to a given number inside Math.floor() function.

Example:

Math.floor( 56.5);  // output:  56
Math.floor( 95.15); //output: 95
Math.floor(3); //output: 3
Math.floor(-37.96); //output: -37

4. Math.max():

This method is used to return a maximum value from the given 2 or more numbers inside Math.max() function.

Example:

Math.max(40, 65);   //output:  65
Math.max(-60, -43); //output: -4

5. Math.min():

This method is used to return a minimum value from the given 2 or more numbers inside Math.min() function.

Example:

var m = 36, n= -60;
var o = Math.min(m, n);
//output: -60

Array:

  1. Array.pop():

This function is removing the last element or string from an array & after that, there is a change in the length of an array.

Example:

var myFriend = ['anika', 'faisal', 'tania', 'shawon'];

var poppedUp = myFriend.pop();

console.log(myFriend); //output: ['anika', 'faisal', 'tania' ]

console.log(poppedUp); //output: 'shawon'

2. Array.push():

This method is the opposite of the Array.pop(), it added one or more elements at the end of the array and constructed a new array with a new length.

Example:

let name = ['maiesha', 'niloy']
let allName= name.push('elma', 'jihad')

console.log(name) //output: ['maiesha', 'niloy', 'elma', 'jihad']
console.log(allName) //output: 4

3. Array.splice():

This method is basically add elements on the selected index of the array. It inserted on the selected array index and after that it built a new array formation.

Example:

let myCar= ['bmw', 'toyota', 'porsche', 'honda']
let removed = myCar.splice(3, 0, 'hyundai')

//output: myCar is ["bmw", "toyota", "porsche", "hyundai", "honda"]

--

--