Semi Post-Mortem of Javascript

Tarequl Islam
5 min readMay 5, 2021

JavaScript is a scripting or programming language that allows you to implement complex features on web pages...
ohhho! enough line for the intro, and you know the line already in Javascript main site :P
so we are gonna post mortem Javascript before we into it

“‘We have to see how many type Javascript especially have, Let's deep dive-
JavaScript’s types are:

Number

String

Boolean

Function

Object

Symbol

First play with some numbers, Yeah!

1.Generate Random integer number:
Random numbers are basically used in OTP, Ludo, and other staff. Let's see how:

if you want to generate some random number, you should call Math.random() method. Basically, this method doesn't pass any argument.
This method always returns 0 or 1 as a random number. Let's see

console.log(Math.random());
output: 0.35458322191602965

And if you try this again with the same method, the result will be like:

Result: 0.0822479194440513

Now you worry because you don't want a decimal number, you need an integer number for roll call or propose your secret crush number within 6 or want to play Ludo.
So, if you want the number within 6, multiply with this method to 6. cool, haah!

console.log(Math.random() * 6);
Result: 1.8561552787008955

Again you got the result with decimal, and now it turns into a serious issue. No matter what, now you have to have an integer number. Just pass your full method as a parameter of Math.floor.
run your code

console.log(Math.floor(Math.random() * 6));
Result: 4

2.SLICE A STRING, SLICE() METHOD:
Now we are gonna talk about Slicing. The Slice() method extracts a string section, returns it as a new string, and doesn't impact the main string.

In this section, we need two number parameters. first one for slicing the beginning part and the other numbers for the end of the section

“Result: Ananta, Catch”

#note1: Blank space also an index, and the number starts with 0,1,2 like this.
#note2: Negative parameter count as End of string to the starting point of index

3. ForEach() Method
You want to provide the same superpower to all DC and MARVEL Hero, you call them and open and write some code on VsCode editor, and Booooooom! they all got flying Power from Super Men :D

And the result is. Now you have to carry always an umbrella :P

Now SuperMan transfer power to Batman, Now Batman can fly
Now SuperMan transfer power to Hulk, Now Hulk can fly
Now SuperMan transfer power to Ironman, Now Ironman can fly
Now SuperMan transfer power to Aquaman, Now Aquaman can fly

4.Push() data in an array, Push Method
You are in University, and now you feel like a hero. Now, this is the time to impress the opposite gender and push her to fall in your love.
Here is a similar push() method. You can get some data in your array.
let's jump into the code

Result is : [ ‘Ketty Perry’, ‘Ariana Grande’, ‘Nicky Minaj’, ‘Jennifer Lofez’ ]

#Note: When you add some data by push()method, It always adds in the last position of an array

5.Pop() Method
So after few days, you notice your crush didn’t give you enough expression, and she always wants to ignore, and you decide you have to pop her out from the crush list,

so this is like pop() method. You can remove data from an array by pop()

output: [ ‘Ketty Perry’, ‘Ariana Grande’ ]

#Note: there is some problem when you remove by pop, its always remove the last data in your array

6.String.prototype.toUpperCase()
When you are in class 6, and your crush is an SSC candidate, you always want to be promoted auto the upper class and make a wish that the next morning when you woke up, you will be bigger and promoted to the upper class.

So, It is another simple and useful method of JavaScript that is used to convert the letter of a string from a small letter to a capital letter. In other words, turns the string from LowerCase to UpperCase as like your dream.

Let’s see a simple example.

let example = “makemebigger!”;
console.log(example.toUpperCase());
Output: MAKEMEBIGGER!

7.Map()
The map() collection of elements where each element is stored as a key, value pairs.

Example:

const number = [4, 8, 12, 24, 48];
const newNumber = number.map(x => x * 2);
console.log(“New Number is: “,newNumber);
output: New Number is: [ 8, 16, 24, 48, 96 ]

8.isNaN() Method

The isNaN() function determines whether a value is an illegal number (Not-a-Number).

Output: NaN
Output: The number NaN

9.Array.filter():

If you are working with data, many times you will need to filter it. Array.filter method does the task for you.

const numbers = [1,2,3,4,6,7,8,9,12]
const odd = numbers.filter(num => num % 2 === !0)
console.log(odd) // [1,3,7,9]

The above code block takes an array and filter output for odd numbers. We can take use another kind of filter too.

const productsPrice = [25,50,75,48,45,100,214,254]
const cheapProducts = productsPrice.filter(price => price > 100)
console.log(cheapProducts) // [25,50,75,48,45]

Here use an array filter to get the prices below 100.

--

--