reading-notes

https://faroukibrahim-fii.github.io/reading-notes/

View the Project on GitHub FaroukIbrahim-FII/reading-notes

HTML Tables; JS Constructor Functions

Tables

Basic Table Structure

tables

It is followed by one or more <td> elements (one for each cell in that row).

At the end of the row you use a closing </tr> tag.

At the end of each cell you use a closing </td> tag.

tables

How memory & Variables work

Global variables use more memory. The browser has to remember them for as long as the web page using them is loaded. Local variables are only remembered during the period of time that a function is being executed.

What is an object

Objects group together a set of variables and functions to create a model of a something you would recognize from the real world. In an object, variables and functions take on new names.

object

Creating an object: literal notation

Literal notation is the easitest and most popular way to create objects. (there are several ways to create objects.)

Accessing an object and dot notation

You access the properties or methods of an object using dot notation. You can also access properties using square brackets.

method

Creating an object: constructor notation

The new keyword and the object constructor create a blank object. You can then add proerties and methods to the ojbect.

const

Updating an object

To update the value of properties, use dot notation or square brackets.

They work on objects created using literal or constructor notation. To deleter a property, use the delete keyword.

Creating many objects: construtor notation

Sometimes you will want several objects to represent similar things. Object constructors can use a function as a template for creating objects. First, create the template with the object’s properties and mehtods.

many

Arrays are objects

Arrays are actually a special type of object. They hold a related set of key/value pairs (like all objects), but the key for each value is its index number.

array

Creating an instance of the date object

In order to work with dates, you create an instance of the Date object. You can then specify the time and date that you want it to represent.

To create a Date object, use the Date() object constructor. The syntax is the same for creating any object with a constructor fiuction. You can use it to create more than one Date object.

By default, when you create Date object it will hold today’s date and the current time. If you want it to store another date, you must explicitly specify the date and times you want it to hold.

date