Home > JavaScript Questions
Below is a compiled list of JavaScript interview questions that will help you conquer that upcoming interview of yours!
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();
var x = { foo : 1};
var output = (function(){
delete x.foo;
return x.foo;
})();
console.log(output);
var list = readHugeList();
var nextListItem = function() {
var item = list.pop();
if (item) {
// process the list item...
nextListItem();
}
};
var str = "abcd";
str[0] = "b";
console.log(str);
1. var x = 1;
2. function outer(){
3. var y = 2;
4. x++;
5. function inner(){
6. x++;
7. y++;
8. console.log(x,y);
9. }
10. return inner;
11. }
12. var innerFun = outer();
13. innerFun();
14. outer();
15. innerFun();
console.log(typeof typeof 1);