10 Things You Must Know In JavaScript

JavaScript essential

Ranok Raihan
2 min readMay 7, 2021

There are tons of thing in JavaScript you have to learn. you will need all . but these 10 fundamental topic are very important for you if you want to be a JavaScript developer. lets get started.

  1. string.replace()

string.replace is a method which can replace a particular part of that sting or the entire string. It takes two parameters. first one is which part should be replaced and that part will be replaced by the second parameter.

2. string.indexOf()

sometime we need to know the index of a character in a string. we van do that with the string.indexOf() method. it takes one parameter. that is which character you want to find the index.

3. string.toUpperCase()

this method will make all the character to uppercase in a string.

const testString = 'my name is khan and I am not a terorist';console.log(testString.toUpperCase());//possible output:
//MY NAME IS KHAN AND I AM NOT A TERORIST

4. string.toLowerCase()

If you need to make all the character to lower case in a string this method will help you. It will make all the character to lowercase .

const testString ='MY NAME IS KHAN AND I AM NOT A TERORIST';console.log(testString.toLowerCase());//possible output:  my name is khan and I am not a terorist'

5. Math.random()

what if we need a random number every time? well Math.random will do that for you. It generates random number betwen 0 and 1.

console.log(Math.random())//this will console log a random number like 0.2098407151156534

6. Math.floor()

The Math.floor() function returns the largest integer less than or equal to a given number.

console.log(Math.floor(30.445))
//output: 30
console.log(Math.floor(345.0014))
//output: 345

7. string.trim()

this method removes white spaces form both side of the string. it can be used in form validation.

const name = '      ranok raihan        ';
console.log(name)
//output: ranok raihan
console.log(name.trim());
//output:ranok raihan

8. array.length

array means collection. it can be collection of numbers, string, objects, and another arrays etc. array.length returns how many items in that array.

const students = ['rashed', 'parvej', 'milon', 'Jabbar', 'Morshed']console.log(students.length);//output:6

9.array.push()

array.push() is used for adding a item to an array. this method add that item to the last of the array.

const students = ['rashed', 'parvej', 'milon', 'Jabbar', 'Morshed']console.log(students);//output: ['rashed', 'parvej', 'milon', 'Jabbar', 'Morshed']students.push('Jamal')console.log(students);//output: [ 'rashed', 'parvej', 'milon', 'Jabbar', 'Morshed', 'Jamal' ]

10 array.pop

array.pop() removes the the last item from the array.

const students = ['rashed', 'parvej', 'milon', 'Jabbar', 'Morshed']console.log(students);//output: ['rashed', 'parvej', 'milon', 'Jabbar', 'Morshed']students.pop()console.log(students);//output: [ 'rashed', 'parvej', 'milon', 'Jabbar']

these were the 10 fundamental thins about js. thank you for reading my blog.

--

--