The JS Interview

Not every job is for every person

If you are not hired then the company might not be for you

The Basics of interviewing

  • Confidence (sell yourself)
  • Honesty
  • Look Sharp
  • Do Your Research
  • Be Prepared
  • Be on Time
  • Show Enthusiasm
  • Listen
  • Answer the Question Asked
  • Give Specific Examples
  • Ask Questions
  • Follow Up (email, phone, etc)

Dress Code

  • company focus
  • Business
    • slacks, dress shirt, and Tie (optional)
  • Startup
    • Nice shirt and slacks or nice jeans
  • IT
    • dress or collared shirt and slacks 

Important Questions

Source: http://insights.dice.com/2012/09/26/javascript-interview-questions/

Question

How do you implement an extend function that takes an object and extends it with new properties and makes it work on n levels of recursion? Basically, duplicating a jQuery extend.

Answer

This question shows whether candidates have an understanding of basic programming concepts such as recursion, says Jonas Huckestein, co-founder of conference-calling startup HipDial

Question

Can you write a function that takes an object and appends it to the DOM, making it so that events are buffered until the next tick? Explain why this is useful?

Answer

This last part only applies in browser-side settings where it can dramatically increase performance, he says.

Question

How do you write an event emitter base class that allows you to add event listeners?

Answer

This question can nicely lead into architectural questions, Huckestein says, such as: “How would you make an event emitter that’s distributed?”

Question

What is the concept of “functions as objects” and how does this affect variable scope?

Answer

“What it can suggest is that the person really ‘gets’ JavaScript and the way it works as opposed to just having copied syntax and code from the web without understanding it,” Weinberg says. “It can also show that the person has at least some understanding of basic programming concepts, which in my experience means they will be better equipped to come up with good solutions to hard problems.”

Question

What modern JavaScript frameworks and utilities excite you right now from an approach and code point of view, even if they’re not yet stable enough for client work?

Answer

TBD

Question

What is the difference between .call() and .apply()?

Answer

The JavaScript Function prototype has two very powerful functions that are at the core of Javascript’s “everything is an object” mentality, including functions, Kubasik says.

Question

Can you explain how inheritance works in JavaScript?

Answer

JavaScript has a somewhat unique inheritance model and a good understanding of it is crucial to using JavasScript in larger applications, Kubasik says.  “We are looking for the applicant to discuss not only prototypes, and how that affects inheritance, but in what ways this can be more flexible than classical inheritance models seen in Java and C#.”

Question

What is event bubbling in the DOM?

Answer

The main goal of this question is to establish that the applicant knows what order events will be propagated in the DOM – most specific to least specific.

“Not everyone may know this by the name ‘event bubbling,’ so asking about event propagation in general is sometimes needed. Ideally, this is an opportunity to discuss event models outside of the DOM, and ask follow-up questions about routing based on user actions, looking for techniques popularized with frameworks like backbone.js, or AngularJS,” Kubasik says.

Importance of GitHub

I can go onto GitHub or BitBucket. I can actually look at what they’ve done with their code. I can see the projects they’ve worked on [and] I can see how much they’ve contributed to projects. I can go onto sites like Stack Overflow and see who are the influential people in the community, see who’s answering questions specifically about JavaScript,” he says. “… from that I already know they’re technically savvy, so from there, my role is just to convince them to leave where they currently are and come work for us.”

Code Example

Source:

http://www.sitepoint.com/5-typical-javascript-interview-exercises/

Scope

1

2

3

4

5

(function() {

   var a = b = 5;

})();

 

console.log(b);

Answer

The code above prints 5.

The trick of this question is that in the IIFE there are two assignments but the variable a is declared using the keyword var. What this means is that a is a local variable of the function. On the contrary,b is assigned to the global scope.

Strict Mode

The other trick of this question is that it doesn’t use strict mode ('use strict';) inside the function. If strict mode was enabled, the code would raise the error Uncaught ReferenceError: b is not defined. Remember that strict mode requires you to explicitly reference to the global scope if this was the intended behavior. So, you should write:

1

2

3

4

5

6

(function() {

   'use strict';

   var a = window.b = 5;

})();

 

console.log(b);

Create “native” methods

Define a repeatify function on the String object. The function accepts an integer that specifies how many times the string has to be repeated. The function returns the string repeated the number of times specified. For example

1

console.log('hello'.repeatify(3));

Should print hellohellohello.

Title Text

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin urna odio, aliquam vulputate faucibus id, elementum lobortis felis. Mauris urna dolor, placerat ac sagittis quis.

The JS Interview

By James Brinkerhoff

The JS Interview

  • 816