Exercises

  1. What is the result of executing each of these lines in the console? Why?
    > var a; typeof a;
    > var s = '1s'; s++;
    > !!"false";
    > !!undefined;
    > typeof -Infinity;
    > 10 % "0";
    > undefined == null;
    > false === "";
    > typeof "2E+2";
    > a = 3e+3; a++;
  2. What is the value of v after the following?
    > var v = v || 10;

    Experiment by first setting v to 100, 0, or null.

  3. Write a small program that prints out the multiplication table. Hint: use a loop nested inside another loop.

Get Object-Oriented JavaScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.