Objects are similar to arrays because they store data. Data can be stored in a structural way and can be represented as a real-world object.
Data stored in objects can be accessed through what is called properties, either using the dot notation" (
object.propertyName)or the bracket notation (
Objects are most useful for lookups when we have tabular data and when we know that our data is limited to a certain range.
checkBestStudentwith a single argument
lookup. It has 5 properties and values.
subjectas a property name into the variable
lookupwhich is an object. This is done using bracket notation. The result is assigned to the empty variable
bestStudent. Whenever we call the
checkBestStudentfunction with the argument, it will lookup the subject as a property in the object then assigned the value to the
bestStudentvariable to the console.
View all Courses