Must Know JavaScript Methods

Must Know JavaScript Methods
Techiio-author
Written by Nilima PaulJanuary 21, 2022
3 min read
JavaScript
5 VIEWS 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 5 VIEWS SHARE
Techiio-author
Nilima Paul

Technology Security Analyst

In this blog post. we will discuss Must Know JavaScript Methods.

toString9

Returns a string representing the specified object.

const arr = [1, 2, 'a', 'b'];
let num = 5;
console. log(arr. toString());
// Output: "1, 2, a, b"
console . log(num. toString());
// Output: "5'

join

Returns a new string by concatenating all of the elements in an array.

const el = ['Fire' , 'Air', "Water"];
console.log(el.join());
// Output: "Fire, Air, water"
console. log(el. join (''));
// Output "FireAirWater"
console. log(el. join('-'));
// Output: "Fire-Air-Water"

push

Add one or more elements to the end of an array.

const arr = ['a', 'b'];
arr. push('c');
console. log(arr);
// Output: ["a", "b", "c"]
console. log(arr. push('d'));
// Output: "d"

reverse

Reverses the order of the elements in an array.

const arr =[1, 2, 3];
arr. reverse();
console. log(arr);
// Output: [3,2,1]

pop

Returns the last element from an array.

const arr = ['a', 'b', 'c'];
arr. pop();
console. log (arr);
// Output: ["a", "b"]
console. log(arr. pop());
// Output: "b"

search

Searches a string for a specified value and returns the position of the match.

let txt = "This is easy";
console. log (txt. search ('easy'));
// Output: 8

indexOf

const arr = ['x' , 'y', 'z'];
console. log(Arr. indexOf('y'));
// Output: 1
console. log(Arr. indexOf('w'));
 // Output: -1

replace

Search the array for an element and returns its position.

let txt = "this is easy";
console. log(txt. replace('easy' , 'simple'));
// output: "this is simple"

JavaScipt
reactjs
5 VIEWS 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 5 VIEWS SHARE
Was this blog helpful?
techiio-price-plantechiio-price-plantechiio-price-plantechiio-price-plantechiio-price-plan
You must be Logged in to comment
Code Block
Techiio-logo

Techiio is on the journey to build an ocean of technical knowledge, scouring the emerging stars in process and proffering them to the corporate world.

Follow us on:

Subscribe to get latest updates

You can unsubscribe anytime from getting updates from us
Developed and maintained by Wikiance
Developed and maintained by Wikiance