|
| 1 | +# Class 07 Reading Notes |
| 2 | + |
| 3 | +I decided to make a tutorial based off these reading chapters |
| 4 | + |
| 5 | +### Tables! |
| 6 | + |
| 7 | +Tables are a great way to store information in a grid format! I'm going to show how to make a table in this week's reading notes. |
| 8 | + |
| 9 | +``` |
| 10 | +<table> //this element is used to start the table |
| 11 | + <tr> |
| 12 | + <th scope="col">Title of our table</th> // use th to delcare the heading of the column or row. we are using the scope "col" because we want the txt on top of the column |
| 13 | + <th></th> |
| 14 | + <th></th> |
| 15 | + </tr> |
| 16 | + <tr> // the start of each row |
| 17 | + <th scope="row">Top row!</td> // this is the first cell of the table. Also we are using th to put a heading with scope "row" so it will replace the column with our text. |
| 18 | + <td>Top row 1</td> |
| 19 | + <td>Top row 2</td> |
| 20 | + </tr> |
| 21 | + <tr> |
| 22 | + <th scope="row">Middle row!</td> |
| 23 | + <td>Middle row 1</td> |
| 24 | + <td>Middle row 2</td> |
| 25 | + </tr> |
| 26 | + <tr> |
| 27 | + <th scope="row">Lower row </td> |
| 28 | + <td>Lower row 1</td> |
| 29 | + <td>Lower row 2</td> |
| 30 | + </tr> |
| 31 | +</table> |
| 32 | +``` |
| 33 | + |
| 34 | +Some other options you can use when building grids: |
| 35 | + |
| 36 | +Using colspan in a td can make the column extend the amount of spaces you specify horizontally |
| 37 | + |
| 38 | +The book uses colspan="2" to show some text in a column taking up 2 cell spaces horizontally. |
| 39 | + |
| 40 | +Using rowspan can make a td extend vertically. |
| 41 | + |
| 42 | +the book uses rowspan="2" to show a column taking up both a middle row and bottom row amount of space. |
| 43 | + |
| 44 | +When dealing with long tables its good to split up the information like this: |
| 45 | + |
| 46 | +- thead, the headings of the tables should be placed here |
| 47 | +- tbody, the body of the table should sit here |
| 48 | +- tfoot, all information that goes at the last row should be here |
| 49 | + |
| 50 | +### JS Functions, Methods and Objects |
| 51 | + |
| 52 | +> recap of the notes from last week: |
| 53 | +
|
| 54 | +#### Objects |
| 55 | + |
| 56 | +Objects group together a set of variables and functions to creat a mode of something you'd recognize from the real world. |
| 57 | + |
| 58 | +If a variable is part of an object it is called a property |
| 59 | + |
| 60 | +If a function is part of an object it is called a method |
| 61 | + |
| 62 | +Just like how variables and functions have names and a value, in an object the names are called a key, values are the same. An object cannot have two keys with the same names. |
| 63 | + |
| 64 | +Here is how you would declare an object |
| 65 | +``` |
| 66 | +var nameOfObject = { |
| 67 | + keyOne: 'string', |
| 68 | + keyTwo: 23, |
| 69 | + keyThree: 10, |
| 70 | + methodCheckNumber: function() { |
| 71 | + return this.keyTwo + this.keyThree; |
| 72 | + } |
| 73 | +}; |
| 74 | +``` |
| 75 | + |
| 76 | +***See [reading notes-6 for more on objects](class-06.md)*** |
| 77 | + |
| 78 | +#### Arrays are Objects! |
| 79 | + |
| 80 | +Instead of making an object with a bunch of seperate different keys for every value you can place all the values into an array. |
| 81 | +refer to page 118 in the book |
| 82 | + |
| 83 | +Objects can hold arrays and you can call them with dot notation. |
| 84 | +``` |
| 85 | +var things = { |
| 86 | + thing1 = stuff[1, 23, 555] |
| 87 | + thing2 = stuff[999, 2, 43] |
| 88 | +}; |
| 89 | +
|
| 90 | +things.thing1[0] // this will call the number 1 from the key thing1. |
| 91 | +``` |
| 92 | +Notice how the value is the array's name, brackets and then the values. |
| 93 | + |
| 94 | +### Built in objects and how to use them |
| 95 | + |
| 96 | +The built in objects come with the browser and represent things like the browers window and the current web page being shown. These can be used like a toolkit for creating interactive we pages. |
| 97 | + |
| 98 | +The three types of built-in objects: |
| 99 | +- Browser Object Model, creates a model of the browser tab or window |
| 100 | +- Document Object Model, creates a model of the current web page |
| 101 | +- Global JavaScript Objects, these are a group of individual objects that relate to different parts of the JavaScript language. |
| 102 | + |
| 103 | +See page 123 for further details. |
| 104 | +Remember math objects are on page 134, date objects page 137 |
| 105 | + |
| 106 | + |
| 107 | +[Return to Main Page](https://github.com/PyDrummer/pydrummer.github.io-reading-notes-/blob/master/class-06.md) |
0 commit comments