CS 347: Lab 12 – JavaScript Questions

Welcome to lab, a time for applying the ideas introduced in lecture in exercises that you will complete in small groups.

Within your breakout room, designate one of your team to be the screen sharer. Screen sharer, share your screen and claim your group’s task on Crowdsource. Make sure to enter every group member’s JMU eID so that they receive credit. Your group will be assigned a task number.

Team, complete the assigned task below. Screen sharer, be careful not to dominate. All members should contribute ideas.

Task

Answer the following questions. Assemble your answers in a plain text document using your preferred method (Google Docs, Slack, Zoom chat, etc.).

  1. What does it mean that JavaScript is dynamically typed?
  2. There are three keywords to declare variables in JavaScript: var, let, and const. What are the semantics of each? Does const mean constant? What is meant by the term hoisting?
  3. Why are == and != problematic? How should comparisons be made?
  4. How does function overloading work in JavaScript?
  5. Suppose I have the following function definition:
    function delay(millis) {
      return new Promise(resolve => setTimeout(resolve, millis));
    }
    
    How do I schedule a JavaScript alert call to execute after 3 seconds has elapsed?
  6. Investigate the spread syntax of arrays. If I have arrays a and b, how can I define a new array c using this syntax?
  7. What are the primitive types? Compared to other languages you know, what types are missing?
  8. Write a function named each that accepts two parameters: an array and a callback function. For each element of the array, call the function with the element passed as the parameter. Use a loop; do not use any builtin array functions to achieve this. Write additional code to demonstrate that each works.

Screen sharer, when your group is done or when time is up, submit your group’s answers on Crowdsource. Do not submit a link; copy and paste the plain text content into the form.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *