Skip to content

Instantly share code, notes, and snippets.

@clucasalcantara
Created February 5, 2018 11:08
Show Gist options
  • Save clucasalcantara/157eb08cbf9613c07938297677971ff0 to your computer and use it in GitHub Desktop.
Save clucasalcantara/157eb08cbf9613c07938297677971ff0 to your computer and use it in GitHub Desktop.
Gajo - Interview Questions
// 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();
// What does the code below alert?
function aaa() {
return
{
test: 1
};
}
alert(typeof aaa());
// What is the result?
Number("1") - 1 == 0;
// What is the result?
console.log( (true + false) > 2 + true );
// What is the order of values alerted?
var x = 3;
var foo = {
x: 2,
baz: {
x: 1,
bar: function() {
return this.x;
}
}
}
var go = foo.baz.bar;
alert(go());
alert(foo.baz.bar());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment