10 JavaScript concepts which must be known for beginners

Nahid Ahmed
3 min readMay 5, 2021

JavaScript, which we are known as JS is a lightweight, interpreted & prototype-based, multi-paradigm, dynamic scripting language. Today I will explain 10 basic concepts of JavaScript.

1. String : String is a collection of characters. The string object used to manipulate a sequence of characters. Mainly string is a ward or sentence. When we need to write a sentence we need strings which are mainly a collection of some words.

Example :const myName = “My Name is Farhan”console.log(myName) //hare myName is a String

2. Number : Number is a primitive number object. The number object used to manipulate numbers.

Example :const myAge = 20console.log(myAge) //hare myAge is a Number

3. Object : Most of the time one variable have so properties. But we can not set more properties at a time. Using objects we can do it so easily. The object gives us to set more properties.

Example :const myDetails = {firstName: ’Farhan’,LastName: ’Nahid’,age: 20,fevColor: ‘Black’,dream: ‘Web Developer’}// we can understand now by using objects how easy we pass some information.

4. Array : Array is a collection of so many objects. You know object have so many properties. But sometimes you need some objects at a time. In this situation we need to declare an array.

Example :const myFriends = [{name : ‘friend1’, salary : 1000, number : 01823XXXXXXX},{name : ‘friend2’, salary : 1100, number : 01364XXXXXXX},{name : ‘friend3’, salary : 1200, number : 01976XXXXXXX},]// Now we can understand how easily we can found particular details of my friends.

5. IndexOf: Sometimes we need a find an array element position. If the array is small we can find it so easily. But in real-time applications, our array is too big. So is it so complicated for us to find the index number off the element? Using an index of we can solve this problem so easily. If the element is in the array it will give us the number. But if you search for a wrong element that does not exist in the array it will give us -1. If the same element is two or above times in the array it always shows the first element. By using the start position parameter you can find another one.

Example :const myHobby = [ ‘gamming’, ‘codding’, ‘playing’, ‘napping’, ‘codding’]*const firstOne = myHobby.indexOf(‘codding’)console.log(firstOne ) // it will be output us 1.**const secondOne= myHobby.indexOf(‘codding’, 2)console.log(secondOne ) // it will be output us 4. Because we say start from array two number index.***const notInArray = myHobby.indexOf(‘reading’)console.log(notInArray) // it will be output us -1.

6. lastIndexOf: lastIndexof is almost a similar kind of indexOf. But the difference is it count the index position from the last index of the array. Except this, it is a smiler kind of indexOf.

Example :const myHobby = [ ‘gamming’, ‘codding’ ‘playing’, ‘napping’, ‘codding’]*const lastOne = myHobby.lastIndexOf(‘codding’)console.log(lastOne) // it will be output us 4.**const firstOne= myHobby.lastIndexOf(‘codding’, 1)console.log(firstOne) // it will be output us 1.***const notInArray = myHobby.lastIndexOf(‘reading’)console.log(notInArray) // it will be output us -1.

7. toLowerCase: toLoweCase is a method where we can convert a string into a lowerCase. If you need to organize your string in lowerCase you can use it.

Example :FARHAN.toLowerCase() //it will be show us farhan

8. toUpperCase: toUpperCase is a method where we can convert a string into an upperCase. If you need to organize your string in upperCase you can use it.

Example :farhan.toUpperCase() //it will be show us FARHAN

9. Math.ceil: Math.ceil is a function. if the number is in float type By using this function the number will be nearest upper value.

Example :const ceilNumber = Math.ceil(58.01)console.log(ceilNumber)//it will be output us 59

10. Math.floor: Math.floor is a function. if the number is in float type by using this function the number will be nearest lower value.

Example :const floorNumber = Math.floor(58.99)console.log(floorNumber)//it will be output us 58

--

--

Nahid Ahmed

I am a Junior MERN Stack Developer. I know Basic Html5, CSS3, Javascript, React, Node, Express, MongoDB, Firebase Authentication