How can I check if an element exists in the visible DOM?

How do you test an element for existence without the use of the getElementById method? I have set up a live demo for reference. I will also print the code on here as well: <!DOCTYPE html> <html> <head> <script> var getRandomID = function (size) { var str = “”, i = 0, chars = “0123456789abcdefghijklmnopqurstuvwxyzABCDEFGHIJKLMNOPQURSTUVWXYZ”; … Read more

Deleting array elements in JavaScript – delete vs splice

What is the difference between using the delete operator on the array element as opposed to using the Array.splice method? For example: myArray = [‘a’, ‘b’, ‘c’, ‘d’]; delete myArray[1]; // or myArray.splice (1, 1); Why even have the splice method if I can delete array elements like I can with objects? 2 27 delete … Read more