Esta tradução está incompleta. Ajude atraduzir este artigo.
This is an experimental technology, part of the ECMAScript 6 (Harmony) proposal.
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future version of browsers as the spec changes.
Sumário
A propriedade Promise
.prototype
representa o protótipo para o construtor Promise
.
Property attributes of Promise.prototype |
|
---|---|
Writable | no |
Enumerable | no |
Configurable | no |
Descrição
Promise
instância herdada de Promise.prototype
. Você pode usar o objeto construtor para adicionar propriedades ou métodos para todas as instancias de Promise
.
Properties
-
Promise.prototype.constructor
-
Retorna a função que cria uma instância. Isso é a função padrão
Promise
.
Métodos
-
Promise.prototype.catch(onRejected)
- Adiciona um callback que trata rejeçãopara a promise e, retorna uma nova promise resolvendo o valor retornado do callback, se ele for chamado, ou para seu valor original de conclusão se a promise for realizada.
-
Promise.prototype.then(onFulfilled, onRejected)
- Adiciona os métodos de tratamento da realização e rejeiçãoda promise e, retorna uma nova promise resolvendo para o valor do método chamado.
Especificações
Specification | Status | Comment |
---|---|---|
ECMAScript 6 (ECMA-262) The definition of 'Promise.prototype' in that specification. |
Release Candidate | Initial definition. |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 32 | 24.0 (24.0) as Future 25.0 (25.0) as Promise behind a flag[1]29.0 (29.0) by default |
Não suportado | 19 | 7.1 |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|
Basic support | Não suportado | 24.0 (24.0) as Future 25.0 (25.0) as Promise behind a flag[1]29.0 (29.0) by default |
Não suportado | Não suportado | iOS 8 | 32 |
[1] Gecko 24 has an experimental implementation of Promise
, under the initial name of Future
. It got renamed to its final name in Gecko 25, but disabled by default behind the flag dom.promise.enabled
. Bug 918806 enabled Promises by default in Gecko 29.