Your variable doc
will never be an array as document.getElementById
will only return the matched element, or undefined.
This code is all you need:
var doc = document.getElementById('skip');
alert(doc.href);
Extra:
This conditional statement would return the element, and never be false:
var array = doc ? doc.getElementsByTagName('a') : [];
This would always return false as the html element does not have a .length
property:
if(array.length > 2)
This will cause an error as array
is not an array.
alert(array[0]);