forked from webplatform/webplatform.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
137 lines (129 loc) · 7.08 KB
/
Copy pathindex.html
File metadata and controls
137 lines (129 loc) · 7.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<!DOCTYPE html>
<html lang="en" dir="ltr" class="client-nojs with-toc">
<head>
<meta charset="UTF-8" />
<title>prototype · WebPlatform Docs</title>
<link rel="stylesheet" href="/assets/css/docs.css" />
<link rel="stylesheet" href="/assets/css/highlight.css" />
<link rel="shortcut icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width" />
<!--[if lt IE 7]><script src="/bower_components/ie7-js/lib/IE7.js"></script><![endif]-->
<!--[if lt IE 8]><script src="/bower_components/ie7-js/lib/IE8.js"></script><![endif]-->
<!--[if lt IE 9]><script src="/bower_components/ie7-js/lib/IE9.js"></script><![endif]-->
<!--[if lt IE 8]><link rel="stylesheet" href="/assets/css/ie7.css"><![endif]-->
<meta property="readiness" content="Ready to Use" />
<meta name="description" content="Returns a reference to the prototype for a class of array." />
<script src="/bower_components/jquery/dist/jquery.min.js"></script>
<script src="/bower_components/vue/dist/vue.min.js"></script>
</head>
<body class="mediawiki ltr sitedir-ltr skin-webplatform action-view">
<div class="readiness-state Ready_to_Use"><p>This page is <a>Ready to Use</a></p></div>
<header id="mw-head" class="noprint">
<div class="container">
<div id="p-logo">
<a href="/" title="Visit the home page"></a>
</div>
</div>
</header>
<nav id="sitenav">
<div class="container">
<ul class="links">
<li><a href="/" class="active">THE DOCS</a></li>
<li><a href="/docs/Community">CONNECT</a></li>
<li><a href="/docs/WPD/Contributors_Guide/">CONTRIBUTE</a></li>
<li><a href="/blog/">BLOG</a></li>
</ul>
</div>
</nav>
<div id="siteNotice">
<div id="localNotice" dir="ltr" lang="en">
<div class="notice" style="margin:10px auto; position: relative; width: 90%; max-width: 950px;">
<div style="padding: 10px; border-radius: 4px; background-color: rgb(249, 247, 243); box-shadow: 0px 0px 1px rgb(167, 169, 172);">
<strong>Notice:</strong> The WebPlatform project, supported by various stewards between 2012 and 2015, has been <b>discontinued</b>. This site is now available on <a href="https://github.com/webplatform/webplatform.github.io/">github</a>.
</div>
</div>
</div>
</div>
<div id="content" class="mw-body">
<div class="container">
<a id="top"></a>
<div class="tool-area">
<div id="hierarchy-menu">
<ol id="breadcrumb-info" class="breadcrumbs">
<li><a href="/">DOCS</a></li>
<li><a href="/docs/javascript/">javascript</a></li><li><a href="/docs/javascript/Array/">Array</a></li><li><a href="/docs/javascript/Array/prototype/">prototype</a></li>
</ol>
</div>
</div>
<div id="page">
<div id="page-content">
<div id="main-content">
<h1>prototype</h1>
<h2>Summary</h2>
<p>Returns a reference to the prototype for a class of array.</p>
<h2>Syntax</h2>
<pre><code>Array.prototype
</code></pre>
<h2>Examples</h2>
<p>The array argument is the name of an array.</p>
<p>Use the <strong>prototype</strong> property to provide a base set of functionality to a class of objects. New instances of an object “inherit” the behavior of the prototype assigned to that object.</p>
<p>For example, to add a method to the <strong>Array</strong> object that returns the value of the largest element of the array, declare the function, add it to <strong>Array.prototype</strong> , and then use it.</p>
<pre><code class="js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">array_max</span>(<span class="hljs-params"> </span>)</span>{
<span class="hljs-keyword">var</span> i, max = <span class="hljs-keyword">this</span>[<span class="hljs-number">0</span>];
<span class="hljs-keyword">for</span> (i = <span class="hljs-number">1</span>; i < <span class="hljs-keyword">this</span>.length; i++)
{
<span class="hljs-keyword">if</span> (max < <span class="hljs-keyword">this</span>[i])
max = <span class="hljs-keyword">this</span>[i];
}
<span class="hljs-keyword">return</span> max;
}
<span class="hljs-built_in">Array</span>.prototype.max = array_max;
<span class="hljs-keyword">var</span> myArray = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Array</span>(<span class="hljs-number">7</span>, <span class="hljs-number">1</span>, <span class="hljs-number">3</span>, <span class="hljs-number">11</span>, <span class="hljs-number">25</span>, <span class="hljs-number">9</span>
);
<span class="hljs-built_in">document</span>.write(myArray.max());
<span class="hljs-comment">// Output: 25</span>
</code></pre>
<h2>Remarks</h2>
<p>All intrinsic JavaScript objects have a <strong>prototype</strong> property that is read-only. Properties and methods may be added to the prototype, but the object may not be assigned a different prototype. However, user-defined objects may be assigned a new prototype.</p>
<p>The method and property lists for each intrinsic object in this language reference indicate which ones are part of the object’s prototype, and which are not.</p>
<h2>Requirements</h2>
<p>Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Also supported in Windows Store apps. See Version Information.</p>
<h2>Attributions</h2>
<ul>
<li><p>Microsoft Developer Network: <a href="http://msdn.microsoft.com/en-us/library/ie/jj155285(v=vs.94).aspx">Article</a></p>
</li>
</ul>
</div>
<div class="topics-nav">
<ul>
<li><a href="/docs/Beginners">Beginners</a></li>
<li><a href="/docs/concepts">Concepts</a></li>
<li><a href="/docs/html">HTML</a></li>
<li><a href="/docs/css">CSS</a></li>
<li><a href="/docs/concepts/accessibility">Accessibility</a></li>
<li><a href="/docs/javascript">JavaScript</a></li>
<li><a href="/docs/dom">DOM</a></li>
<li><a href="/docs/svg">SVG</a></li>
</ul>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
<footer id="mw-footer">
<div class="container">
<div id="footer-wordmark">
<a href="https://github.com/webplatform/docs/blob/master/LICENSE.md" class="license">
<img src="/assets/cc-by-black.svg" width="120" height="42" alt="Content available under CC-BY, except where otherwise noted.">
</a>
<a href="/"><span id="footer-title">WebPlatform<span id="footer-title-light">.org</span></span></a>
</div>
<!-- ul class="stewards">
<li class="steward-w3c"><a href="/stewards/w3c">W3C</a></li>
</ul -->
</div>
</footer>
<script src="/assets/js/docs.js"></script>
</body>
</html>