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


Go At Highest Rank Ever in TIOBE Index
20/11/2024

Go is currently in 7th place in the TIOBE Index for November 2024. Not only is this is the highest position it has ever had, it's percentage rating is almost equal to its all-time-high. Will Go contin [ ... ]



Google Opensources Privacy Library
08/11/2024

Google is making a new differential privacy library available as open source. PipelineDP4J is a Java-based library that can be used to analyse data sets while preserving privacy.


More News

espbook

 

Comments




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

 

<ASIN:1871962579>

<ASIN:1871962560>

 

Last Updated ( Tuesday, 02 July 2019 )