Last active
February 28, 2019 14:14
-
-
Save rootTheLure/8bc261a750c61126e63b51705abff8db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1) what is console output for every line below | |
typeof 5; | |
typeof new Number(); | |
typeof 0; | |
typeof -0; | |
typeof null; | |
typeof undefined; | |
typeof NaN; | |
typeof !0+1; | |
typeof Object; | |
// 2) what is result of 2 function calls below | |
const karl = { | |
name: 'Karl', | |
sayYourName: () => { console.log(this.name); }, | |
sayItAgain: function () { console.log(this.name); } | |
} | |
karl.sayYourName(); | |
karl.sayItAgain(); | |
// 3) what is the order of console.logs below | |
console.log('script start'); | |
setTimeout(function() { | |
console.log('setTimeout'); | |
}, 0); | |
Promise.resolve().then(function() { | |
console.log('promise1'); | |
}).then(function() { | |
console.log('promise2'); | |
}); | |
console.log('script end'); | |
// 4) What is the result of function calls below | |
function printThis() { | |
console.log(this); | |
} | |
const firstObj = { name: 'FIRST' }; | |
const secondObj = { name: 'SECOND' }; | |
const printFirst = printThis.bind(firstObj); | |
const printSecond = printFirst.bind(secondObj); | |
printThis(); | |
printFirst(); | |
printSecond(); | |
// 5) Are this selector equal? | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Selector</title> | |
</head> | |
<body> | |
<div class='outer'> | |
<div class='inner'> | |
<div> | |
<div></div> | |
<div></div> | |
</div> | |
<div></div> | |
</div> | |
<div></div> | |
<div></div> | |
</div> | |
</body> | |
</html> | |
const length = document.querySelectorAll('.inner div div').length; | |
const length2 = document.querySelector('.inner').querySelectorAll('div div').length; | |
console.log(length === length2); | |
// 6) what is an output | |
for (var i = 0; i < 10; i++) { | |
setTimeout(() => { | |
console.log(i); | |
}, 0); | |
} | |
// 6.1) what is an output | |
var i = 0; | |
while(i++ < 4) { | |
let s = i; | |
setTimeout(function() { | |
console.log(i); | |
}, i * 100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment