0% found this document useful (0 votes)
23 views

Stack That You Must Use: Js or Jquery For The Front End

The document contains 3 interview questions: 1) A code sample that logs the value of 'this' and 'self' in inner and outer functions and would output the value of 'foo' to the console from both inner and outer functions due to how 'this' is bound. 2) A recursive function to process a huge list that would cause a stack overflow and suggests handling the recursion differently to avoid overflowing the stack. 3) A requirement to build a simple slot machine game using only HTML, CSS, and JavaScript/jQuery without plugins.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Stack That You Must Use: Js or Jquery For The Front End

The document contains 3 interview questions: 1) A code sample that logs the value of 'this' and 'self' in inner and outer functions and would output the value of 'foo' to the console from both inner and outer functions due to how 'this' is bound. 2) A recursive function to process a huge list that would cause a stack overflow and suggests handling the recursion differently to avoid overflowing the stack. 3) A requirement to build a simple slot machine game using only HTML, CSS, and JavaScript/jQuery without plugins.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Interview Task

1) What will the code below output to the console and why?
var myObject = {

foo: "bar",

func: function() {

var self = this;

console.log("outer func: this.foo = " + this.foo);

console.log("outer func: self.foo = " + self.foo);

(function() {

console.log("inner func: this.foo = " + this.foo);

console.log("inner func: self.foo = " + self.foo);

}());

};

myObject.func();

2) 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();

};

3) Build a simple slot machine game


Stack that you must use

1) JS or jQuery for the front end.


2) HTML & CSS
Note: Don’t use any plugins.

You might also like