Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <body> <p> If you use a named index, when accessing an array, JavaScript will redefined the array to a standard object, and all array methods and properties will produce undefined or incorrect results. </p> <p id="demo"></p> <script> var person = []; person["firstName"] = "John"; person["lastName"] = "Doe"; person["age"] = 46; document.getElementById("demo").innerHTML = person[0] + " " + person.length; </script> </body> <!-- Mirrored from www.w3schools.com/js/tryit.asp?filename=tryjs_array_associative_2 by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 07:35:55 GMT --> </html>
Result:
Try it Yourself - © w3schools.com