blob: 9b8745086b11c3b780fc976bbe3770bbfd7268cb (
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
65
|
---
title: WebAssembly.Table.prototype.grow()
slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/grow
tags:
- API
- JavaScript
- Méthode
- Reference
- WebAssembly
- table
translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/grow
original_slug: Web/JavaScript/Reference/Objets_globaux/WebAssembly/Table/grow
---
{{JSRef}}
La méthode **`grow()`**, rattachée au prototype de {{jsxref("WebAssembly.Table")}}, permet d'augmenter la taille du tableau WebAssembly d'un nombre d'éléments donné.
## Syntaxe
table.grow(nombre);
### Paramètres
- `nombre`
- : Le nombre d'éléments qu'on souhaite ajouter au tableau.
### Valeur de retour
La taille du tableau avant l'agrandissement.
### Exceptions
Si l'opération `grow()` échoue, pour quelque raison que ce soit, une exception {{jsxref("RangeError")}} sera levée.
## Exemples
Dans l'exemple qui suit, on crée une instance de `Table` pour représenter un tableau WebAssembly avec une taille initiale de 2 et une taille maximale de 10.
```js
var table = new WebAssembly.Table({ element: "anyfunc", initial: 2, maximum: 10 });
```
On étend ensuite le tableau d'une unité en utilisant la méthode `grow()` :
```js
console.log(table.length); // "2"
console.log(table.grow(1)); // "2"
console.log(table.length); // "3"
```
## Spécifications
| Spécification | État | Commentaires |
| ---------------------------------------------------------------------------------------------------- | ------------------------------------ | -------------------------------------------------- |
| {{SpecName('WebAssembly JS', '#webassemblytableprototypegrow', 'grow()')}} | {{Spec2('WebAssembly JS')}} | Brouillon de définition initiale pour WebAssembly. |
## Compatibilité des navigateurs
{{Compat("javascript.builtins.WebAssembly.Table.grow")}}
## Voir aussi
- [Le portail WebAssembly](/fr/docs/WebAssembly)
- [Les concepts relatifs à WebAssembly](/fr/docs/WebAssembly/Concepts)
- [Utiliser l'API JavaScript WebAssembly](/fr/docs/WebAssembly/Using_the_JavaScript_API)
|