Just short note to my self. If getElementById doesn't work, most probably I forgot window.onload, because if page is not loaded yet, and javascript is executed, then my element with ID will not exist. So, html part looks like:
<!DOCTYPE html> <html> <head> <script type="text/javascript" src="/arrayAssignment.js"></script> </head> <body> Variable <strong>A</strong>: <span id='varA'></span> <br/> <strong>var b = a</strong>: <span id='b=a'></span> <br/> b.splice(3); <br/> Variable <strong>A</strong>: <span id='bSplice'></span> <br/> </body> </html>
and javascript part should lok something like:
window.onload = function() { var a = []; var b = []; a = [1, 2, 3, 4] b = a; document.getElementById("varA").innerHTML = a; document.getElementById("b=a").innerHTML = b; b.splice(3); document.getElementById("bSplice").innerHTML = a; };
This is just short note to myself since I always forget onLoad part :)