Skip to content

Instantly share code, notes, and snippets.

@leejordan
Created July 31, 2015 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leejordan/a08c31bf0f4ff5b96c90 to your computer and use it in GitHub Desktop.
Save leejordan/a08c31bf0f4ff5b96c90 to your computer and use it in GitHub Desktop.

Front end dev interview questions

Standard JS Questions:

  • Explain javascript closures
  • Explain event bubbling
  • Explain event delegation
  • What does apply() do
  • What does bind() do
  • Explain what the js map function does provide an example
  • What is strict mode
  • Whats the difference between a promise and a callback

Angular JS Questions:

  • What is scope
  • What is a directive
  • What is the link function in the directive
  • What is the digest cycle (after I mentioned it in giving another answer)
  • What is $scope.$apply
  • What are the most commonly used out of the box directives
  • What does transclude do on directives
  • Tell me about a time you had problems with state in angular
  • Have you ever had performance issues in angular and how did you tackle them
  • What do you like about angular, what do you dislike about angular
  • Why use a q promise as opposed to just returning $http’s promise
  • What does $resource do

General/Presentation Layer Questions:

  • What is a model in mvc
  • Explain css specificity
  • How do you centre something horizontally
  • Explain what media queries are
  • What are the pros and cons of a single page app
  • How could you improve performance of a single page app
  • Whats the difference between inline-block and inline
  • How would you develop a mobile site for a website that didn’t already have one
  • What is jsonp
  • What is a doctype
  • On a unix command line how would you run a long command you typed out already an hour ago
  • What frontend tools do you normally use
  • Where do you think ui’s are heading
  • What motivates you, how do you learn

JS Challenge Type Questions:

Write a function that takes an integer and returns it doubled

    //your code here
}```

Write a function that takes a number and returns true if it's even and false if not

```function isNumberEven(i) {
    // i will be an integer. Return true if it's even, and false if it isn't.
}```

Write a function that returns a file extension

```function getFileExtension(i) {
    // i will be a string, but it may not have a file extension.
    // return the file extension (with no period) if it has one, otherwise false
}```

What will be printed on the console? Why?

```(function() {
   var a = b = 5;
})();
console.log(b);```

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:

```console.log('hello'.repeatify(3));
//Should print hellohellohello.```

What will log out here?

```function test() {
   console.log(a); 
   console.log(foo());

   var a = 1;
   function foo() {
      return 2;
   }
}
test();

What will log out here?

var obj = {
   fullname: 'Colin Ihrig',
   prop: {
      fullname: 'Aurelio De Rosa',
      getFullname: function() {
         return this.fullname;
      }
   }
};

console.log(obj.prop.getFullname()); 
var test = obj.prop.getFullname; 
console.log(test()); ```

Now fix the previous question’s issue so that the last console.log() prints Aurelio De Rosa.
 
The following recursive code will cause a stack overflow if the array list is too large. How can you fix this and still retain the recursive pattern?

```var list = readHugeList();

var nextListItem = function() {
    var item = list.pop();

    if (item) {
        // process the list item...
        nextListItem();
    }
};```

What will alert out here:

```var a = 'value';

(function() {
  alert(a); 
  var a = 'value2';
})();```

The following code will output "my name is rex, Woof!" and then "my name is, Woof!" one second later, fix it so prints correctly the second time

```var Dog = function (name) {
  this.name = name;
};

Dog.prototype.bark = function () {
  console.log('my name is '+ this.name + ', Woof!');
}

var rex = new Dog('rex');

rex.bark();

setTimeout(rex.bark, 1000);```

The following code outputs 100, a hundred times, fix it so it outputs every number with a 100ms delay between each

```for (var i = 0; i < 100; ++i) {
  setTimeout(function() {
    console.log(i);
  }, 100);
}```

The following code is outputting the array but it's filled with every number, we just want the even numbers, what's gone wrong?

```var evenNumbers = []

var findEvenNumbers = function (i) {
  if (i % 2 === 0)
    console.log(i, 'is an even number, adding to array!');
    evenNumbers.push(i);
}

for (var i = 0; i < 10; i++) {
  findEvenNumbers(i);
}

console.log(evenNumbers);

//outputs:
//0 "is an even number, adding to array!"
//2 "is an even number, adding to array!"
//4 "is an even number, adding to array!"
//6 "is an even number, adding to array!"
//8 "is an even number, adding to array!"
//[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]```

The following is outputting 0, but if 42 = 16 and 22 = 4 then the result should be 12

```var square = function (number) {
  result = number * number;
  return result;
}

result = square(4);
result2 = square(2);
difference = result - result2;

console.log(difference);```

I was presented with a html element with a border, and asked to animate it left to right full width of browser

I was presented with another html box and asked to centre it both horizontally and vertically
@leejordan
Copy link
Author

a badly formatted dump of a useful reddit post. will tidy up in future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment