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


Eclipse JKube 1.16 Goes GA
08/04/2024

Eclipse JKube makes deploying your Java application to a Kubernetes cluster a breeze. Let's find out what's new.



Explore SyncFusion's Blazor Playground
16/04/2024

Syncfusion has provided an in-browser environment where you can write, compile and run code that uses Blazor components and get it previewed live.


More News

raspberry pi books

 

Comments




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

 

<ASIN:1871962579>

<ASIN:1871962560>

 

Last Updated ( Tuesday, 02 July 2019 )