Skip to content

Instantly share code, notes, and snippets.

@shaggybb
Forked from marciobarrios/1.scopes.js
Created January 24, 2020 08:59
Show Gist options
  • Save shaggybb/1a16039098eefbea66200a1c4e223d20 to your computer and use it in GitHub Desktop.
Save shaggybb/1a16039098eefbea66200a1c4e223d20 to your computer and use it in GitHub Desktop.
Practical frontend interview
(function() {
var a = b = 5;
})();
console.log(b);
// 1. What will be printed on the console?
// 2. Rewrite the code to return the same result but with the variable declarations separated
// 3. Enable strict mode to explicitly reference the scope
console.log('hello'.repeatify(3));
// 1. Write a method of String that prints 'hellohellohello'
function test() {
console.log(a);
console.log(foo());
var a = 1;
function foo() {
return 2;
}
}
test();
// 1. What’s the result of executing this code and why
var fullname = 'Rude Ayelo';
var obj = {
fullname: 'Helios Aliaga',
prop: {
fullname: 'Marcio Barrios',
getFullname: function() {
return this.fullname;
}
}
};
console.log(obj.prop.getFullname());
var test = obj.prop.getFullname;
console.log(test());
// 1. What is the result of the following code?
// 2. Fix the previous question’s issue so that the last console.log() prints Marcio Barrios
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment