About understanding object's key value pair

I am reading the lesson in the following link:

I am confused about this paragraph:

With bracket notation you can also use a variable inside the brackets to select the keys of an object. This can be especially helpful when working with functions

I know we can use variable inside the brackets to select value of an object. But why this said key? We can pass in the key to select value but we can not pass in variable to select key.

Maybe an example would help:

const object1 = { 
   "dog": "bark",
   "cat": "meow"

// access value for a key using brackets
let result1 = object1["dog"];
/* result1 is now "bark" */

// access value for key using brackets when key is a variable
let animal = "cat";
let result2 = object1[animal];
/* result2 is now "meow" */

let result3 = object1.dog;
/* result3 is now "bark" */
1 Like