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


.NET Jupyter Notebooks Announced
18/11/2019

Microsoft has announced that you'll be able to run .NET code in Jupyter Notebooks, specifically C# and F#, and therefore ML.NET as well. The new support is enabled by the .NET kernel for Jupyter and T [ ... ]



CodeGuru For Automated Code Review
06/12/2019

Perhaps the most interesting AWS announcement for professional programmers from this week's annual re:Invent conference was Amazon CodeGuru which makes the claim "It's like having a distinguished engi [ ... ]


More News

graphics

 



 

Comments




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

 

<ASIN:1871962579>

<ASIN:1871962560>

 

Last Updated ( Tuesday, 02 July 2019 )