COVER

Step Forward to Javascript

Sayeed Sayem
Nov 5, 2020 · 7 min read

‘Zero’! Truthy or Falsy?

Think about a number. Is ‘zero’ a truthy value? Generally, you can say zero is a number and as a number, it should be truthy. But you're wrong. Zero is a falsy value. For example:

“‘ vs “ “

First, let me show you a code example:

Some other Falsy Values

  • undefined: undefined is a falsy value. When you declare a variable but didn’t set any value or forgot to declare then it’ll be undefined. Not only that, you may get undefined in many other ways. We’ll talk about them too later.
  • null: null is also a falsy value as undefined. Null means empty and an empty variable cannot explain anything, so null is falsy too.
  • NaN: NaN stands for ‘Not a Number’. Sometimes you'll find this kind of error while working with numbers. NaN is a falsy value.
  • False: false itself a falsy value. Because false is false. It’s a boolean type variable. I think no more explanation needed. But if you put false inside quotes like zero inside quotes it’ll be truthy. Because it’ll be string then, no more boolean type.

undefined vs null

  • If you declare a variable without value and try to read it’s value then you'll get undefined;
  • If you call a function in which there is no return statement in it you’ll get undefined;
  • If you call a function that has one or more parameters but you don’t put any parameter or forgot to put then you’ll get undefined;
  • If you try to read a property of an object or array but the proper is not declared you’ll get undefined;
  • If you're a monkey type developer and declare a variable with property undefined like so, const a = undefined; you'll get undefined;
  • The only way to get null in return is to declare a variable with the null property;

Magic between ‘==’ and ‘===’

Before explaining, I wanna show you some code:

map find filter

  1. map: map is a method of the array in javascript. By using map you can read every element of an array and you can use them like this

Scope

In general, scope means field or territory. Similarly, in javascript scope means an area of a variable. This means, how distant a variable can cover. If you declare any variable outside block-level element (function, if, else, etc) you can access them from anywhere. For example,

Duplicate Numbers Removal

Suppose you're a teacher, you wanna gift your students a pen and asked them to give their id’s in a paper. But some of your monkey type students give their twice or three times or even more. So how can you define them? If you're a javascript programmer then it’s very easy. How? let me show you how.

Bind

Bind is an interesting thing in javascript. Suppose, you need a calculator for your exam and you don’t have one or lost it. But your friend has a calculator and you can borrow it. Exactly the same thing happens when you use the bind keyword. If you don’t understand let me show you an example:

Call and Apply

First I wanna show you something, just see and try to relate with the example provided up:

The Startup

Get smarter at building your thing. Join The Startup’s +731K followers.

The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +731K followers.

Sayeed Sayem

Written by

AssalamuAlaikum. I'm Abu Sayed, a front-end web developer. My Github (https://github.com/ahmedmusa995). My Website( https://sayeedsayem.netlify.app)

The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +731K followers.