JavaScript Q&A - Extend Your Knowledge
Written by Ian Elliot   
Tuesday, 02 July 2019

A set of multiple choice JavaScript questions to test (and expand) your knowledge is available on GitHub. The questions range from basic to advanced.

The questions are posted daily on Instagram by Lydia Hallie, who describes herself as a 21 year old software developer in React, Node, GraphQL, and AWS. The idea is that the questions let you test how well you know JavaScript, help you refresh your knowledge a bit, or prepare for your coding interview.

JSlogo

Once a week the GitHub repo is updated with that week's questions. Each question takes the form of a question showing some code, four multiple choice possible answers, and the answer hidden in a collapsed section below the question.

So, for example, one of this week's questions asks:

What's the output of:

function sayHi() {

  console.log(name);
  console.log(age);
  var name = "Lydia";
  let age = 21;
}
sayHi();
And gives you choices of possible answers of:
  • A: Lydia and undefined
  • B: Lydia and ReferenceError
  • C: ReferenceError and 21
  • D: undefined and ReferenceError

The answers are more than just what the correct choice was; in the case of the question above, Hallie says:

Answer: D

 

Within the function, we first declare the name variable with the var keyword. This means that the variable gets hoisted (memory space is set up during the creation phase) with the default value of undefined, until we actually get to the line where we define the variable. We haven't defined the variable yet on the line where we try to log the name variable, so it still holds the value of undefined.

Variables with the let keyword (and const) are hoisted, but unlike var, don't get initialized. They are not accessible before the line we declare (initialize) them. This is called the "temporal dead zone". When we try to access the variables before they are declared, JavaScript throws a ReferenceError.

It's a fun read if you want to stretch your brain and keep your JavaScript skills current.

JSlogo

 

More Information

JavaScript Questions On GitHub

Related Articles

Jobs Need More Than JavaScript

Homepage For JavaScript Standards Launched

Top 10 JavaScript Errors

JavaScript Puzzle - The Too Tidy Assignment

The Confusing Comma In JavaScript 

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


Tabnine Adds Code Provenance And Attribution Checks
07/01/2025

Tabnine has added a feature intended to reduce the risk of IP infringement. The new Provenance and Attribution feature checks that code suggested by AI code assistants doesn't use code with copyright  [ ... ]



Robot Vacs Move Towards Real Robots
12/01/2025

Robot vacuum cleaners swept the floor at CES 2025 and while this might not seem very exciting, think again. Adding AI to these everyday home helpers has already made them more efficient at what they d [ ... ]


More News

espbook

 

Comments




or email your comment to: comments@i-programmer.info

 

<ASIN:1871962579>

<ASIN:1871962560>

 

Last Updated ( Tuesday, 02 July 2019 )