Some important topic for a JavaScript developer

Fahad Ezahar
2 min readNov 5, 2020

Truthy and Falsy:

Do you know that Javascript has a set of pre-defined falsy values? Truthy and Falsy values are the non-boolean values that are coerced to true or false when performing certain operations.

The following are the only six values that are considered as falsy values in JavaScript.

· false

· undefined

· null

· “”

· NaN

· 0

Anything that is not present in the above list is considered as truthy. So if you are writing an if condition, you don’t need to check if something is empty or undefined or null. It will automatically be considered as false.

Differences between null and undefined:

When you define a variable but not assign a value to it, it automatically puts a placeholder which is called undefined so you don’t have do it manually, JavaScript does it for you.

Null means an empty or non-existent value.

Null is assigned, and explicitly means nothing. While undefined typically means a variable has been declared but not defined yet.

Double Equals Vs Triple Equals:

Double Equals:
It just looks for value. Double does type coercion which means it tries to convert them into common type before comparing.

Triple Equals:
It looks for both types and value.

Map:

Map takes an array of elements and returns a new array of elements transformed by the callback.

Filter:

Takes the array and returns a new array that only contains the elements that match some condition.

Global scope:

A variable exists inside or outside a block. If a variable is declared outside all functions or curly braces ({}), it exists in the global scope. The global variables can be accessed by any line of code in the program, including inside blocks.

Closure:

A closure is a stateful function that is returned by another function. It acts as a container to remember variables and parameters from its parent scope even if the parent function has finished executing.

Bind Method:

The ‘bind()’ method creates a new function where ‘this’ refers to the parameter in the parenthesis. the ‘bind()’ method enables us to call a function with a specified ‘this’ value.

Call and Apply Methods:

Similar but slightly different usage provides the ‘call ()’ and ‘apply ()’ methods which also belong to the Function. When using the ‘apply ()’ function the parameter must be placed in an array. ‘call ()’ accepts an argument list.

Window:

Window is a global object of JavaScript while document is a property of the window object.

Window includes the following and more:

· Global functions

· Location

· History

· Web Components

· setTimeout

· XML-Http Request

· Console

· LocalStorage

Document includes the following:

· DOM (Document Object Model) of the page

· Methods that traverse the DOM

--

--

Fahad Ezahar
0 Followers

I continue my learning on the challenges of becoming a professional web developer.