Objects and Arrays | Bondar Academy
Course: JavaScript for Testers
Module: JavaScript Fundamentals
Instructor: Artem Bondar
Lesson Summary
In this lesson, we explore objects and arrays in programming. These are essential data structures that allow us to store and manipulate multiple values effectively. Objects Objects are used to combine several pieces of data into a single reusable component. They are defined using {} (curly braces) and store data in key-value pairs . For example: let customer = { firstName: "John", lastName: "Smith" }; To access values, you can use: Dot notation: customer.firstName Bracket notation: customer["firstName"] To modify values, simply assign a new value: customer.firstName = "Mike"; Arrays Arrays are lists of items, defined using [] (square brackets). For example: let cars = ["Volvo", "Toyota", "Tesla"]; Each item in an array has an index starting from zero: Volvo: index 0 Toyota: index 1 Tesla: index 2 To access an array item, use its index: console.log(cars[0]); // Outputs: Volvo Arrays can also be part of objects, allowing for complex data structures: let customer = { firstName: "John", cars: ["Volvo", "Toyota", "Tesla"] }; To access a specific car: console.log(customer.cars[0]); // Outputs: Volvo Summary In summary, objects are defined with curly braces and store data in key-value pairs, while arrays are defined with square brackets and maintain an ordered list of items. Both structures can be used together to create complex data models.