Few Introduction With Javascript Fundamental Concept

H. Nazmul Hassan
4 min readMay 5, 2021

javascript is a Programming language. Which language once a time people called it toy language. But that is not still available. Now Javascript is a nonblocking interpreter language. Today We will discuss javascript basic things that you should know as a Web Developer

Javascript is a modern language. So it Has too many methods and utility about String, Array Number, Object-oriented programming also Javascript, And it Has Many more properties.

Javascript String

Javascript has a lot of power of utility with string Such as
But Here I am gonna Talking About the 4 String method Of javascript.
1. Split()
2. Concat()
3. indexOf()
4.includes()

  1. split() method
//Split String 
const str = “hey, today is a pretty day.”
str.split(“ “)
//“hey,todayisaprettyday.”

Because split() method vanish all thing that you put inside the bracket.

2. Concat() method
concat method is added two strings in one. For example, you have three mangoes, and your brother has 2 mangoes. If you add you and your brother mango, then there will 5 mangoes. Like this, you said “my name”, and your brother said “Nazmul” if you add these two lines, their result will “my name Nazmul”. If you not clear, then you try the following code :

const str1 = "I have determined"
const str2 = "to learn Programmin and and to world best"
const totalStr = str1.concat(str2)
console.log(totalStr)
//output will : I have determined I have determined to learn Programmin and and to world best

3. indexOf() method
indexOf() method bear two parameters. indexOf() is a string checker. suppose you have a long string, but you are not sure that is a specific word includes in your string. on that time, the indexOf() method will help you search or find any specific word. Second up, the indexOf() will use any starting point of the string. If it is very long, you don’t want to use the indexOf() method for full string. Then indexOf method will help you by its second parameter. You can follow the following code example

const str = "hello everyone. i Know i am not a good blog writer. but I try my best to explain everything as though you can understand javascript more explicitly";
console.log(str.indexOf("best"));
console.log(str.indexOf("i", 20));
// result will 65, 23

4. includes() method
includes() method same like as indexOf(). just deferent is included () method return true or false value. If any word in your string includes method will return true else false. for example, you can follow the below code:

const str = "hello everyone, you are learing about includes method of javascript"
const result = str.includes("javascript");
console.log(result)
// log result will true

Javascript Array

likes string... Javascript also has the power of the array. Now, we will gonna discuss javascript Array. we will discuss now 3 important things of Javascript Array

  1. Array.flat()
  2. Array.reduce()
  3. Array.map()
  4. Array.slice()
  1. array.flat()
    I think flat is important for a programmer. Arry flat use for decorating an array by sequences. I know you can't understand it. For this, I will show an example here. Before this, I want to say some this. Array flat() method make an array if here stay nesting arry. follow that below code example
const arry2 = [1,3,4,[43,53,62,[46,57 ,[41,64]]]];
console.log(arry2.flat());
//expected output is const arry2 = [1,3,4,[43,53,62,[46,57 ,[41,64]]]];

2.array.reduce()
array. Reduce method is an important utilization of the array. Because this code has been shortened much code. For example, you need a sum of the array's call number, then you know for loop() then what will you do. I am sure you will run for loop through the array, and you will create a variable and store all sum of numbers in an array. But the arry reduce method makes it easy. you can follow the below code example

const arry1 = [2,4,56,6,3,564,6];
const arrySum = arry1.reduce((acc, curr)=> acc+curr );
console.log(arrySum)
//expeted result will 641

3.Array.map()
An important is an array.map() method. it does an abridged version of for loop. It is mostly used for data providing in the dynamic HTML element.

4.Array.slice():

array. Slice () is a more one important thing. Because of Array. Slice () divide a full array to a certain part. You can follow below code example.

const arry1 = [2,4,56,6,3,564,6];
const partOfArry1 = arry1.slice(2,6)
console.log(partOfArry1)
//now i will not say .. try it and show what will resul

Javascript Math

Javascript not only for array or string. You can utilize or calculate more complex math with javascript. Such as plus, minus, times and divide, sin, cos, random number, and many things you can utilize with javascript. So here I will be talking about the 2 javascript Math method.

  1. Math.random()
  2. Math.round()
  1. Math. random
    math. Random () is very useful for the dynamic generating password, any number, .normally, it provides an integer number. When you call it, it will return a number; you will use it by your choice. follow the below code
const myNumber = Math.random()
console.log(myNumber)
//then it will return a number. fun fact i can't tell it wich number will return this method.

2.Math.Round()
Math. round() will return, or if you put any number in the parenthesis of this method, it will make a full digit number. If you put 3.4, then it will return 3, and if you put 3.6, it will return 4. it returns by checking this if it is greater than 0.5; if it were greater than 0.5, it would return the next full digit. Or if it is lower than 0.5, it will return the previous number of your entered number.

for more details, you can follow the world best javascript documentation Mozilla developer network

Thank You for staying with me

--

--

H. Nazmul Hassan

I am a Full Stack web developer Ui designer. As a full stack webdeveloper I work with React js, Node.js , Django, pythone and many other tools and technolgy.