Appendix E. Answers to Exercise Questions

This appendix lists possible answers to the exercises at the end of the chapters. Possible answers meaning they are not the only ones, so don't worry if your solution is different.

As with the rest of the book, you should try them in your console and play around a bit.

The first and the last chapters don't have the Exercises section, so let's start with Chapter 2, Primitive Data Types, Arrays, Loops, and Conditions.

Chapter 2, Primitive Data Types, Arrays, Loops, and Conditions

Lets try and solve the following exercises:

Exercises

  1. The result will be as follows:
            > var a; typeof a; 
            "undefined" 
    

    When you declare a variable but do not initialize it with a value, it automatically gets the undefined value. You can ...

Get Object-Oriented JavaScript - Third 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.