Javascript create new elements

Does any one know how to add new elements to a page in javascript? For example I have a for loop that has to be done 4 times. For each of the time i want to add a link tag to my page, so in the end I have for new links on my page based on the loop. How can this be done. In php I know I can just echo the enter link code with some ajax but I want to do this without php involvement.

document.createElement
document.createTextNode

and then use appendChild to attach the elements to the other elements and the page.

var new_link = document.createElement(‘a’);
new_link.href = ‘http://www.google.com’;
new_link.innerHTML = ‘Go to Google!’;

document.getElementById(‘destinationDiv’).appendChild(new_link);