A good analogy is of a journalist and his or her boss-the editor. The journalist write a story and the editor uses a red pen and "makrs up" all the text that needs attention. For example, a circle might be drawn around a word with "i"(for "italics") noted in the margin. The journalist receives the story back and can make sense of the editor's notes, because in the publishing world there is a set of rules for such text editing.
The control flow is the order in which the computer executes statements in a script. Loops offer a quick and easy way to do something repeatedly. They repeat an action some number of times. The control flow and loop can be illustrated by getting the kids ready for school every day. The order of events (congtrol flow) is as follows. After waking up the kids at 7:30am, I preapare their lunch, while they get dressed, then I provide them breakfast, the kids eat breakfast, after which the children brush their teeth, wash face, put their lunch in their bags, put their bags on, go the car, I drive the car to school, drop off the children, drive back home. This is carried out everyday from Monday to Friday, like a continuious loop.
- The DOM is an 'application programming interface'
- Use the DOM when we interact with web pages
- Add content to a HTML document
- Delete content from a HTML document
- Change content on a HTML document
JavaScript has only one data type which can contain multiple values: Object. An Array is a special form of object. (Plain) Objects have the form-{key: value, key: value, ...} Arrays have the form-[value, value, ...]
- A function is a subprogram designed to perform a particular task.
-Functions are executed when they are called. This is known as invoking a function.
-Values can be passed into functions and used within the function.
-Functions always return a value. In JavaScript, if no return value is specified, the function will return undefined.
-Functions are objects.
You can reuse code: Define the code once, and use it many times.
You can use the same code many times with different arguments, to produce different results.