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!
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
What's the more common practice for passing data to $.getJSON: using variables or hard coding inline?
I know the video says both are common, but I'd love to know which is more common // or considered best practice. Are there performance improvements either way?
Seems like the latter would be easier to debug as there is less obfuscation. Are there other considerations?
I don't think there's an easy answer for this, since getting the numbers to determine the more common approach would be difficult/near impossible, and 'best practice' is always a subjective opinion shared by a number of people.
As far as the use of variables go, I think the rule of thumb is that if you need it more than once or it makes it clearer to read and understand the code, then use a variable.