DEV Community

Cover image for Most 10 common JavaScript questions.
Md Nayem Hossain
Md Nayem Hossain

Posted on

Most 10 common JavaScript questions.

Truthy and Falsy values:

Truthy and falsely value is Boolean context. Mainly it is used if and else condition in javaScript. Some rules have if and else condition.
Some falsy values are;

  • false
  • 0 (zero)
  • '' or "" (empty string)
  • null *undefined
  • NaN

Otherwise, every value is truthy values. Some truthy values are;

  • '0' (a string containing a single zero)
  • 'false' (a string containing the text “false”)
  • {} (an empty object)
  • function(){} (an “empty” function)

Null Vs Undefined:

The null and undefined value is mainly empty values.
Null: Null in JavaScript is an assignment value. You can assign it to a variable.
Undefined: It means a variable declared, but no value has been assigned a value.

Double equal(==) and Triple equal (===):

The double and triple equal main difference triple equal compare to other values very strictly but double equal not strictly compare.

Scope:

Scope determines the visibility or accessibility of a variable or other resource in the area of your code. Many types of scope. There are;

  • Global scope
  • Block scope. # Hoisting: Hoisting is a JavaScript mechanism where variables and function declarations are moved to the top of their scope before code execution.

Closure:

If there is another function inside a function, then a close environment is created when that function is returned. This close environment process is called closure.

This Keyword:

The JavaScript this keyword refers to the object it belongs to.

  • this refers to the owner object.
  • this refers to the global object.
  • this refers to the global object.
  • this refers to the call() and apply() method

Global Variable:

A variable declared outside a function becomes global. A global variable has global scope. All scripts and functions on a web page can access it.

Event Bubble:

Event bubbling is a term you might have come across on your JavaScript travels. It relates to the order in which event handlers are called when one element is nested inside a second element, and both elements have registered a listener for the same event.

Arrow function:

The arrow function is shorter syntax in the main function. It uses to start when the javaScript es6 version was coming. It is most useful to every JavaScript developer.

What is DOM?

The Document Object Model (DOM) is a programming interface for HTML and XML documents. It represents the page so that programs can change the document structure, style, and content. The DOM represents the document as nodes and objects. That way, programming languages can connect to the page.

Top comments (0)