mdn append vs appendchild code example

Example 1: difference between the `.append()` method and the `.appendChild()` method

The ParentNode. append() method inserts a set of Node objects or DOMString objects after the last child of the ParentNode . ... append() allows you to also append DOMString objects, whereas Node. appendChild() only accepts Node objects.

Example 2: appendchild javascript

const parent = document.createElement('div');
const child = document.createElement('p');
const childTwo = document.createElement('p');
parent.append(child, childTwo, 'Hello world'); // Works fine
parent.appendChild(child, childTwo, 'Hello world');
// Works fine, but adds the first element and ignores the rest