JavaScript Objects
JavaScript objects are data structures that can be used to aggregate, encapsulate, and abstract information. Objects also serve as a way to template structures for duplication and reuse. An object can be defined using the Object Initialiser, which uses curly brace notation with members defined inside.
MDN reference
myObject = {
memberVariable: "I'm a member variable",
memberFunction: function() {
console.log("I'm a member function");
},
}
myObject.memberFunction();
HTML Forms
HTML Forms are used to collect data from the user. Forms support a variety of input types.
Create a new account
| Input type | Input element |
|---|---|
| button | |
| checkbox | |
| color | |
| date | |
| file | |
| hidden | |
| image | |
| number | |
| password | |
| radio | |
| range | |
| reset | |
| submit | |
| text | |
| url |
Animation Replay
Animations can be replayed by replacing the animation container with a fresh copy.
JS Animation
JS Animation is achieved by using a perpetual loop and updating properties of HTML elements via the DOM API.
Snake
Limited scope projects such as the Snake game are great ideas to attempt to create when learning a language. This example requires modification to end the game if the snake overlaps with itself.