Javascript oneliners: functions are attributes too

Just a small reminder. Javascript allows you to call methods based on their name. So if a DOM element has a addClass and removeClass which both take the same argument we could write:

but we could also write

Sometimes this means you can use this technique to write powerful one liners.

Leave a Reply

Your email address will not be published. Required fields are marked *