Git Product home page Git Product logo

asynchrony-in-javascript-quiz-denver-web-career-031119's Introduction

Quiz: Asynchrony in JavaScript Quiz

Introduction

Welcome to our quiz! Quizzes are designed for knowledge exploration and finding weaknesses in your understanding. Use this to check up on your understanding. Even if you see the "right" answer, consider what it would take to change the given code to make it work. Think through the bugs that may arise in the given code and consider multiple ways to fix the errors. Doing so will improve your learning as there is always more than one solution and that solution may not be immediately obvious. Incidentally, those are common tasks to assign in an interview: explaining buggy code and then debugging it. Accordingly, these are skills that we hope to help you grow over your course of study at Flatiron!

???

Asynchronous JavaScript

?: What is the threading model of JavaScript

( ) Global Interpreter Lock ( ) Multicore (X) Single-Threaded ( ) Multi-Threaded

?: Which of the following commands does not use asynchronous processing

( ) fetch() ( ) setTimeout() (X) console.log() ( ) jQuery.get()

?: In JavaScript, execution can be reliably traced by following from top-down, left to right.

( ) True (X) False

?: A selling feature of libraries like jQuery and React is that they handle asynchronous logic for you.

( ) True (X) False

?: In a language without asynchronous processing (something not like JavaScript), if a web request is made, the following code will not process until the response is received and handled.

(X) True ( ) False

?: Given that setTimeout takes a function and a time (in milliseconds) as arguments (setTimeout(fn, time)), what is the expected output of this code (output lines have been collapsed):

setTimeout(() => console.log("Hello"), 5);
console.log("World");

( ) Hello World (X) World Hello ( ) Trick Question: setTimeout "steals" the output filehandle ( ) Hello Hello Hello Hello Hello World

?: Given that setTimeout takes a function and a time (in milliseconds) as arguments (setTimeout(fn, time)), what is the expected output of this code (output lines have been collapsed):

setTimeout(() => console.log("Hello"), 0);
console.log("World");

( ) Hello World ( ) Trick Question: setTimeout "steals" the output filehandle (X) World Hello ( ) World

?: What is the expected output of this command? Assume the server returns {"name": "Byron"}:

var babyName;

fetch("http://flatiron-baby-name.example.com")
  .then(response => response.json())
  .then(data => babyName = data.name);


console.log(`I've named my kid, ${babyName}`);

(X) I've named my kid, undefined ( ) I've named my kid, Byron ( ) This code will not work ( ) babyName will be updated in a parallel thread

?: What is the expected output of this command? Assume the server returns a random Integer. On this particular run it will return 2 and 3.

var addends = [];

fetch("http://flatiron-random-integer.example.com")
  .then(response => parseInt(response.text()))
  .then(newInt => addends.push(newInt));

fetch("http://flatiron-random-integer.example.com")
  .then(response => parseInt(response.text()))
  .then(newInt => addends.push(newInt));

setTimeout(() => {
   var sum = addends[0] + addends[1];
   console.log(sum);
}, 500)

( ) 5 ( ) 2 undefined ( ) undefined 3 (X) We have no way of being certain

???

asynchrony-in-javascript-quiz-denver-web-career-031119's People

Contributors

curiositypaths avatar danielseehausen avatar maxcell avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.