- split() method
const str = “hey, today is a pretty day.”
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
// 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:
// log result will true
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]]]];
//expected output is const arry2 = [1,3,4,[43,53,62,[46,57 ,[41,64]]]];
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 );
//expeted result will 641
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.
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)
//now i will not say .. try it and show what will resul
- 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()
//then it will return a number. fun fact i can't tell it wich number will return this method.
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.
Thank You for staying with me