Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Interactive Web Pages with JavaScript Traversing and Manipulating the DOM with JavaScript Perform: Traversing Elements with children

function(taskListItem, checkBoxEventHandler) Is 'checkBoxEventHandler' arbitrary? Is the event Handler always 2nd arg?

This has always confused me about JavaScript as I come from a Java and C# background. It seems like the function args are a guessing game. How did he know that the 2nd arg should be the checkBoxEventHandler. I kind of get the first one as if you pass in an object you have clicked on or want to deal with that is the first param. Maybe this is base object stuff that I just am missing concepts for?

1 Answer

Do you mean 'does the param order matter for non-native functions?' If so, no, other than the obvious that the args will be interpreted according to the order of the params. No reason the function couldn't have been written function(checkBoxEventHandler, taskListItem).