Adding a prototype Property : Array : Language Basics JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Language Basics » Array »

 

Adding a prototype Property



<HTML>
<HEAD>
<TITLE>Array prototypes</TITLE>
<SCRIPT LANGUAGE="JavaScript1.1">
// add prototype to all Array objects
Array.prototype.sponsor = "DG"
a = new Array(5)
b = new Array(5)
c = new Array(5)
// override prototype property for one 'instance'
c.sponsor = "JS"
// this one picks up the original prototype
d = new Array(5)
</SCRIPT>
<BODY><H2>
<SCRIPT LANGUAGE="JavaScript">
document.write("Array a is brought to you by: " + a.sponsor + "<P>")
document.write("Array b is brought to you by: " + b.sponsor + "<P>")
document.write("Array c is brought to you by: " + c.sponsor + "<P>")
document.write("Array d is brought to you by: " + d.sponsor + "<P>")
</SCRIPT>
</H2>
</BODY>
</HTML>

           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Language Basics
» Array