Objects

Objects

  • Objects are used to represent real world objects in programming

  • Within an object, variables are known as properties and functions are known as methods

  • Curly braces are a means of identifying if a variable is an object

        // create an object that represents a dog
    
        const myDog = {
          name: "Fido",
          age: 4,
          speak: function() {
            console.log('Woof woof')
          }
        }
        
    
  • Objects are organized in Key / Value pairs, in the example above: name is a key and "Fido" is the value, the pair together is referred to as the property

Details