CMSC 122 Lecture 37: CMSC 122 - Lecture 37 - NOV 19

120 views2 pages
Verified Note

Document Summary

Today we are going to discuss about 2 dimensional arrays and how to go about creating them. With javascript"s support for literal arrays in modern browsers (this tutorial predates that), this tutorial can arguably be considered obsolete. Nevertheless, we look at how to manually add additional dimensions to a regular array in javascript, and specifically, how to create a custom 2 dimensional array. If nothing it illustrates a technique for extending prebuilt javascript objects on your own. Before we switch dimensions, lets first quickly review how to create "normal" arrays, and take it from there: The above creates an array with 3 "storage compartments". A two-dimensional array is created simply by building on a "normal" array. Constructing a two-dimensional array requires that we declare another array on top of each of the "stems" (myarray[0], myarray[1]). To start things off, lets first illustrate graphically how a two dimensional array is represented:

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers