Technology Security Analyst
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'
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"
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"
Reverses the order of the elements in an array.
const arr =[1, 2, 3];
arr. reverse();
console. log(arr);
// Output: [3,2,1]
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"
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
const arr = ['x' , 'y', 'z'];
console. log(Arr. indexOf('y'));
// Output: 1
console. log(Arr. indexOf('w'));
// Output: -1
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"