Lesson 12 - 13: JavaScript Events and Objects

Cards (12)

  • JavaScript Events - are things that happen in the system you are programming — the system produces (or "fires") a signal of some kind when an event occurs, and provides a mechanism by which an action can be automatically taken when the event occurs.
  • Event Listener - to react to an event, you attach an event handler to it. This is a block of code that runs when the event fires. They are sometimes called "Event Listeners". It is a mechanism that allows you to listen for specific events that occur on HTML elements, such as clicks, keypresses, mouse movements, and more. They enable you to execute code or trigger functions when those events happen.
  • Event - action or occurrence recognized by the browser, such as a click, mouse movement, or a keypress.
  • Event Handler (Event Listener) - function that is executed in response to an event. It “listens” for the event to occur and then runs the specified code.
  • JavaScript Objects - are a type of data structure that contains both properties and methods and a collection of properties. It can store values, you can use objects to manipulate values and combine them into more complex objects, like arrays.
  • Properties - are key–value pairs that describe the characteristics of the object.
  • Keys - (or properties) are usually strings or symbols.
  • Values - can be of any type: numbers, strings, arrays, functions, or even other objects.
  • Common Ways to Create and Object
    • Using Object Literals
    • Accessing Object Properties
    • Modifying Object Properties
  • Using Object Literals - the most common way to create an object is by using curly braces {} and defining key-value pairs inside them.
  • Accessing Object Properties - can access properties using dot notation or bracket notation.
  • Modifying Object Properties - can add, update, or delete properties.