javascript - When the last part of expression will be returned -


i have following expression taken jquery native code:

handlers = ( jquery._data( this, "events" ) || {} )[ event.type ] || [] 

i'm curios under conditions last part of expression - [] - assigned handlers variable? here speculation:

1) part executed first ( jquery._data( this, "events" ) || {} ). if there no attached events jquery._data( this, "events" ) === undefined, empty object returned.

2) part {}[event.type] || [] processed. if event.type undefined, array returned , assigned handlers variable. means array returned enough event.type undefined?

am right?

so means array returned enough event.type undefined?

yes, array returned if event.type has value not exist property name in object. is, if first expression evaluates to empty object, any value of event.type result in array being returned.

example:

({}['click'] || []) 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -