Skip to content

Instantly share code, notes, and snippets.

@ripter
Created September 10, 2012 19:26
Show Gist options
  • Save ripter/3693196 to your computer and use it in GitHub Desktop.
Save ripter/3693196 to your computer and use it in GitHub Desktop.
JavaScript Test

General

  • What JS libraries have you used?
    • Why that over X?
  • What JS tempting libraries have you used?
  • How do you organize your code?
  • Have you used CoffeeScript?
    • What do you like/dislike about it?
    • Advantages/Disadvantages over JavaScript?

What is:

  • primitive types
  • this
  • apply & call
    • What is the difference between the two?
  • closures
  • lambdas
  • JSON

Describe the differences between:

  • Loops
    • for
    • for in
    • while
    • forEach
      • is there an issue with for/while that forEach can solve?
    • map
    • reduce
  • Variables
    • undefined
    • undeclared
    • null
  • Host objects and Native objects.
  • Passed by reference vs passed by value
    • Bonus if knows everything is passed by reference but primitives are immutable.

Explain:

  • How are variables scoped in JavaScript?
  • What is hoisting?
  • The prototype chain

Solve:

  • FizzBuzz
  • Reverse a string
  • Reverse the letters but not the word order.
    • Example: "Hello World" becomes "olleH dlroW"
  • Flatten a list.
    • Example: [[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []] becomes [1, 2, 3, 4, 5, 6, 7, 8]
  • Memorize function
function hello(what) {
what = "world";
return "Hello, " + arguments[0] + "!";
console.log( hello('Chris') );
//
//
//
function allNames() {
var names = [ 'Chris', 'Skip', 'Jeff' ];
for (name in names) {
console.log(name);
}
}
allNames();
console.log(name);
(function() {
  var count = 10;

  while (count--) {
    console.log(count);
  }

  console.log(count);
})();

(function() {
  var count = 10;

  while (count--) {
    var foo = 'boo';
    console.log(foo);
  }

  console.log(foo);
})();

(function() {
  var count = 10;

  (function() {
    while (count--) {
      console.log(count);
    }
  })();

  console.log(count);
})();

(function() {
  var count = 10;

  (function() {
    var count = 5;
 
    while (count--) {
      console.log(count);
    }
  })();

  console.log(count);
})();
var a = 2
, b = '4'
, c = b + a
, d = b - a
, e = c + d
;
console.log(typeof a, a);
console.log(typeof b, b);
console.log(typeof c, c);
console.log(typeof d, d);
console.log(typeof e, e);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment