JavaScript Interesting String And Array Methods Power

Sreekantaraju
3 min readMay 5, 2021

Interesting javascript string methods Power

  1. concat() Method

concat(): Method:

concat () Method input string arguments and adding arguments return new concat() string arguments. Change original string.

Exemple:

conat str1 = ‘Concat(): Method:

Concat () Method input string arguments and adding arguments return new concat() string arguments. Change orginial string but bo effect.

Exemple:

conat str1 = ‘ Raju’;

concat str2 = ‘ Biswas’;

console.log(str1.concat(‘ ’, str2));

OutPut = ‘’Raju, Biswas’’’;

02. includes() Method.

Includes() is case sensitive, search one string if found within another string, includes return true or false.

Example:

const line = ‘ He goes to school late today.’;

const word = ‘late’;

console.log(`This word ‘’${word}’’ $(sentence.includes(word) ? ‘is’ : ‘is not’} in the sentence `);

output = “The word ‘’late” id on the sentence’’

03. toLowerCase() Method:

toLowerCase() method string calling value convert lower case.

Example:

const lower = ‘Man is Mortal’;

console.log(lower.toLowerCase());

output: ‘’man is mortal’’

O4. toUpperCase() Method:

toUpperCase() method string calling value convert uppercase.

Example:

const upper= ‘Man is Mortal’;

console.log(upper.toUpperCase());

output: ‘’MAN IS MORTAL’’

05. trim() Methods:

trim() methods remove whitespace from start and end both side sentence. if sentence (space, tab, break space etc) remove use trime method.

Example:

sorry space not a write ..

06. trimEnd() Methods:

trimEnd() method remove whitespace from end sentence/right site sentence.if ride site sentence (space, tab, break space etc) remove use trimeEnd method.

Example:

space not count so not write example

07. trimStart() Methods:

trimStart() method remove whitespace from start sentence/left site sentence.if left site sentence (space, tab, break space etc) remove use trimStart method.

Example:

space not count so not write example

Interesting javascript Array methods Power

01. find() Method

find() methods return value of the first matching condition apply an element in the provided array and satisfy testing element. If no value satisfy test function return undefined.

Example:

const array = [‘6’, ‘7’, ‘8’, ‘9’, ‘15’];

const find = array.find(element=> element> 12)

console.log(find)

output: “15”

02. indexOf() Method

indexOf() give return value this array how to search number of element index position number.

Example:

const index = [‘rahim’, ‘korim’, ‘horim’, ‘jorim’];

console.log(index.indexOf(‘horim’)];

output: 2

03. pop() Method

Any array removes the last element that's mean array right-side element remove and change the length of the array.

Example:

const theArray = [‘apple’, ‘ball’, ‘cat’, ‘dog’, ‘egg’];

console.log(theArry.pop());
output: “egg”

console.log(theArry);
output: Array [‘apple’, ‘ball’, ‘cat’, ‘dog’]

03. push() Method

push() method adds one more element to the end side array. that's means rode side array and changed array length.

Example:

const abc= [‘apple’, ‘ball’, ‘cat’];

const abcd = abc.push(‘dog’);

console.log(abcd);
output: Array [‘apple’, ‘ball’, ‘cat’, ‘dog’].

o4. reverse() Method

the reverse() method the first array element becomes the last, and the last array element becomes the first. change array some element index of position.

const abc= [‘apple’, ‘ball’, ‘cat’]

const compile = abc.reverse();

console.log(compile)

output: [‘cat’, ‘ball’, ‘apple’].

THANKYOU .

--

--

Sreekantaraju

I'm a Front-end Developer and Familiar with work's Backend. I enjoy working with Team as a leader or member.I Always learning New technology. I enjoy it.