From 844f5103992238c0c23203286dad16a466e89c97 Mon Sep 17 00:00:00 2001 From: julieng Date: Tue, 3 Aug 2021 08:03:09 +0200 Subject: move *.html to *.md --- .../global_objects/reflect/apply/index.html | 97 ---------------------- .../global_objects/reflect/apply/index.md | 97 ++++++++++++++++++++++ 2 files changed, 97 insertions(+), 97 deletions(-) delete mode 100644 files/fr/web/javascript/reference/global_objects/reflect/apply/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/reflect/apply/index.md (limited to 'files/fr/web/javascript/reference/global_objects/reflect/apply') diff --git a/files/fr/web/javascript/reference/global_objects/reflect/apply/index.html b/files/fr/web/javascript/reference/global_objects/reflect/apply/index.html deleted file mode 100644 index e341856408..0000000000 --- a/files/fr/web/javascript/reference/global_objects/reflect/apply/index.html +++ /dev/null @@ -1,97 +0,0 @@ ---- -title: Reflect.apply() -slug: Web/JavaScript/Reference/Global_Objects/Reflect/apply -tags: - - ECMAScript 2015 - - JavaScript - - Méthode - - Reference - - Reflect -translation_of: Web/JavaScript/Reference/Global_Objects/Reflect/apply -original_slug: Web/JavaScript/Reference/Objets_globaux/Reflect/apply ---- -
{{JSRef}}
- -

La méthode statique Reflect.apply() permet d'appeler une fonction cible avec des arguments donnés.

- -
{{EmbedInteractiveExample("pages/js/reflect-apply.html")}}
- -

Syntaxe

- -
Reflect.apply(cible, argumentThis, listeArguments)
-
- -

Paramètres

- -
-
cible
-
La fonction cible à appeler.
-
argumentThis
-
La valeur fournie pour this lors de l'appel à cible.
-
listeArguments
-
Un objet semblable à un tableau qui définit les arguments à passer à cible. S'il vaut {{jsxref("null")}} ou {{jsxref("undefined")}}, aucun argument ne sera passé.
-
- -

Valeur de retour

- -

Le résultat de l'appel de la fonction cible indiquée avec la valeur this et les arguments indiqués.

- -

Exceptions levées

- -

Une exception {{jsxref("TypeError")}}, si cible ne peut pas être appelée.

- -

Description

- -

Avec ES5, on utilise généralement {{jsxref("Function.prototype.apply()")}} pour appeler une fonction avec une valeur this donnée et des arguments donnés.

- -
Function.prototype.apply.call(Math.floor, undefined, [1.75]);
- -

Reflect.apply permet de rendre cela plus concis et facile à comprendre.

- -

Exemples

- -
Reflect.apply(Math.floor, undefined, [1.75]);
-// 1;
-
-Reflect.apply(String.fromCharCode, undefined, [104, 101, 108, 108, 111]);
-// "hello"
-
-Reflect.apply(RegExp.prototype.exec, /ab/, ["confabulation"]).index;
-// 4
-
-Reflect.apply("".charAt, "poneys", [3]);
-// "e"
-
- -

Spécifications

- - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES2015', '#sec-reflect.apply', 'Reflect.apply')}}{{Spec2('ES2015')}}Définition initiale.
{{SpecName('ESDraft', '#sec-reflect.apply', 'Reflect.apply')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

{{Compat("javascript.builtins.Reflect.apply")}}

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/reflect/apply/index.md b/files/fr/web/javascript/reference/global_objects/reflect/apply/index.md new file mode 100644 index 0000000000..e341856408 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/reflect/apply/index.md @@ -0,0 +1,97 @@ +--- +title: Reflect.apply() +slug: Web/JavaScript/Reference/Global_Objects/Reflect/apply +tags: + - ECMAScript 2015 + - JavaScript + - Méthode + - Reference + - Reflect +translation_of: Web/JavaScript/Reference/Global_Objects/Reflect/apply +original_slug: Web/JavaScript/Reference/Objets_globaux/Reflect/apply +--- +
{{JSRef}}
+ +

La méthode statique Reflect.apply() permet d'appeler une fonction cible avec des arguments donnés.

+ +
{{EmbedInteractiveExample("pages/js/reflect-apply.html")}}
+ +

Syntaxe

+ +
Reflect.apply(cible, argumentThis, listeArguments)
+
+ +

Paramètres

+ +
+
cible
+
La fonction cible à appeler.
+
argumentThis
+
La valeur fournie pour this lors de l'appel à cible.
+
listeArguments
+
Un objet semblable à un tableau qui définit les arguments à passer à cible. S'il vaut {{jsxref("null")}} ou {{jsxref("undefined")}}, aucun argument ne sera passé.
+
+ +

Valeur de retour

+ +

Le résultat de l'appel de la fonction cible indiquée avec la valeur this et les arguments indiqués.

+ +

Exceptions levées

+ +

Une exception {{jsxref("TypeError")}}, si cible ne peut pas être appelée.

+ +

Description

+ +

Avec ES5, on utilise généralement {{jsxref("Function.prototype.apply()")}} pour appeler une fonction avec une valeur this donnée et des arguments donnés.

+ +
Function.prototype.apply.call(Math.floor, undefined, [1.75]);
+ +

Reflect.apply permet de rendre cela plus concis et facile à comprendre.

+ +

Exemples

+ +
Reflect.apply(Math.floor, undefined, [1.75]);
+// 1;
+
+Reflect.apply(String.fromCharCode, undefined, [104, 101, 108, 108, 111]);
+// "hello"
+
+Reflect.apply(RegExp.prototype.exec, /ab/, ["confabulation"]).index;
+// 4
+
+Reflect.apply("".charAt, "poneys", [3]);
+// "e"
+
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('ES2015', '#sec-reflect.apply', 'Reflect.apply')}}{{Spec2('ES2015')}}Définition initiale.
{{SpecName('ESDraft', '#sec-reflect.apply', 'Reflect.apply')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +

{{Compat("javascript.builtins.Reflect.apply")}}

+ +

Voir aussi

+ + -- cgit v1.2.3-54-g00ecf