Skip to content

Instantly share code, notes, and snippets.

@ValeriiVasin
Last active January 5, 2016 11:16
Show Gist options
  • Save ValeriiVasin/84e8349afa9964b49d17 to your computer and use it in GitHub Desktop.
Save ValeriiVasin/84e8349afa9964b49d17 to your computer and use it in GitHub Desktop.

JavaScript

  • Explain event delegation
  • Explain how this works in JavaScript
  • Explain how prototypal inheritance works
  • How do you go about testing your JavaScript?
  • AMD vs. CommonJS?
  • Which JavaScript libraries have you used?
  • Have you ever looked at the source code of the libraries/frameworks you use?
  • What are undefined and undeclared variables?
  • What is a closure, and how/why would you use one?
  • Your favorite pattern used to create them? argyle (Only applicable to IIFEs)
  • What's a typical use case for anonymous functions?
  • Explain the "JavaScript module pattern" and when you'd use it.
  • Bonus points for mentioning clean namespacing.
  • What if your modules are namespace-less?
  • How do you organize your code? (module pattern, classical inheritance?)
  • What's the difference between host objects and native objects?
  • Difference between: javascript function Person(){} var person = Person() var person = new Person()
  • What's the difference between .call and .apply?
  • explain Function.prototype.bind?
  • When do you optimize your code?
  • Can you explain how inheritance works in JavaScript?
  • When would you use document.write()?
  • Most generated ads still utilize document.write() although its use is frowned upon
  • What's the difference between feature detection, feature inference, and using the UA string
  • Explain AJAX in as much detail as possible
  • Explain how JSONP works (and how it's not really AJAX)
  • Have you ever used JavaScript templating?
  • If so, what libraries have you used? (Mustache.js, Handlebars etc.)
  • Explain "hoisting".
  • Describe event bubbling.
  • What's the difference between an "attribute" and a "property"?
  • Why is extending built in JavaScript objects not a good idea?
  • Why is extending built ins a good idea?
  • Difference between document load event and document ready event?
  • What is the difference between == and ===?
  • Explain how you would get a query string parameter from the browser window's URL.
  • Explain the same-origin policy with regards to JavaScript.
  • Describe inheritance patterns in JavaScript.
  • Describe a strategy for memoization (avoiding calculation repetition) in JavaScript.
  • What is the arity of a function?
  • What is "use strict";? what are the advantages and disadvantages to using it?

jQuery

  • Explain "chaining".
  • Explain "deferreds".
  • What are some jQuery specific optimizations you can implement?
  • What does .end() do?
  • Write an simple example of jQuery plugin (e.g. set color of element)

Code samples

What is the diffence:

  • a === undefined
  • typeof a === 'undefined'

What is incorrect:

var a = b = 5;

What will it produce in strict mode.

Implement .duplicate():

[1,2,3,4,5].duplicate(); // [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]

Implement function:

add(1,2); // 3
add(1)(2); // 3

What will be printed? And why?

var o = {
  f: function () {
    console.log(this);
  }
};

o.f();
('hello', o.f)();

What will be printed? And why?

var a = [],
    i;

for (i = 0; i < 10; i += 1) {
  a[i] = function () {
    var j = i;
    
    return j*j;
  };
}

console.log( a[a.length - 1]() );

Implement inheritance. What types of inheritance do you know?

Implement Function.prototype.bind?

Algorithms

  • You have an array with 99 numbers from 1 upto 100. One number is missed. Find it.
/**
 * @param {Array} arr Array with numbers
 * @return {Number} Missed number
 */
function missed(arr) {
  // yours implementation
}
  • Make it work
var add = function (x, y) {
  return x + y;
}.autoCurry();

var add3 = add(3);
add3(4); // 7

add(3, 5); // 8
  • Implement own function that implements new F() functionality
function myNew(constructor, args) {
  // realization
}

function hello(one, two) {
  this.one = one;
  this.two = two;
}

hello.prototype.sayOne = function () {
  console.log('hello, %d', this.one);
};

var obj = myNew(hello, [1,2]);

console.log( obj.one, obj.two );
obj.sayOne();
  • Implement a function asyncForEach(urls, callback) that perform ajax request to each url and invoke callback after all responses recieved.
/**
 *  @param {Array}  Array with urls to request
 *  @param {Function} callback Callback to invoke after
 */
function asyncForEach(urls, callback) {
  // yours implementation
}

var urls = ['1.html', '2.html', '3.html'];
asyncForEach(urls, function () {
  console.log('done.');
});
  • Implement a function draw(n) that will draw pyramid in console. For example, draw(4); should output to console:
   *
  ***
 *****
*******
  • Linked list Implement a function that takes a linked list as argument and invert it:
/**
 * @param {Object} list Linked list
 * @return {Object} Inverted linked list
 */
function invertLinkedList(list) {
  // yours implementation
}

// example
var list = {
  value: 1,
  next: {
    value: 2,
    next: {
      value: 3,
      next: {
        value: 4,
        next: null
      }
    }
  }
};

invertLinkedList(list);

/** it should return an object:
{
  "value": 4,
  "next": {
    "value": 3,
    "next": {
      "value": 2,
      "next": {
        "value": 1,
        "next": null
      }
    }
  }
}
**/
  • Implement .uniq() for array
  • Implement .reverse()
  • Implement sort for array
  • Implement .shuffle() function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment