JavaScript Interview Questions You Need To Know — Part III

The final part of a three part JS Interview Question series.

Adi S
Adi S
Jan 8 · 4 min read

Check out the first part here and second part here

Image from Tutorialrepublic


Q: What does the Operator do?

A: This might be easier to look at in code first:

Which expressions are falsy?

Basically the operator (read as Logical AND) finds the first falsy value in the expression and returns it. If it does not find a falsy value it will return the last value in the expression.

So, the first line

console.log(1 && false && {});

returns false because false is the first falsy value in that expression.

The second line

console.log([] && "true" && 1);

does not contain a falsy value and therefore returns the last value in the expression, which is 1.


Q: What are the falsy value types in JS?

A: There are 7 falsy values in JS:

  1. the number
  2. the BigInt
  3. the keyword
  4. the keyword
  5. the number
  6. the boolean
  7. the empty string (equivalent to or )

These will all evaluate to false in conditionals. Also many places will list only 6 falsy values and forget . Additionally the opposite of falsy values are truthy values, which are everything else. For example and are truthy.

*Take your knowledge of loose equality and strict equality from part I to test these out*


Q: Break down the different parts of a URL for me.

A: First, a URL stands for Uniform Resource Locator…in other words, the web address of an online resource, i.e. a web site or document.

The first part of the URL, http or https, is known as the protocol. The protocol determines how your browser communicates with the web server. In this example https is Hypertext Transfer Protocol Secure. https connections are encrypted and more secure than plain http. The scheme is separated by the and starts the domain name. is the domain name or host. This is the web server that data is being requested from. A domain always includes the top-level domain. In this case the top-level domain is other top-level domains are etc.

is the port. The port is like a technical gate that is used to access resources on the web server. If the web server is on a standard port (:80 for http and :443 for https) you will not see it in the URL. Otherwise it is required and it will grant access to the resources on that web server.

is known as the path to the file. It indicates the path to the specific resource on the web server that the client (browser) is asking to access.

are the parameters of the URL. These are basically key value pairs separated by the symbol. Since in this specific URL there is a you can refer to as the query string. Web servers are all unique and handle parameters differently.

is the anchor. Some may call this the fragment identifier. It will always begin with a hash . It is basically an internal page reference. The anchor will bring you to specific location on a webpage. If it is a long webpage maybe it brings you to a specific section or part of the page.

Q: What are the three phases of event propagation?

A: Propagation happens with capturing first then bubbling.

During the capturing phase events propagate from the Window through the DOM tree until it reaches the target node. For example, if you click on a hyperlink it may go from the element, to the element, to the element, to the element that has the link.

Image from Tutorialrepublic

Then after the target element is accessed (in code this would likely be ) the bubbling phase occurs.

Bubbling is the opposite of the capturing phase. During bubbling phase, the event bubbles up DOM tree. So it would go from the target element all the way up to the Window. In our example above, after the hyperlink is clicked it would go from the element that has the link, to the element, to the element, to the element and finally the Window.

*Before modern browsers, there were 3 phases of event propagation. Capturing>Target>Bubbling. In modern browsers the Target phase is not handled separately.*


Q: What will be the output of the following code?

var Food = {
cuisine: 'abc'
var food1 = Object.create(Food);
delete food1.cuisine

…send your answers in the comments! And I’ll post mine there as well 😎

JavaScript in Plain English

Learn the web's most important programming language.

Adi S

Written by

Adi S

JavaScript in Plain English

Learn the web's most important programming language.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade