aboutsummaryrefslogtreecommitdiff
path: root/files/zh-tw/conflicting/web/javascript/reference/global_objects/promise/index.html
blob: 594219280350d5f3e45d05599bcaf97878b90e0e (plain)
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
---
title: Promise.prototype
slug: conflicting/Web/JavaScript/Reference/Global_Objects/Promise
translation_of: Web/JavaScript/Reference/Global_Objects/Promise
translation_of_original: Web/JavaScript/Reference/Global_Objects/Promise/prototype
original_slug: Web/JavaScript/Reference/Global_Objects/Promise/prototype
---
<div>{{JSRef}}</div>

<p><code><strong>Promise</strong></code><strong><code>.prototype</code></strong> 屬性代表了 {{jsxref("Promise")}} 建構式的原型物件。</p>

<div>{{js_property_attributes(0,0,0)}}</div>

<h2 id="描述">描述</h2>

<p>所有 {{jsxref("Promise")}} 實例都繼承自 {{jsxref("Promise.prototype")}}。您可以使用建構式的原型物件來增加屬性或方法到所有的 <code>Promise</code> 實例。</p>

<h2 id="屬性">屬性</h2>

<dl>
 <dt><code>Promise.prototype.constructor</code></dt>
 <dd>回傳一個建立實例原型(instance's prototype)的函式。預設為 {{jsxref("Promise")}} 函數。</dd>
</dl>

<h2 id="方法">方法</h2>

<dl>
 <dt>{{jsxref("Promise.catch", "Promise.prototype.catch(onRejected)")}}</dt>
 <dd>繫結一個拒絕回呼函式(rejection handler callback)到 promise,當它被呼叫時回傳一個以回傳值作解析的新 promise,或者當 promise 被實現時以原值作解析。</dd>
 <dt>{{jsxref("Promise.then", "Promise.prototype.then(onFulfilled, onRejected)")}}</dt>
 <dd>繫結實現或拒絕回呼函式到 promise,回傳一個以 handler 之回傳值作解析的新 promise,或者當 promise 未處理(not handled)時以原值作解析。(i.e. 比如相關聯的 <code>onFulfilled</code> 或 <code>onRejected</code> 不是函式。)</dd>
</dl>

<h2 id="規範">規範</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('ES6', '#sec-promise.prototype', 'Promise.prototype')}}</td>
   <td>{{Spec2('ES6')}}</td>
   <td>Initial definition.</td>
  </tr>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-promise.prototype', 'Promise.prototype')}}</td>
   <td>{{Spec2('ESDraft')}}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

<h2 id="瀏覽器相容性">瀏覽器相容性</h2>

<p>{{Compat("javascript/promise","Promise.prototype")}}</p>

<h2 id="參見">參見</h2>

<ul>
 <li>{{jsxref("Promise")}}</li>
</ul>