JavaScript intermediate concepts

Syum Akhlaque
2 min readNov 5, 2020

I will discuss hare some JavaScript intermediate features

  1. Truthy vs falsie
    Its a very confusing issue to differentiate between truthy and falsie value in JavaScript. Lets discuss little of them.
    Number: In JavaScript without 0 [‘zero’] any positive or negative number consider as true value.
    String: In terms of string if string value is empty (‘’) then you got the value false otherwise the value will be true.
    Undefined: Any undefined value returns flase.
    Null : Null returns false.
    NaN: Nan (not a number) is a false value.
  2. Null VS Undefined
    If you declare a variable bot not set it’s value then you get undefined
    If you declare a function but don’t return something then when called this function get the value undefined
    If you want to get a property of an object which is not set, then you will get undefined.
    if you set something value as Null only then you get the Null
  3. Double equal vs triple equal
    Double equal compare weather values are same or not but it’s don’t check the type of these value.
    Triple equal check the values with the type of values.
  4. Arrow Function: Arrow function is a very interesting function. It make the function smaller that looks very good.
fuction box ={ 
//Normal function
}
box =>{
//arrow Function
}

5. Array Map:
To get the concept easily you can consider map as a for loop. What does a for loop do? it returns all element conditionally of an array or object. Map do the same in very short way.
let brothers = ['syum', 'tasin','sakib']
brothers.map(element => console.log(element, index, arr)
// it return all brother name with index number along with full array

6. Filter:
method we ca filter an item from an array
let number = [4,5,6,7,10,15,19]
names.find(num=> console.log(num > 10)
// output: 15,19 hare filter this numbers which are greater then 10

7. Find: Find is a another interesting method. Hare is a little similarity with filter but it returns only one item. If we apply find method in previous array which is declared in filter section we will get only 15 as output.

8. Closure: Suppose there is a function that return another function and the second function return something. when we called the function this makes a closed environment. Its called closure.

9. Scope: Sometimes new developers are getting so confused with scope or block scope. When a variable declared between curly bracket it make a block scope you cannot access it from outside it . Other variable are in global scope, You can access it from anywhere

10. Array Sum:

const tickets=[32,42,52,23,23,33,50,43];function getArraySum(tickets){
let sum = 0;
for(let i=0; i<tickets.length; i++){
let add= sum+ tickets[i];
sum=add;
}
return sum;
}
console.log(getArraySum) // returns ticket sum

--

--

Syum Akhlaque
0 Followers

MERN Stack Developer. From Cumilla, Bangladesh.