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 One Solution

append or appendChild?

In tasks 5 & 7 Guil uses .appendChild to add the elements to the page, however I used .append and seem to get the same result.

Is there a reason to use .appendChild over .append here or is it functionally the same thing?

1 Answer

Steven Parker
Steven Parker
231,269 Points

These functions differ in the number and kind of arguments they take, and whether or not they return a value. But for some operations they are interchangeable.

Perhaps the most important difference is legacy support. appendChild is supported by nearly every historical version of every common browser, but append is only supported in recent browser versions, and not at all in IE. When there's more than one way to do a particular task (as often happens), the "best practice" choice is usually the one that has the most legacy support.

For more details, see the MDN pages on append and appendChild.

Thanks Steven!