Accessing a JavaScript function of an object using [] instead of a dot (.)