JavaScript Quiz that May Confuse You

JavaScript Quiz that May Confuse You pitayan.com3 months ago in #Funny Love27

These days, I used to be making ready a small sport for our workforce’s tech workshop. Thought it’d be a excellent alternative of introducing the some elementary and tough stuffs round JavaScript. So I made eight quiz to our workforce individuals. And hope they may resolve them inside of 15 min. Eventually, it took they all over 20 mins to finish and maximum of them may just resolve 4-Five questions accurately. You can take it as only a small check, each and every quiz has solution hooked up to the top of the code. Try to reply to them first after which have a look at the solutions. Good success. #What do those console.log print out? #No. 1 — Doctor Pavlov has a canine serve as Animal(){ this.sort = “animal” } serve as Dog(){ this.title = “canine” } Dog.prototype = new Animal() var PavlovPuppy = new Dog(); console.log(PavlovPuppy.__proto__ === Dog.prototype) console.log(Dog.prototype.__proto__ === Animal.prototype) Answer for No. 1 Very elementary stuff in regards to the prototype chain. #No. 2 — Be cautious with the “type” var arr = [5, 22, 14, 9]; console.log(arr.type()); Answer for No. 2 Sorry, no longer [5, 9, 14, 22]. Each component is transformed into string after which evaluating the collection of UTF-16 price. Check this out: doctors/Web/JavaScript/Reference/Global_Objects/Array/type #No. 3 — Closure and tournament loop for (var i = 0; i { console.log(i) } setTimeout(log, 100) } Answer for No. 3 It prints out Three 3 times since setTimout places that log serve as to the following macro job queue #No. 4 — There’s indentation serve as createNewArray(merchandise) { go back } console.log(createNewArray(0)) Answer for No. 4 This reasons an error. Can’t go back price with break-line and indentation in combination Uncaught SyntaxError: Invalid or surprising token #No. 5 — What’s throughout the “numbers” const duration = 4 const numbers = [] for (var i = 0; i  » Read More

Like to keep reading?

This article first appeared on If you'd like to keep reading, follow the white rabbit.

View Full Article

Leave a Reply