Chapter 1b - How do computers fit in with the world around them? Flashcards
Objects represent:
Each physical thing in the world
e.g. Car and Hotel
There is one instance of the hotel and one instance of the car
Each object can have its own:
Properties
Events
Methods
Properties are…
The characteristics of an object
e.g. Color / engine size / current speed of a car
Properties are made up of…
Name
Value
e.g. Name: Car colour / Value: Red
Events are…
A computer’s way of putting up its hand and saying: “This just happened!”.
When an event is triggered…
It is used to trigger a certain section of code
A script will state which events a programmer wants to respond to and what part of the script should then run.
e.g. In a hotel a book event will increment the value of the bookings property by one.
Methods are…
Things people need to do with objects
They can retrieve or update the values of an object’s properties
What does a Method do?
The code for a method can contain lots of instructions that together represent one task
When you use a method, you might not need to know how it achieves its task, rather just how to ask a question, and how to interpret any answers.
e.g. checkAvailability() will subtract the value of the bookings property from the value of the rooms property to return the number of rooms available.
Web Browsers create models of..
The web page they are showing - Document Object
The browser window that the page is being shown in - Window Object
The Document Object represents…
An HTML page
Properties - Describe characteristics of the current web page - e.g. title
Methods - Perform tasks associated with the document currently loaded in the browser
Such as getting info from a specified element
Or Adding new content
Events - Responds to e.g. user clicking or tapping on an element
All browser makers implement the DOM in the same way meaning you already have
Properties that you can access to find out about the current page
Methods to help you achive some common tasks
When a browser creates a model of a page, it creates a new object for each element on the page. This, along with the document object, is called…
The Document Object Model - DOM
A browser sees a web page in the following way:
Receive the page as HTML
Create a model of the page and store it in memory
Uses a rendering engine to display the page onscreen
A subsection of the DOM is called a…
Node
Javascript instructions are interpreted by a part of the browser called an…
Interpreter
In Javascript, each line of code is run one by one. This is because JavaScript is an:
Interpreted Programming Language