TypeOfNaN JavaScript Quizzes
Written by Nikos Vaggalis   
Monday, 16 March 2020

Learn JavaScript fundamentals through fun and challenging quizzes! This interactive quiz provides a total hands-on learning experience. It currently has 72 questions on a variety of Javascript concepts and more are being added.

These quizzes have been set by Nick Scialli who explains that many of them are tricky and dive into subjects that tripped him up when he was first learning JavaScript. The very first question should give you an idea of what to expect:

Array Sort Comparison

Consider the following arrays. What gets logged in various sorting conditions?

const arr1 = ['a', 'b', 'c'];
const arr2 = ['b', 'c', 'a'];

console.log(
arr1.sort() === arr1,
arr2.sort() == arr2,
arr1.sort() === arr2.sort()
);

The question is followed by multiple choice answers:

true true true
true true false 
false false false
true false true

After you make your choice, be it right or wrong, an explanation is provided :

There are a couple concepts at play here. First, the array sort method sorts your original array and also returns a reference to that array. This means that when you write arr2.sort(), the arr2 array object is sorted.

It turns out, however, the sort order of the array doesn't matter when you're comparing objects. Since arr1.sort() and arr1 point to the same object in memory, the first equality test returns true. This holds true for the second comparison as well: arr2.sort() and arr2 point to the same object in memory.

In the third test, the sort order of arr1.sort() and arr2.sort() are the same; however, they still point to different objects in memory. Therefore, the third test evaluates to false.


Here's are another couple:


Prototypal Inheritance

In this question, we have a Dog constructor function. Our dog obviously knows the speak command. What gets logged in the following example when we ask Pogo to speak?

function Dog(name) {
this.name = name;
this.speak = function() {
return 'woof';};
  }

const dog = new Dog('Pogo');

Dog.prototype.speak = function() {
return 'arf';
};

console.log(dog.speak());

Every time we create a new Dog instance, we set the speak property to that instance to be a function returning the string woof. Since this is being set every time we create a new Dog instance, we never use the prototypal speak property on Dog that returns the arf string.

Others quizzes include :

  • Promise.all Resolve Order
  • Reduce Math
  • Array Method Binding
  • Set Uniqueness and Ordering
  • IIFE, HOF, or Both
  • Array-to-Object Efficiency
  • Object Cloning (JSON.parse + JSON.stringify) Comparison
  • Global Local
  • Console Log Constructors
  • Arrow Functions
  • Async/Await
  • Curly Q
  • Floating-Point Precision
  • Reduce Object
  • Off to the Races
  • Callback setTimeOut
  • Array Object Iteration
  • Equality and Identity Operators
  • this Keyword

and so on.

As the list indicates, the quiz is addressed to the intricacies of the language and spans important and tricky concepts that you need firmly established foundation of in order to progress further with the language. Nick Scialli does warn however:

I'm considered a senior developer and would probably have trouble with a lot of these questions had I not made them myself. Please don't be hard on yourself as you attempt these questions; we're all still learning!

Scialla also offers the quiz as a self hosted option so that you can adapt it to a local network (i.e corporate environment) or even make your own for educational purposes, simply by cloning its Gitgub repo.

Enjoy!

 typeofnanjsq

More Information

TypeOfNaN JavaScript Quizzes

TypeOfNaN JavaScript Quizzes-Github

Related Articles

LInQer ports .NET LINQ to Javascript

Learn Ramda.js The Interactive Way

 

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


Oracle SQL Developer for VS Code
26/02/2024

Oracle has recently introduced some goodies for developers working with VS Code. This is an extension that integrates  SQL Developer within VS Code.



Apache Lucene Adds Similarity Vector Searches
27/02/2024

Apache Lucene 9.10 has been released with support for similarity-based vector searches. Other improvements include block join compatible index sorting, and several improvements to ensure the software  [ ... ]


More News

{laodposition comment}

Last Updated ( Monday, 16 March 2020 )