Javascript Some Core Thing

Rasel Hossain
2 min readMay 8, 2021

Truthy and Falsy values

In javascript, there have two types of boolean value one is Truthy value and the other is a falsy value. when you write if/else statement in any programming language, you expect two value in the if() 1. true 2.false

Truthy values

Here is some truth values example:

if (true)
if ({})
if ([])
if (42)
if ("0")
if ("false")
if (new Date())
if (-42)
if (12n)
if (3.14)
if (-3.14)
if (Infinity)
if (-Infinity)

Falsy values

Here is some falsy values example :

if (false)
if (null)
if (undefined)
if (0)
if (-0)
if (0n)
if (NaN)
if ("")

Null Vs Undefined

When defining a variable but not assign a value to it, it automatically puts a placeholder which is called undefined.

Null means an empty value. when you declare a variable but you do not want to assign a value to it also you want to use it without a return Undefined so you can use Null as a primary value of this variable

Double Equals vs. Triple Equals

In JavaScript, you can test equality in two different ways, one is == and the other is ===
==(double equals) just compare is two values equal or not.

===(triple equals) compare is two value are equal or not also check two value are same data types

Difference Between bind, call, and apply

Call( ): The call() method invokes a function with a given ‘this’ value and arguments provided one by one.

Apply( ): Invokes the function and allows you to pass in arguments as an array.

Bind(): returns a new function, allowing you to pass in an array and any number of arguments.

--

--