10 basic JavaScript methods you should know as a developer.

In JavaScript method is a function like other programming languages. Here are a few basic JavaScript methods every developer should know:

Array.prototype.push()

let numbers = [5, 10, 20];
let item = 30;
numbers.push(item); // numbers will be [5, 10, 20, 30]

Array.prototype.pop()

let language = ['C', 'C++', 'JavaScript', 'Python'];
console.log(language.pop()); << Python

// language becomes ['C', 'C++', 'JavaScript']

Array.prototype.shift()

let language = ['C', 'C++', 'JavaScript', 'Python'];
console.log(language.shift()); << C

// language becomes ['C++', 'JavaScript', 'Python']

Array.prototype.indexOf()

const friends = ['Abdul', 'Hamid', 'Rayhan', 'Maksud'];
console.log(friends.indexOf('Rayhan')); << 2
console.log(friends.indexOf('Lutfar')); << -1

Note that indexOf() is case sensitive.

const friends = ['Abdul', 'Hamid', 'Rayhan', 'Maksud'];
console.log(friends.indexOf('rayhan')); << -1

Math.abs()

console.log(Math.abs(-10))     << 10
console.log(Math.abs(5)) << 5

Math.max()

const numbers = [5, 2, 10, 4, 30, 1, 7];
console.log(Math.max(...numbers)); << 30

Math.min()

const numbers = [5, 2, 10, 4, 30, 1, 7];
console.log(Math.min(...numbers)); << 1

String.protopype.charAt()

const sentence = "There it goes";
let index = 3;
console.log(sentence.charAt(index)); << "r";
index = 50;
console.log(sentence.charAt(index)); << "";

String.protopype.toLowerCase()

let sentence = "There it goes";
console.log(number.toLowerCase()); << "there it goes"

String.protopype.toUpperCase()

let sentence = "There it goes";
console.log(number.toLowerCase()); << "THERE IT GOES"

These are some basic methods in JavaScript. Hope this will help you sometimes. Thank you for reading.