Basic JavaScript QA

Minhajul Abedin Rahat
4 min readMay 8, 2021

1.Truthy & Falsy

Let’s see which things are considered as true & which are considered as false in JavaScript.

We know that when the first condition fulfills its criteria it will go inside the if block that means it’s true. We can see that in our code the first condition is true. Without that

In JavaScript without 0 any kind of number if-else consume it as true. Any kind of string also true by default except the empty string “” empty string is falsy.

Undefined by default false.

There are some example of truthy and falsy

List of Truthy : ‘0’ it's not 0, this is side a string that’s, white space string “ ”, [], {}, “false”, truth

List of Falsy : 0, “”, Undefined, null, NAN, false.

2. Null

Null means not existing. Or we can also say that once upon a time there is value, but now it had been empty.

3. Undefined

Undefined variables are those that are declared in the program but have not been given any value. If the program tries to read the value of an undefined variable, an undefined value is returned.

4.Clouser

Let’s try to make it easy to understand with an example suppose two friend susmoy & alif went to the restaurant they order one bowl of beef curry. The waiter now start to serve at first alif waiter serve 1 piece beef to him then serve susmoy 2 pieces of beef we can see that the beef cooked from the same kitchen and serve from the same bowl but when it served its count individually that who takes how many piece individuals that is the closed environment.

In the same way when inside a function there another function that exists & once it is called by x then it will count this way count call me 1 time & then Y calls that function 2 time it will count that Y call me 2 times. Again X calls the function it will count that X calls him 2 times previous 1 & right now 1 total 2.

5.Scopes

The scope of a variable is the region of your program in which it is defined. JavaScript variable will have only two scopes.

Global Scope

Global scope means that if you declare any variable outside of any block, then you can access that variable from anywhere in your JS code.

Local Scope

Local scope means if you declare any variable inside any function, you can’t use that variable outside that function. If you want to use that local variable, you have to use it inside the function.

6.JavaScript’s Data Type

I.Number

II.String

III.Boolean

IV.Object

V.Undefined

7. Double Equal(==) vs Triple Equal (===)

When you use double equal in JavaScript it will check either that two values are equal or not. But when you use triple equal in JS it will check not only check that values are equal or not it also check that two value’s data type also equal or not.

8.Call()

In a call method, we can send arguments with the object.

9.Apply()

Apply method is similar to the call method. But the difference is when we send arguments with the object in the apply method we have to send the arguments inside an array.

10.JavaScript

JavaScript is a single thread language that reads the code & executes the code in a synchronized way. Like in a restaurant there are two customer waiter go to the first one and take order go to the kitchen passed the order to the chief & wait for the food at that meantime the second customer is waiting after complete the food waiter serve that the first customer after that he goes to the second customer to take the order.

--

--

Minhajul Abedin Rahat
0 Followers

I'm so ambitious & determined about my goal & strongly believes in positivity.