What easy questions on Javascript I can ask?

Jun 25, 2018·
Denis Trofimov
Denis Trofimov
· 2 min read
blog learning

In this post I speak about some basic Javascript quesions and answers, which I have made passing throught course JavaScript LaunchPad by Simple Programmer.com.

I have interviewed 3 persons in the year 2017 for developer position to the company I work for, Vzor Systems LLC.

It turned out that to prepare for interview from the interviewer side one should do some effort. If the company is not a big but a small startup, it is my job as interviewer to think of questions and written tests to check a candidate`s skills and knowledge. One time I was looking for typical questions on interview for C++ developer position.

Having an interviewer field of view in mind, I created this questions list when I have finished first **JavaScript LaunchPad **chapter “Execution Contexts and Lexical Environments”.

The Execution Context – Creation & Hoisting

Question: What this code give to the console?

b();
console.log(a);
var a = 'Hello World!';
function b() {
  console.log('Called b!');
}

Answer:

Called b!
Hello World!

Functions, Context, and Variable Environments

Question: What this code give to the console?

function b() {
  var myVar;
  console.log(myVar);
}
function a() {
  var myVar = 2;
  console.log(myVar);
  b();
}
var myVar = 1;
console.log(myVar);
a();
console.log(myVar);

Answer:

1
2
1
1

The Scope Chain

Question: What this code give to the console?

function a() {
  function b() {
    console.log(myVar);
  }
  b();
}
var myVar = 1;
a();
b();

Answer:

1
Uncaught ReferenceError: b is not defined

What About Asynchronous Callbacks

Question: What this code give to the console?

// long running function
function waitThreeSeconds() {
  var ms = 3000 + new Date().getTime();
  while (new Date() < ms){}
  console.log('finished function');
}
function clickHandler() {
  console.log('click event!');
}
// listen for the click event
document.addEventListener('click', clickHandler);
waitThreeSeconds();
console.log('finished execution');

Answer:

finished function
finished execution
click event!
Denis Trofimov
Authors
Software Architect, Data Architect

Software Architect, Data Architect


Seasoned software developer with experience at startups, banks, and industries like space and railroads.


  • Go, Python, C++, C engineer since 2006.
  • Last 3 years: Platform Engineering, building Internal Developer Portals (IDPs), and shifting organizations left in DevOps.
  • Designed and built standalone and client-server apps with Oracle DB, PostgreSQL, and MySQL.
  • Delivered CRM systems, web-based automated order processing, and simulations for railroad rolling stock operations.