Top 10 Javascript Method

Jahid Hasan
2 min readMay 5, 2021

Article: 01

Object

replace()
replace method recive 2 parameter replace(‘text1’, ‘text2’). replace method find text1 paremeter from object and replace by text2 paremeter.
const sentence = ‘web developer jurney is easy’
console.log(sentence.replace(‘easy’, ‘hard’)) outpot : web…is hard

Article: 02

slice() method
slice method recive 1 or 2 number parameter slice(4) / slice(2,7) and cut a section from string without change orginal string

const str = ‘hi, i am a junior web developer’;
console.log(str.slice(3,17)) outpot: i am a junior

Article: 03

split() method
split method cut a sentence with a specific word.

const str = ‘Hi i Am a web developer’;
const search= str.split(‘ ‘);
console.log(search[1]); outpot: developer

Article: 04

trim()

trim method remove space Tab from both side of a string.
const srt = “ ‘Hello World’ “;
console.log(str.trim()); outpot: “‘Hello world’”

Math

Article: 05

Math.abs() function alawes return absolute value. if one value is possetive its return positive value and if one value is negative its ignore it
console.log(Math.abs(7–9)) outpot : 2

Article : 06

Math.max()

Math.max() function always return larget number from input parameter.
console.log(Math.max(1,2,3,4,9,7,8,5)); outpot : 9

Array

Article: 07

array concat() method marge 2 or 2+ array, And create a new array.
const array1 = [‘jahid’, ‘hasan’];
const array2 = [‘niloy’, ‘sojib’];
console.log(array2.concat(array1)); Outpot: [ ‘niloy’, ‘sojib’, ‘jahid’, ‘hasan’ ]

Article: 08

array every() method check all array number and check condition. and return bollean value.
const value = allNumber => allNumber < 40;
const array = [1,30,28,25,31,35,27];
console.log(array.every(value)) outpot : true

Article : 09

array sort() method compaire with first number or string first latter. and return value
const latter = [‘Apple’,’cat’,’bat’,’doll’]
console.log(latter.sort()); outpot : [ ‘Apple’, ‘bat’, ‘cat’, ‘doll’ ]

Article: 10

array pop() method remove last array item from array. and create new array and return it.
const latter = [‘a’,’b’,’c’,’d’,’e’]
console.log(latter.pop()) Outpot : e
and new array [‘a’,’b’,’c’,’d’]

--

--