From 0c7a4c8d1d44f4c89b1861bd91652df9d76d90e6 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Thu, 27 Jul 2023 14:21:14 -0700 Subject: [PATCH 01/30] fr: Synchronize /Web/CSS/Shorthand_properties with upstream (#14637) * fr: Replace tables in CSS shorthand properties page * Update (and slightly improve) the article based on current en-US version * now it should be even prettier * Minor typofix --------- Co-authored-by: SphinxKnight Co-authored-by: Carolyn Wu --- .../fr/web/css/shorthand_properties/index.md | 305 ++++++++++-------- 1 file changed, 179 insertions(+), 126 deletions(-) diff --git a/files/fr/web/css/shorthand_properties/index.md b/files/fr/web/css/shorthand_properties/index.md index 848d0d75a0cdef..9c75697b945e48 100644 --- a/files/fr/web/css/shorthand_properties/index.md +++ b/files/fr/web/css/shorthand_properties/index.md @@ -1,138 +1,106 @@ --- title: Propriétés raccourcies slug: Web/CSS/Shorthand_properties -translation_of: Web/CSS/Shorthand_properties +l10n: + sourceCommit: be7a098e6af7b820c06a2d5169a9221ee2065e82 --- {{CSSRef}} -_Les propriétés raccourcies sont des propriétés CSS qui permettent de définir la valeur de plusieurs propriétés via une seule déclaration. En manipulant des propriétés raccourcies, un développeur web peut créer des feuilles de style plus concises et plus lisibles, améliorant ainsi la maintenabilité_. - -La spécification CSS définit les propriétés raccourcies en regroupant la définition des propriétés agissant sur le même aspect de l'élément. Ainsi, la propriété {{cssxref("background")}} est une propriété raccourcie qui permettra de définir {{cssxref("background-color")}}, {{cssxref("background-image")}}, {{cssxref("background-repeat")}} et {{cssxref("background-position")}}. De même, les propriétés fréquemment utilisées pour la mise en forme des polices de caractères (_font_) peuvent être définies via la propriété raccourcie {{cssxref("font")}} et celles qui concernent la marge avec la propriété raccourcie {{cssxref("margin")}}. - -## Quelques cas aux limites épineux - -Bien que les propriétés raccourcies soient pratiques à utiliser. Il est nécessaire de noter certains éléments pour parer aux cas étranges qui peuvent survenir : - -1. Une valeur qui n'est pas définie pour la propriété raccourcie **sera réinitialisée avec sa valeur initiale**. Cela peut sembler anecdotique mais attention aux valeurs qui seront surchargées et à l'ordre des déclarations. Ainsi : - - ```css - background-color: red; - background: url(images/bg.gif) no-repeat top right; - ``` - - ne définira pas la couleur d'arrière-plan en rouge mais avec la valeur par défaut de {{cssxref("background-color")}} `transparent` car la deuxième déclaration prend le pas sur la première. - -2. L'héritage des propriétés ne peut avoir lieu qu'avec les propriétés individuelles . En effet, les valeurs absentes sont remplacées par leurs valeurs initiales et il est donc impossible d'hériter des valeurs en les omettant. Le mot-clé {{cssxref("inherit")}} pourra être appliqué à une propriété mais ce sera sur l'ensemble et non pour une valeur donnée ou une autre. Ainsi, pour utiliser une valeur héritée sur une propriété spécifique, il faudra utiliser cette propriété « longue » avec le mot-clé `inherit.` -3. Les propriétés raccourcies n'ont pas d'ordre spécifique pour trier les valeurs des propriétés détaillées qu'elles remplacent. Cela fonctionne sans problème lorsque les différentes propriétés utilisent différents types de valeurs car l'ordre n'a alors aucune importance. Toutefois, lorsque les différentes propriétés peuvent prendre les mêmes valeurs, cela n'est pas si simple. On peut regrouper les différents cas en deux catégories distinctes : - - 1. Les propriétés raccourcies qui gèrent les bords d'une boîte telles que {{cssxref("border-style")}}, {{cssxref("margin")}} ou {{cssxref("padding")}}. Elles utilisent une méthode constante selon qu'elles reçoivent 1 à 4 valeurs : - - - - - - - - - - - - - - - - - - - - -
border1.png - 1 valeur : border-width: 1em — La valeur unique - s'adresse à tous les côtés. -
border2.png - 2 valeurs : border-width: 1em 2em — La première - valeur représente les côtés horizontaux en haut et en bas. La seconde - valeur représente les côtés verticaux, à gauche et à droite. -
border3.png - 3 valeurs : border-width: 1em 2em 3em — La - première valeur représente le côté haut, la deuxième les côtés gauche et - droit et la troisième représente le côté bas. -
border4.png -

- 4 valeurs : border-width: 1em 2em 3em 4em — Les - quatre valeurs représentent respectivement le côté haut, le côté - droit, le côté bas et le côté haut, toujours dans cet ordre (le sens - horaire). -

-
- - 2. De la même façon, les propriétés raccourcies relatives aux coins d'une boîte comme {{cssxref("border-radius")}} utilisent une méthode constante selon qu'elles reçoivent 1 à 4 valeurs : - - - - - - - - - - - - - - - - - - - - -
corner1.png - 1 valeur : border-radius: 1em — La valeur - s'applique à tous les coins. -
corner2.png - 2 valeurs : border-radius: 1em 2em — La première - valeur s'applique aux coins en haut à gauche et en bas à droite et la - deuxième s'applique aux coins en haut à droite et en bas à gauche. -
corner3.png - 3 valeurs : border-radius: 1em 2em 3em — La - première valeur représente le coin en haut à gauche, la deuxième - représente les coins en haut à droite et en bas à gauche et la troisième - valeur représente le coin en bas à droite. -
corner4.png -

- 4 valeurs : border-radius: 1em 2em 3em 4em — Les - quatre valeurs s'appliquent respectivement au coin en haut à gauche, - en haut à droite, en bas à droite et en bas à gauche, toujours dans - cet ordre (le sens horaire). -

-
- -## Les propriétés concernant l'arrière-plan - -Lorsqu'on décrit un arrière-plan avec les propriétés suivantes : +**_Les propriétés raccourcies_** sont des propriétés CSS permettant de paramétrer simultanément les valeurs de plusieurs propriétés CSS. Utiliser une propriété raccourcie permet d'obtenir des feuilles de style plus concises (et souvent plus lisibles). + +La spécification CSS définit des propriétés raccourcies qui regroupent des propriétés courantes portant sur le même thème. Ainsi, la propriété [`background`](/fr/docs/Web/CSS/background) est une propriété raccourcie qui permet de définir les valeurs de [`background-color`](/fr/docs/Web/CSS/background-color), [`background-image`](/fr/docs/Web/CSS/background-image), [`background-repeat`](/fr/docs/Web/CSS/background-repeat), et [`background-position`](/fr/docs/Web/CSS/background-position). De la même façon, la plupart des propriétés communes relatives aux polices peuvent être définies grâce à la propriété raccourcie [`font`](/fr/docs/Web/CSS/font), et celles portant sur les marges autour d'une boîte peuvent être paramétrées grâce à la propriété raccourcie [`margin`](/fr/docs/Web/CSS/margin). + +## Quelques cas aux limites délicats + +Il existe quelques cas aux limites qu'il convient de garder à l'esprit lorsqu'on utilise les propriétés raccourcies. + +### L'omission de propriétés + +Lorsqu'une valeur n'est pas fournie dans la propriété raccourcie, la propriété correspondante utilise alors sa valeur initiale. Cela signifie que la déclaration de la propriété raccourcie **l'emportera** sur les valeurs des éventuelles déclarations précédentes. Prenons par exemple : + +```css +p { + background-color: red; + background: url(images/bg.gif) no-repeat left top; +} +``` + +La couleur de l'arrière-plan ne sera pas rouge (`red`), ce sera la valeur par défaut de [`background-color`](/fr/docs/Web/CSS/background-color) qui sera utilisée : `transparent`. + +Seules les propriétés détaillées permettent l'héritage. Comme les valeurs manquantes dans une déclaration raccourcie sont remplacées par les valeurs initiales correspondantes, il est impossible de permettre l'héritage des propriétés détaillées en les omettant. Le mot-clé `inherit` peut être appliqué à une propriété, mais uniquement dans son ensemble et non comme un mot-clé pour une valeur parmi d'autres. Cela signifie que la seule façon pour qu'une valeur donnée soit héritée consiste à utiliser la propriété détaillée avec le mot-clé `inherit`. + +### L'ordre des propriétés + +Les propriétés raccourcies essaient de ne pas imposer un ordre spécifique pour les valeurs des propriétés qu'elles synthétisent. Cela fonctionne bien lorsque les propriétés détaillées sont de différents types, l'ordre n'ayant alors pas d'importance. En revanche, cela ne peut pas fonctionner si plusieurs des propriétés détaillées permettent d'utiliser des mêmes valeurs. + +Il y a deux thèmes pour lesquels l'ordre est important : + +- Les propriétés relatives aux bords d'une boîte, comme [`border-style`](/fr/docs/Web/CSS/border-style), [`margin`](/fr/docs/Web/CSS/margin) ou [`padding`](/fr/docs/Web/CSS/padding). +- Les propriétés relatives aux coins d'une boîte, comme [`border-radius`](/fr/docs/Web/CSS/border-radius) + +#### Propriétés pour les bords d'une boîte + +Les propriétés raccourcies qui portent sur les bords d'une boîte, comme [`border-style`](/fr/docs/Web/CSS/border-style), [`margin`](/fr/docs/Web/CSS/margin) ou [`padding`](/fr/docs/Web/CSS/padding), utilisent toutes une syntaxe cohérente ayant 1 à 4 valeurs : + +- Syntaxe avec une valeur + + - : `border-width: 1em` — la valeur représente tous les bords : ![Les bords de la boîte avec une syntaxe utilisant une valeur.](border1.png) + +- Syntaxe avec deux valeurs + + - : `border-width: 1em 2em` — la première valeur représente les bords sur l'axe vertical, c'est-à-dire les bords haut et bas ; la seconde représente les bords sur l'axe horizontal, c'est-à-dire les bords gauche et droit : ![Les bords de la boîte avec une syntaxe utilisant deux valeurs.](border2.png) + +- Syntaxe avec trois valeurs + + - : `border-width: 1em 2em 3em` — la première valeur représente le bord haut, la deuxième représente les bords de l'axe horizontal : gauche et droit, et la troisième représente le bord bas : ![Les bords de la boîte avec une syntaxe utilisant trois valeurs.](border3.png) + +- Syntaxe avec quatre valeurs + - : `border-width: 1em 2em 3em 4em` — les quatre valeurs représentent respectivement les bords haut, droit, bas et gauche (et toujours dans cet ordre), soit un sens horaire à partir du haut : ![Les bords de la boîte avec une syntaxe utilisant quatre valeurs.](border4.png) Un moyen mnémotechnique pour mémoriser l'ordre consiste à visualiser le mouvement des aiguilles sur une horloge : la première valeur (ici `1em`) commence à midi, puis la deuxième (ici `2em`) à 15h, puis la troisième (ici `3em`) à 18h, et la dernière (`4em` dans notre exemple) à 21h. + +#### Propriétés pour les coins d'une boîte + +De la même manière, les propriétés raccourcies qui portent sur les coins d'une boîte (par exemple [`border-radius`](/fr/docs/Web/CSS/border-radius)) utilisent toutes une syntaxe cohérente ayant 1 à 4 valeurs : + +- Syntaxe avec une valeur + + - : `border-radius: 1em` — la valeur unique représente tous les coins : ![Les coins de la boîte avec une syntaxe utilisant une valeur.](corner1.png) + +- Syntaxe avec deux valeurs + + - : `border-radius: 1em 2em` — la première valeur porte sur les coins supérieur gauche et inférieur droit, la seconde porte sur les coins supérieur droit et inférieur gauche : ![Les coins de la boîte avec une syntaxe utilisant deux valeurs.](corner2.png) + +- Syntaxe avec trois valeurs + + - : `border-radius: 1em 2em 3em` — la première valeur représente le coin supérieur gauche, la deuxième les coins supérieur droit et inférieur gauche, la troisième le coin inférieur droit : ![Les coins de la boîte avec une syntaxe utilisant trois valeurs.](corner3.png) + +- Syntaxe avec quatre valeurs + - : `border-radius: 1em 2em 3em 4em` — les quatre valeurs représentent respectivement les coins supérieur gauche, supérieur droit, inférieur droit et inférieur gauche (et toujours dans cet ordre), soit un sens horaire à partir du coin supérieur gauche : ![Les coins de la boîte avec une syntaxe utilisant quatre valeurs.](corner4.png) + +## Propriétés pour l'arrière-plan + +Prenons un arrière-plan déclaré comme tel : ```css background-color: #000; background-image: url(images/bg.gif); background-repeat: no-repeat; -background-position: top right; +background-position: left top; ``` -On peut le faire de façon plus concise grâce à la propriété raccourcie. Voici la déclaration équivalent : +On pourra synthétiser ces quatre déclarations en une : ```css -background: #000 url(images/bg.gif) no-repeat top right; +background: #000 url(images/bg.gif) no-repeat left top; ``` -> **Note :** Pour être tout à fait précis, la forme raccourcie présentée juste avant est équivalente aux propriétés détaillées qui précèdent auxquelles on ajoute `background-attachment: scroll` et d'autres propriétés avec CSS3). +Voir [`background`](/fr/docs/Web/CSS/background) pour plus d'informations. -Pour plus d'informations, voir {{cssxref("background")}}. +> **Note :** La forme raccourcie correspond plus précisément aux propriétés détaillées indiquées ici avec également, `background-attachment: scroll` et d'autres propriétés supplémentaires. -## Les propriétés liées à la police (_font_) +## Propriétés typographiques -Les déclarations suivantes : +Prenons les déclarations suivantes : ```css font-style: italic; @@ -142,7 +110,7 @@ line-height: 1.2; font-family: Arial, sans-serif; ``` -Peuvent être synthétisées en une seule déclaration avec la propriété raccourcie : +On pourra les raccourcir ainsi : ```css font: @@ -150,11 +118,13 @@ font: sans-serif; ``` -> **Note :** Pour être tout à fait précis, la déclaration raccourcie précédente est équivalente aux déclarations détaillées ci-avant auxquelles on ajoutera `font-variant: normal` et `font-size-adjust: none` (CSS2.0 / CSS3), `font-stretch: normal` (CSS3). +Voir [`font`](/fr/docs/Web/CSS/font) pour plus d'informations sur cette propriété. + +> **Note :** Cette déclaration raccourcie avec [`font`](/fr/docs/Web/CSS/font) est en réalité équivalente aux déclarations détaillées présentes ici, avec en plus `font-variant: normal`, `font-size-adjust: none`, et `font-stretch: normal`. -## Les propriétés liées aux bordures +## Propriétés pour les bordures -Avec les bordures, la largeur, la couleur et le style peuvent être regroupés en une seule déclaration. Par exemple, +Les épaisseurs, couleurs et styles d'une bordure peuvent être exprimés avec une seule déclaration. Si on part du fragment de CSS suivant : ```css border-width: 1px; @@ -162,15 +132,17 @@ border-style: solid; border-color: #000; ``` -peut être écrit ainsi : +On pourra le simplifier de la façon suivante : ```css border: 1px solid #000; ``` -## Les propriétés liées à la marge et au remplissage (_padding_) +Voir [`border`](/fr/docs/Web/CSS/border) pour plus d'informations sur cette propriété. -Les propriétés raccourcies agissant sur la boîte de marge ou sur la boîte de remplissage (_padding_) fonctionnent de la même façon. Ainsi, les déclarations CSS suivantes : +## Propriétés pour les marges et le remplissage (padding) + +Les propriétés raccourcies pour les marges et le remplissage fonctionnent de la même façon. La propriété [`margin`](/fr/docs/Web/CSS/margin) permet une syntaxe avec une, deux, trois ou quatre valeurs. Prenons les déclarations de ce fragment : ```css margin-top: 10px; @@ -179,19 +151,100 @@ margin-bottom: 10px; margin-left: 5px; ``` -sont équivalentes à la déclaration qui suit (on notera que les valeurs sont ordonnés dans le sens horaire : haut, droit, bas, gauche ; un moyen mnémotechnique est d'utiliser l'acronyme anglais TRBL qui ressemble à _trouble_) : +On pourra les condenser en une seule déclaration équivalente (on notera l'ordre dans le sens horaire : haut, droit, bas, gauche) : ```css margin: 10px 5px 10px 5px; ``` +## Propriétés de position + +Pour positionner un élément, plutôt que d'utiliser les propriétés détaillées `top`, `right`, `bottom` et `left` comme ceci : + +```css +top: 0; +right: 20px; +bottom: 0; +left: 20px; +``` + +On pourra utiliser la propriété [`inset`](/fr/docs/Web/CSS/inset) qui les synthétise : + +```css +inset: 0 20px 0 20px; +``` + +À l'instar des marges et du remplissage, les valeurs suivent l'ordre horaire (haut, droit, bas, puis gauche). + ## La propriété raccourcie universelle -CSS fournit une propriété raccourcie qui permet d'appliquer une même valeur à l'ensemble des propriétés du document : {{cssxref("all")}}. +CSS fournit une propriété raccourcie universelle, [`all`](/fr/docs/Web/CSS/all), qui applique sa valeur à toutes les propriétés du document. Elle permet ainsi de changer le modèle d'héritage des propriétés. -Voir l'article sur [la cascade et l'héritage](/fr/docs/Learn/CSS/Building_blocks/Cascade_and_inheritance) pour plus d'informations sur le fonctionnement de l'héritage. +Voir les articles [La cascade et l'héritage](/fr/docs/Learn/CSS/Building_blocks/Cascade_and_inheritance) ou [Introduction à la cascade CSS](/fr/docs/Web/CSS/Cascade) pour plus d'informations sur le fonctionnement de l'héritage en CSS. ## Voir aussi -- [La référence CSS](/fr/docs/Web/CSS/Reference) -- Les propriétés raccourcies : {{cssxref("animation")}}, {{cssxref("background")}}, {{cssxref("border")}}, {{cssxref("border-bottom")}}, {{cssxref("border-color")}}, {{cssxref("border-left")}}, {{cssxref("border-radius")}}, {{cssxref("border-right")}}, {{cssxref("border-style")}}, {{cssxref("border-top")}}, {{cssxref("border-width")}}, {{cssxref("column-rule")}}, {{cssxref("columns")}}, {{cssxref("flex")}}, {{cssxref("flex-flow")}}, {{cssxref("font")}}, {{cssxref("grid")}}, {{cssxref("grid-area")}}, {{cssxref("grid-column")}}, {{cssxref("grid-row")}}, {{cssxref("grid-template")}}, {{cssxref("list-style")}}, {{cssxref("margin")}}, {{cssxref("offset")}}, {{cssxref("outline")}}, {{cssxref("overflow")}}, {{cssxref("padding")}}, {{cssxref("place-content")}}, {{cssxref("place-items")}}, {{cssxref("place-self")}}, {{cssxref("text-decoration")}}, {{cssxref("transition")}} +- Les concepts fondamentaux de CSS : + - [La syntaxe CSS](/fr/docs/Web/CSS/Syntax) + - [Les règles @](/fr/docs/Web/CSS/At-rule) + - [Les commentaires](/fr/docs/Web/CSS/Comments) + - [La spécificité](/fr/docs/Web/CSS/Specificity) + - [L'héritage](/fr/docs/Web/CSS/Inheritance) + - [Le modèle de boîtes](/fr/docs/Web/CSS/CSS_box_model/Introduction_to_the_CSS_box_model) + - [Les modes de disposition](/fr/docs/Web/CSS/Layout_mode) + - [Les modèles de formatage visuel](/fr/docs/Web/CSS/Visual_formatting_model) + - [La fusion des marges](/fr/docs/Web/CSS/CSS_box_model/Mastering_margin_collapsing) + - Les différentes valeurs + - [Les valeurs initiales](/fr/docs/Web/CSS/initial_value) + - [Les valeurs calculées](/fr/docs/Web/CSS/computed_value) + - [Les valeurs utilisées](/fr/docs/Web/CSS/used_value) + - [Les valeurs réelles](/fr/docs/Web/CSS/actual_value) + - [La syntaxe de définition des valeurs](/fr/docs/Web/CSS/Value_definition_syntax) + - [Les éléments remplacés](/fr/docs/Web/CSS/Replaced_element) +- Les propriétés raccourcies : + - [`all`](/fr/docs/Web/CSS/all) + - [`animation`](/fr/docs/Web/CSS/animation) + - [`background`](/fr/docs/Web/CSS/background) + - [`border`](/fr/docs/Web/CSS/border) + - [`border-block-end`](/fr/docs/Web/CSS/border-block-end) + - [`border-block-start`](/fr/docs/Web/CSS/border-block-start) + - [`border-bottom`](/fr/docs/Web/CSS/border-bottom) + - [`border-color`](/fr/docs/Web/CSS/border-color) + - [`border-image`](/fr/docs/Web/CSS/border-image) + - [`border-inline-end`](/fr/docs/Web/CSS/border-inline-end) + - [`border-inline-start`](/fr/docs/Web/CSS/border-inline-start) + - [`border-left`](/fr/docs/Web/CSS/border-left) + - [`border-radius`](/fr/docs/Web/CSS/border-radius) + - [`border-right`](/fr/docs/Web/CSS/border-right) + - [`border-style`](/fr/docs/Web/CSS/border-style) + - [`border-top`](/fr/docs/Web/CSS/border-top) + - [`border-width`](/fr/docs/Web/CSS/border-width) + - [`column-rule`](/fr/docs/Web/CSS/column-rule) + - [`columns`](/fr/docs/Web/CSS/columns) + - [`contain-intrinsic-size`](/fr/docs/Web/CSS/contain-intrinsic-size) + - [`flex`](/fr/docs/Web/CSS/flex) + - [`flex-flow`](/fr/docs/Web/CSS/flex-flow) + - [`font`](/fr/docs/Web/CSS/font) + - [`gap`](/fr/docs/Web/CSS/gap) + - [`grid`](/fr/docs/Web/CSS/grid) + - [`grid-area`](/fr/docs/Web/CSS/grid-area) + - [`grid-column`](/fr/docs/Web/CSS/grid-column) + - [`grid-row`](/fr/docs/Web/CSS/grid-row) + - [`grid-template`](/fr/docs/Web/CSS/grid-template) + - [`inset`](/fr/docs/Web/CSS/inset) + - [`list-style`](/fr/docs/Web/CSS/list-style) + - [`margin`](/fr/docs/Web/CSS/margin) + - [`mask`](/fr/docs/Web/CSS/mask) + - [`offset`](/fr/docs/Web/CSS/offset) + - [`outline`](/fr/docs/Web/CSS/outline) + - [`overflow`](/fr/docs/Web/CSS/overflow) + - [`padding`](/fr/docs/Web/CSS/padding) + - [`place-content`](/fr/docs/Web/CSS/place-content) + - [`place-items`](/fr/docs/Web/CSS/place-items) + - [`place-self`](/fr/docs/Web/CSS/place-self) + - [`scroll-margin`](/fr/docs/Web/CSS/scroll-margin) + - [`scroll-padding`](/fr/docs/Web/CSS/scroll-padding) + - [`scroll-timeline`](/fr/docs/Web/CSS/scroll-timeline) + - [`text-decoration`](/fr/docs/Web/CSS/text-decoration) + - [`text-emphasis`](/fr/docs/Web/CSS/text-emphasis) + - [`transition`](/fr/docs/Web/CSS/transition) From e0626636f6f083bf64ef18a9a84081c523c9f256 Mon Sep 17 00:00:00 2001 From: SphinxKnight Date: Thu, 27 Jul 2023 23:43:42 +0200 Subject: [PATCH 02/30] Fix #14405 (#14540) * First pass * Typofix * Translate images * Compress images * Small typofixes/nitpicking --------- Co-authored-by: Carolyn Wu --- .../web/http/content_negotiation/httpnego.png | Bin 0 -> 54275 bytes .../http/content_negotiation/httpnego3.png | Bin 0 -> 117319 bytes .../content_negotiation/httpnegoserver.png | Bin 0 -> 84570 bytes .../fr/web/http/content_negotiation/index.md | 114 +++++++++--------- 4 files changed, 55 insertions(+), 59 deletions(-) create mode 100644 files/fr/web/http/content_negotiation/httpnego.png create mode 100644 files/fr/web/http/content_negotiation/httpnego3.png create mode 100644 files/fr/web/http/content_negotiation/httpnegoserver.png diff --git a/files/fr/web/http/content_negotiation/httpnego.png b/files/fr/web/http/content_negotiation/httpnego.png new file mode 100644 index 0000000000000000000000000000000000000000..f8366b04481f811145a20bea53fb047e51e5a5a5 GIT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}`ab|%UfiAl literal 0 HcmV?d00001 diff --git a/files/fr/web/http/content_negotiation/httpnego3.png b/files/fr/web/http/content_negotiation/httpnego3.png new file mode 100644 index 0000000000000000000000000000000000000000..bbfa474aebb87d4d89ce912d7dc8b2dcc9ffb373 GIT binary patch literal 117319 zcmeFYXH-;A(=R%Tiim)MfaD-SvIxkKMF|c$=bSSPNRA4UgN%}gEJqa6&UpwU zIp=f-_&?8i&U@c?-F5G$^Wm}A?HBj`RY>VaYRN!e;hr4<0;FQc`MdZIzUiJU%`)GBP?pKc}Fe2nh)xB_)0J z>ec1t<^B8j2?+^bzI?g8y}h%uQ(0Mga&of2zyI*zLmCAUrS4ilasTotjy2P&%?u`ySqCtFYom9bZl%46BDzp zuI|yJM;||aJUBQYARxfNz=(~F9U2;X^5n_l;$lxvkDZ+z5{bmc#r^s7=h4v-2?!+3>7LWhTkZ{ED=>+9Rx+}z#WwXm=tBO{}vq^zy2eg6Ep zi;K(f@Gw6=zm=7hs;Vjw2%MjvS5#DFXJ^mO&ZeTGGBY!im6hGv+9D?>pPQTe^yyPz zU|>f_hr7EwK0ZD@Jv|Ht6A=-KiHT8DQ;Ud*U}a?`A|m?r>(}1i9x*ZT%*+f63kx3~ zA0s29si|pHRMfk7?^ae;7#J9)rl#1~*aim&ZES3)si_481uH5ly1Kf!xVZH7^(QAM z)6>&wX=&-`=t@gV-@bjjwzig=o2#s>92^{+l9JNW(z39yASNcJr>AFVXb1v<5)u;Z z?d`3tt#fj61Ox<}oSYB{#FsB$W@l&H+S(i(90CFYq@|^Kd3kwwc;w~f4GauaR8%}Y zJy%y(B_t%kU~qDBvZ$!2mzS4`i3tP(DJUrD?CkXS_t(+UsjsguEG(?4sd002D=sen z{rmUG$cVPKwxgq?u&}U#g2M9ha(sMzZ*OmEYHE9XdtzeZhYuf`o0~H;GtJG-gMxzK zaClNul7@!HpFe-%;^Mx2`(|rvD=sdsuC88QUheAZIyyRJ85t=f zBNG-D_Vw%6jEszul9KA`>a?`9@bK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1rjyO{AlK&&pLddQkzk>=2`Jwi)8ilgplk6Bfgz|OoWu=QE$|vG!4KlN z=x26{zBH?TVpf4=?%CJJ7niL8@y*acBk(*B{rx(t^un&U>d>9MK(3i|Jy2Qq%3v;) zt+Nm2QXJTRE6QaE^cw7%CO36J7b^6mkG1tDC|yTyCL)jH05x^e+o3sUP)RmZw;^7l zDrW`^3pixrIe(6qB3x}Q<=LU3hkj60VG8|uF6MiX1xXW@E$hX1)VFrmr|8CYxm7CJ zdHYR%OaNvG7U( zq~_k=Bw!9zhEE{k3}B-v#*Rju?p6i}()A5CF)^@_0`)*Ek`f#G-N{gdxH`46|7azB ze`z9%4|Sa;YjackL#krE3fCV7snNm|QB9q6llx8n+l=*ER%8p0`d|rzhgxhD9A=My zUnNw^&E=yNR24o^J{8NsAAWzpuF=QISs&7sbT@W))3AOwrlo$(tOgF?wjY>3lglR; zf*|I<#%=_os#(;PEMr^h%gWv_ofxk{sT!W1M4#`s28(c~P **Note :** [Le wiki du WHATWG](https://wiki.whatwg.org/wiki/Why_not_conneg) explique certains inconvénients liés à la négociation de contenu HTTP. Sachez que HTML fournit des méthodes complémentaires pour la négociation de contenu, par exemple avec [l'élément ``](/fr/docs/Web/HTML/Element/source). -Un document spécifique s'appelle une _ressource_. Lorsqu'un client veut y accéder, il le demande en utilisant son URL. Le serveur utilise cette URL pour choisir une des différentes versions qu'il peut fournir - chaque version étant appelée une représentation - et renvoie cette représentation spécifique au client. La ressource globale, ainsi que chacune de ses représentations, ont une URL spécifique. La façon dont une représentation spécifique est choisie est déterminée par la _négociation de contenu_ et il existe plusieurs façons de négocier entre le client et le serveur. +## Les principes de la négociation de contenu -![](httpnego.png) +Un document donné est défini comme une _ressource_. Lorsqu'un client souhaite obtenir une ressource, il la demande via une URL. Le serveur utilise alors cette URL pour choisir l'une des variantes disponibles. Chaque variante est appelée une _représentation_. Le serveur renvoie alors une représentation donnée au client. La ressource, ainsi que chacune de ses représentations, dispose d'une URL spécifique. _La négociation de contenu_ détermine quelle représentation donnée est utilisée lorsque la ressource est demandée. Il existe plusieurs méthodes de négociation entre le client et le serveur. -La sélection de la représentation la mieux adaptée se fait par l'un des deux mécanismes suivants: +![Un client demandant une URL. Le serveur possède plusieurs ressources représentant cette URL, il renvoie le contenu approprié selon la requête.](httpnego.png) -- Des [en-têtes HTTP](/fr/docs/Web/HTTP/Headers) spécifiques envoyés par le client (_négociation pilotée par le serveur_ ou _négociation proactive_), qui est le moyen standard de négocier un type de ressource spécifique. -- Les [codes réponses](/fr/docs/Web/HTTP/Status) {{HTTPStatus("300")}} (Multiple Choices) ou {{HTTPStatus("406")}} (Not Acceptable) envoyés par le serveur (_négociation pilotée par le client_ ou _négociation réactive_), qui sont utilisés comme mécanismes de repli. +La représentation la plus adaptée est choisie selon l'un de ces deux mécanismes : -Au fil des ans, d'autres propositions de négociation de contenu, comme la négociation transparente du contenu et l'en-tête `Alternates`, ont été proposées. Elles n'ont pas réussi à emporter l'adhésion et ont été abandonnées. +- [Des en-têtes HTTP spécifiques](/fr/docs/Web/HTTP/Headers) envoyés par le client (_négociation menée par le serveur_ ou _négociation proactive_) : il s'agit de la méthode standard pour négocier un type de ressource donné. +- [Les codes de réponse HTTP](/fr/docs/Web/HTTP/Status) [`300 Multiple Choices`](/fr/docs/Web/HTTP/Status/300), [`406 Not Acceptable`](/fr/docs/Web/HTTP/Status/406) ou [`415 Unsupported Media Type`](/fr/docs/Web/HTTP/Status/415) envoyés par le serveur (_négociation menée par l'agent_ ou _négociation réactive_), sont utilisés comme mécanismes de recours. -## La négociation de contenu gérée par le serveur +Au fur et à mesure des années, d'autres propositions relatives à la négociation de contenu ont été faites, comme [la négociation de contenu transparente](https://datatracker.ietf.org/doc/html/rfc2295) et l'en-tête `Alternates`. Toutefois, elles n'ont pas suffisamment pris d'ampleur et ont finalement été abandonnées. -Dans la _négociation de contenu gérée par le serveur_, ou négociation proactive de contenu, le navigateur (ou tout autre type de client) envoie plusieurs en-têtes HTTP avec l'URL décrivant les choix préférés de l'utilisateur. Le serveur les utilise comme indications et un algorithme interne choisit le meilleur contenu à servir au client. L'algorithme est spécifique au serveur et n'est pas défini dans la norme. Voir, par exemple, l'[algorithme de négociation d'Apache 2.2](http://httpd.apache.org/docs/2.2/en/content-negotiation.html#algorithm). +## Négociation de contenu menée par le serveur -![](httpnegoserver.png) +Lors d'une _négociation de contenu menée par le serveur_ (aussi appelée négociation de contenu proactive), le navigateur (ou tout autre agent utilisateur) envoie plusieurs en-têtes HTTP avec l'URL. Ces en-têtes décrivent les préférences de la personne. Le serveur utilise alors ces en-têtes comme indications et un algorithme interne détermine le meilleur contenu à servir au client. Si le serveur ne peut fournir une ressource adéquate, il peut répondre avec les erreurs [`406 Not Acceptable`](/fr/docs/Web/HTTP/Status/406) ou [`415 Unsupported Media Type`](/fr/docs/Web/HTTP/Status/415) et renvoyer des en-têtes indiquant les types de média qu'il prend en charge (par exemple avec [`Accept-Post`](/fr/docs/Web/HTTP/Headers/Accept-Post) ou [`Accept-Patch`](/fr/docs/Web/HTTP/Headers/Accept-Patch) selon que la requête utilise respectivement le verbe `POST` ou `PATCH`). L'algorithme est propre au serveur et n'est pas défini par le standard. Comme exemple, vous pouvez consulter [l'algorithme de négociation utilisé par le serveur HTTP httpd d'Apache](https://httpd.apache.org/docs/current/en/content-negotiation.html#algorithm). -La norme HTTP/1.1 définit la liste des en-têtes standard qui initient la négociation pilotée par le serveur ({{HTTPHeader("Accept")}}, {{HTTPHeader("Accept-Charset")}}, {{HTTPHeader("Accept-Encoding")}}, {{HTTPHeader("Accept-Language")}}). Bien qu'à proprement parler {{HTTPHeader("User-Agent")}} ne figure pas dans la liste, il est aussi parfois utilisé pour envoyer une représentation spécifique de la ressource demandée, bien que cela ne soit pas considéré comme une bonne pratique. Le serveur utilise l'en-tête {{HTTPHeader("Vary")}} pour indiquer quels en-têtes il a effectivement utilisés pour la négociation de contenu (ou plus précisément les en-têtes de réponse associés), pour que les [caches](/fr/docs/Web/HTTP/Caching) puissent fonctionner de manière optimale. +![Un client dem ande une URL avec des en-têtes indiquant une préférence pour des types de contenu. Le serveur possède plusieurs ressources représentant cette URL et renvoie le contenu associé à la langue préférée tout en compressant le corps de la requête avec la méthode demandée par le client dans les en-têtes de la requête.](httpnegoserver.png) -En outre, il existe une proposition expérimentale visant à ajouter d'autres en-têtes à la liste des en-têtes disponibles, appelés indications (_hints_) du client. Ces hints indiquent sur quel type de périphérique l'agent utilisateur fonctionne (par exemple, s'il s'agit d'un ordinateur de bureau ou d'un périphérique mobile). +Le standard HTTP/1.1 définit une liste des en-têtes standard qui initient la négociation menée par le serveur (comme [`Accept`](/fr/docs/Web/HTTP/Headers/Accept), [`Accept-Encoding`](/fr/docs/Web/HTTP/Headers/Accept-Encoding), et [`Accept-Language`](/fr/docs/Web/HTTP/Headers/Accept-Language)). Bien que l'en-tête [`User-Agent`](/fr/docs/Web/HTTP/Headers/User-Agent) ne soit pas dans cette liste, il est parfois utilisé en pratique pour déterminer la ressource à envoyer, bien que ce ne soit pas une bonne pratique. Le serveur utilise l'en-tête [`Vary`](/fr/docs/Web/HTTP/Headers/Vary) pour indiquer les en-têtes effectivement utilisés pour la négociation de contenu (ou, plus précisément, les en-têtes correspondants à ceux de la requête), afin que [les caches](/fr/docs/Web/HTTP/Caching) puissent fonctionner de façon optimale. -Même si la négociation de contenu gérée par le serveur est le moyen le plus courant de s'entendre sur une représentation spécifique d'une ressource, elle présente plusieurs inconvénients: +En complément de ces en-têtes, une proposition expérimentale décrit plusieurs en-têtes supplémentaires appelés _indications client_ (client hints). Ces indications exposent le type d'appareil sur lequel est utilisé l'agent utilisateur (par exemple un ordinateur de bureau ou un appareil). -- Le serveur n'a pas une connaissance totale du navigateur. Même avec l'extension _Client Hints_, il n'a pas une connaissance complète des capacités du navigateur. Contrairement à la négociation de contenu réactif où le client fait le choix, celui du serveur est toujours quelque peu arbitraire. -- L'information fournie par le client est assez verbeuse (la compression de l'en-tête HTTP/2 atténue ce problème) et est un risque d'atteinte à la vie privée (empreintes digitales HTTP) -- Comme plusieurs représentations d'une ressource donnée sont envoyées, les caches partagés sont moins efficaces et les implémentations des serveurs sont plus complexes. +Même si la négociation menée par le serveur est la méthode la plus fréquemment employée pour s'accorder sur la représentation spécifique d'une ressource, elle souffre de plusieurs inconvénients : -### The `Accept` header +- Le serveur ne connaît pas tout du navigateur. Même avec les indications client, le serveur ne peut connaître toutes les capacités du navigateur. Contrairement à la négociation de contenu menée par le client, où c'est ce dernier qui fait le choix, le choix du serveur repose toujours sur une partie d'arbitraire. +- Les informations envoyées par le client sont assez verbeuses (la compression des en-têtes HTTP/2 atténue ce problème) et peuvent être un risque quant à la vie privée (en permettant par exemple de construire [des empreintes HTTP uniques](/fr/docs/Glossary/Fingerprinting)). +- Lorsque plusieurs représentations d'une même ressource sont envoyées par le serveur, l'efficacité des caches est réduite et les implémentations des serveurs deviennent plus complexes. -The {{HTTPHeader("Accept")}} header lists the MIME types of media resources that the agent is willing to process. It is comma-separated lists of MIME types, each combined with a quality factor, a parameter indicating the relative degree of preference between the different MIME types. +### L'en-tête `Accept` -The {{HTTPHeader("Accept")}} header is defined by the browser, or any other user-agent, and can vary according to the context, like fetching an HTML page or an image, a video, or a script: It is different when fetching a document entered in the address bar or an element linked via an {{ HTMLElement("img") }}, {{ HTMLElement("video") }} or {{ HTMLElement("audio") }} element. Browsers are free to use the value of the header that they think is the most adequate; an exhaustive list of [default values for common browsers](/fr/docs/Web/HTTP/Content_negotiation/List_of_default_Accept_values) is available. +L'en-tête [`Accept`](/fr/docs/Web/HTTP/Headers/Accept) liste les types MIME des ressources média que l'agent accepte de traiter. Il s'agit d'une liste de types MIME séparés par des virgules, chacun associé avec un facteur de qualité indiquant la préférence relative entre chaque type MIME. -### The `Accept-CH` header {{experimental_inline}} +L'en-tête `Accept` est défini par le navigateur (ou tout autre agent utilisateur) et peut varier selon le contexte, par exemple que la ressource soit une page HTML, une image, une vidéo ou un script. Cet en-tête sera différent selon qu'on récupère un document demandé via la barre d'adresse, ou une ressource désignée par un élément [``](/fr/docs/Web/HTML/Element/img), [`
+
Watch this element as you resize your viewport's width and height.
``` @@ -36,7 +36,7 @@ slug: Web/CSS/@media/aspect-ratio /* 最大宽高比 */ @media (max-aspect-ratio: 3/2) { div { - background: #9ff; /* cyan */ + background: #9ff; /* cyan */ } } diff --git a/files/zh-cn/web/css/@media/device-height/index.md b/files/zh-cn/web/css/@media/device-height/index.md index c324eb53a8c7d9..1d9a10fb168e22 100644 --- a/files/zh-cn/web/css/@media/device-height/index.md +++ b/files/zh-cn/web/css/@media/device-height/index.md @@ -16,7 +16,10 @@ slug: Web/CSS/@media/device-height 在高度低于 800px 时加载指定样式 ```html - + ``` ## Specifications diff --git a/files/zh-cn/web/css/@media/index.md b/files/zh-cn/web/css/@media/index.md index e6ecdb53f67e21..bdead41391f178 100644 --- a/files/zh-cn/web/css/@media/index.md +++ b/files/zh-cn/web/css/@media/index.md @@ -1,5 +1,5 @@ --- -title: '@media' +title: "@media" slug: Web/CSS/@media --- @@ -120,6 +120,7 @@ _逻辑操作符_(_logical operator_)`not`、`and`、`only` 和 `or` 可用 - `and` - : 用于将多个媒体查询规则组合成单条媒体查询,当每个查询规则都为真时则该条媒体查询为 `true`,它还用于将媒体功能与媒体类型结合在一起。 - `not` + - : 用于否定媒体查询,如果不满足这个条件则返回 `true`,否则返回 `false`。如果出现在以逗号分隔的查询列表中,它将仅否定应用了该查询的特定查询。如果使用 `not` 运算符,则*还必须*指定媒体类型。 > **备注:** 在 Level 3 中,`not` 关键字不能用于否定单个媒体特性表达式,而只能用于否定整个媒体查询。 diff --git a/files/zh-cn/web/css/@media/prefers-color-scheme/index.md b/files/zh-cn/web/css/@media/prefers-color-scheme/index.md index 1407600836fc63..7b4a3e0d365dea 100644 --- a/files/zh-cn/web/css/@media/prefers-color-scheme/index.md +++ b/files/zh-cn/web/css/@media/prefers-color-scheme/index.md @@ -31,7 +31,8 @@ slug: Web/CSS/@media/prefers-color-scheme ```html
Day (initial)
Day (changes in light scheme)
-
Day (changes in dark scheme)

+
Day (changes in dark scheme)
+
Night (initial)
Night (changes in light scheme)
@@ -41,20 +42,39 @@ slug: Web/CSS/@media/prefers-color-scheme ### CSS ```css -.day { background: #eee; color: black; } -.night { background: #333; color: white; } +.day { + background: #eee; + color: black; +} +.night { + background: #333; + color: white; +} @media (prefers-color-scheme: dark) { - .day.dark-scheme { background: #333; color: white; } - .night.dark-scheme { background: black; color: #ddd; } + .day.dark-scheme { + background: #333; + color: white; + } + .night.dark-scheme { + background: black; + color: #ddd; + } } @media (prefers-color-scheme: light) { - .day.light-scheme { background: white; color: #555; } - .night.light-scheme { background: #eee; color: black; } + .day.light-scheme { + background: white; + color: #555; + } + .night.light-scheme { + background: #eee; + color: black; + } } -.day, .night { +.day, +.night { display: inline-block; padding: 1em; width: 7em; diff --git a/files/zh-cn/web/css/@media/prefers-reduced-motion/index.md b/files/zh-cn/web/css/@media/prefers-reduced-motion/index.md index 26ce87841a7e3f..581b1cbfe08454 100644 --- a/files/zh-cn/web/css/@media/prefers-reduced-motion/index.md +++ b/files/zh-cn/web/css/@media/prefers-reduced-motion/index.md @@ -56,7 +56,10 @@ slug: Web/CSS/@media/prefers-reduced-motion .animation { background-color: rebeccapurple; color: #fff; - font: 1.2em Helvetica, arial, sans-serif; + font: + 1.2em Helvetica, + arial, + sans-serif; width: 200px; padding: 1em; border-radius: 1em; @@ -76,22 +79,22 @@ slug: Web/CSS/@media/prefers-reduced-motion @keyframes vibrate { 0% { - transform: translate(0); + transform: translate(0); } 20% { - transform: translate(-2px, 2px); + transform: translate(-2px, 2px); } 40% { - transform: translate(-2px, -2px); + transform: translate(-2px, -2px); } 60% { - transform: translate(2px, 2px); + transform: translate(2px, 2px); } 80% { - transform: translate(2px, -2px); + transform: translate(2px, -2px); } 100% { - transform: translate(0); + transform: translate(0); } } ``` diff --git a/files/zh-cn/web/css/@namespace/index.md b/files/zh-cn/web/css/@namespace/index.md index e8e23d49291bdc..132c525d3661dc 100644 --- a/files/zh-cn/web/css/@namespace/index.md +++ b/files/zh-cn/web/css/@namespace/index.md @@ -1,5 +1,5 @@ --- -title: '@namespace' +title: "@namespace" slug: Web/CSS/@namespace --- @@ -42,13 +42,16 @@ slug: Web/CSS/@namespace @namespace svg url(http://www.w3.org/2000/svg); /* 匹配所有的 XHTML
元素,因为 XHTML 是默认无前缀命名空间 */ -a {} +a { +} /* 匹配所有的 SVG 元素 */ -svg|a {} +svg|a { +} /* 匹配 XHTML 和 SVG 元素 */ -*|a {} +*|a { +} ``` ## 规范 diff --git a/files/zh-cn/web/css/@page/index.md b/files/zh-cn/web/css/@page/index.md index 6bb65c847a8659..bb9fb14f76f381 100644 --- a/files/zh-cn/web/css/@page/index.md +++ b/files/zh-cn/web/css/@page/index.md @@ -1,5 +1,5 @@ --- -title: '@page' +title: "@page" slug: Web/CSS/@page --- diff --git a/files/zh-cn/web/css/@property/index.md b/files/zh-cn/web/css/@property/index.md index ae954db571bc78..dd943d2021398a 100644 --- a/files/zh-cn/web/css/@property/index.md +++ b/files/zh-cn/web/css/@property/index.md @@ -1,5 +1,5 @@ --- -title: '@property' +title: "@property" slug: Web/CSS/@property --- @@ -13,7 +13,7 @@ slug: Web/CSS/@property ```css @property --property-name { - syntax: ''; + syntax: ""; inherits: false; initial-value: #c0ffee; } @@ -33,7 +33,7 @@ slug: Web/CSS/@property ```css @property --my-color { - syntax: ''; + syntax: ""; inherits: false; initial-value: #c0ffee; } @@ -43,10 +43,10 @@ slug: Web/CSS/@property ```js window.CSS.registerProperty({ - name: '--my-color', - syntax: '', + name: "--my-color", + syntax: "", inherits: false, - initialValue: '#c0ffee', + initialValue: "#c0ffee", }); ``` diff --git a/files/zh-cn/web/css/@property/inherits/index.md b/files/zh-cn/web/css/@property/inherits/index.md index a7b658041f9e8b..d926698932ac9a 100644 --- a/files/zh-cn/web/css/@property/inherits/index.md +++ b/files/zh-cn/web/css/@property/inherits/index.md @@ -11,13 +11,13 @@ slug: Web/CSS/@property/inherits ```css @property --property-name { - syntax: ''; + syntax: ""; inherits: false; initial-value: #c0ffee; } @property --property-name { - syntax: ''; + syntax: ""; inherits: true; initial-value: #c0ffee; } @@ -48,7 +48,7 @@ slug: Web/CSS/@property/inherits ```css @property --my-color { - syntax: ''; + syntax: ""; inherits: false; initial-value: #c0ffee; } @@ -58,10 +58,10 @@ slug: Web/CSS/@property/inherits ```js window.CSS.registerProperty({ - name: '--my-color', - syntax: '', + name: "--my-color", + syntax: "", inherits: false, - initialValue: '#c0ffee', + initialValue: "#c0ffee", }); ``` diff --git a/files/zh-cn/web/css/@property/initial-value/index.md b/files/zh-cn/web/css/@property/initial-value/index.md index 912b23f2b45e84..f6291c5ba8f5f4 100644 --- a/files/zh-cn/web/css/@property/initial-value/index.md +++ b/files/zh-cn/web/css/@property/initial-value/index.md @@ -13,13 +13,13 @@ slug: Web/CSS/@property/initial-value ```css @property --property-name { - syntax: ''; + syntax: ""; inherits: false; initial-value: #c0ffee; } @property --property-name { - syntax: ''; + syntax: ""; inherits: true; initial-value: #c0ffee; } @@ -47,7 +47,7 @@ slug: Web/CSS/@property/initial-value ```css @property --my-color { - syntax: ''; + syntax: ""; inherits: false; initial-value: #c0ffee; } @@ -57,10 +57,10 @@ slug: Web/CSS/@property/initial-value ```js window.CSS.registerProperty({ - name: '--my-color', - syntax: '', + name: "--my-color", + syntax: "", inherits: false, - initialValue: '#c0ffee', + initialValue: "#c0ffee", }); ``` diff --git a/files/zh-cn/web/css/@property/syntax/index.md b/files/zh-cn/web/css/@property/syntax/index.md index 1eb8d016aacbef..1dd6d79467aff9 100644 --- a/files/zh-cn/web/css/@property/syntax/index.md +++ b/files/zh-cn/web/css/@property/syntax/index.md @@ -12,13 +12,13 @@ slug: Web/CSS/@property/syntax 如下是所有的有效 syntax 字符串: ```css -syntax: ''; /* 接收一个颜色值 */ +syntax: ""; /* 接收一个颜色值 */ -syntax: ' | '; /* 接收长度或百分比参数,但是二者之间不进行计算合并 */ +syntax: " | "; /* 接收长度或百分比参数,但是二者之间不进行计算合并 */ -syntax: 'small | medium | large'; /* 接收这些参数值之一作为自定义标识符 */ +syntax: "small | medium | large"; /* 接收这些参数值之一作为自定义标识符 */ -syntax: '*'; /* 任何有效字符 */ +syntax: "*"; /* 任何有效字符 */ ``` ## 取值 @@ -72,7 +72,7 @@ syntax: '*'; /* 任何有效字符 */ ```css @property --my-color { - syntax: ''; + syntax: ""; inherits: false; initial-value: #c0ffee; } @@ -82,10 +82,10 @@ syntax: '*'; /* 任何有效字符 */ ```js window.CSS.registerProperty({ - name: '--my-color', - syntax: '', + name: "--my-color", + syntax: "", inherits: false, - initialValue: '#c0ffee', + initialValue: "#c0ffee", }); ``` diff --git a/files/zh-cn/web/css/@supports/index.md b/files/zh-cn/web/css/@supports/index.md index f28acb0a316920..31591d286d9293 100644 --- a/files/zh-cn/web/css/@supports/index.md +++ b/files/zh-cn/web/css/@supports/index.md @@ -1,5 +1,5 @@ --- -title: '@supports' +title: "@supports" slug: Web/CSS/@supports --- @@ -34,7 +34,8 @@ slug: Web/CSS/@supports 最基本的支持条件就是 CSS 声明,也就是一个 CSS 属性后跟一个值,中间用冒号分开。如果 {{cssxref("transform-origin")}} 的实现语法认为 `5% 5%` 是有效的值,则下面的表达式会返回 true。 ```css -@supports (transform-origin: 5% 5%) {} +@supports (transform-origin: 5% 5%) { +} ``` ### 函数语法 @@ -46,7 +47,8 @@ slug: Web/CSS/@supports 测试浏览器是否支持经过测试的选择器语法。如果浏览器支持[子组合器](/zh-CN/docs/Web/CSS/Child_combinator),则以下示例返回 true: ```css -@supports selector(A > B) {} +@supports selector(A > B) { +} ``` ### `not` 操作符 @@ -54,14 +56,17 @@ slug: Web/CSS/@supports 将 `not` 操作符放在任何表达式之前就能否定一条表达式。如果 {{CSSxRef("transform-origin")}} 的实现语法认为 `10em 10em 10em` 是**无效**的,则下面的表达式会返回 true。 ```css -@supports not (transform-origin: 10em 10em 10em) {} +@supports not (transform-origin: 10em 10em 10em) { +} ``` 和其他操作符一样,`not` 操作符可以应用在任意复杂度的表达式上。下面的几个例子中都是合法的表达式: ```css -@supports not (not (transform-origin: 2px)) {} -@supports (display: grid) and (not (display: inline-grid)) {} +@supports not (not (transform-origin: 2px)) { +} +@supports (display: grid) and (not (display: inline-grid)) { +} ``` > **备注:** 如果 `not` 操作符位于表达式的最外层,则没有必要使用圆括号将它括起来。但如果要将该表达式与其他表达式连接起来使用,比如 `and` 和 `or`,则需要外面的圆括号。 @@ -71,14 +76,17 @@ slug: Web/CSS/@supports `and` 操作符用来将两个原始的表达式做逻辑与后生成一个新的表达式,如果两个原始表达式的值**都为真**,则生成的表达式也为真。在下例中,当且仅当两个原始表达式同时为真时,整个表达式才为真: ```css -@supports (display: table-cell) and (display: list-item) {} +@supports (display: table-cell) and (display: list-item) { +} ``` 可以将多个合取词并置而不需要更多的括号。以下两者都是等效的: ```css -@supports (display: table-cell) and (display: list-item) and (display:run-in) {} -@supports (display: table-cell) and ((display: list-item) and (display:run-in)) {} +@supports (display: table-cell) and (display: list-item) and (display: run-in) { +} +@supports (display: table-cell) and ((display: list-item) and (display: run-in)) { +} ``` ### `or` 操作符 @@ -86,17 +94,26 @@ slug: Web/CSS/@supports `or` 操作符用来将两个原始的表达式做逻辑或后生成一个新的表达式,如果两个原始表达式的值**有一个或者都**为真,则生成的表达式也为真。在下例中,当两个原始表达式中至少有一个为真时,整个表达式才为真: ```css -@supports (transform-style: preserve) or (-moz-transform-style: preserve) {} +@supports (transform-style: preserve) or (-moz-transform-style: preserve) { +} ``` 可以将多个析取词并置而不需要更多的括号。以下两者都是等效的: ```css @supports (transform-style: preserve) or (-moz-transform-style: preserve) or - (-o-transform-style: preserve) or (-webkit-transform-style: preserve) {} + (-o-transform-style: preserve) or (-webkit-transform-style: preserve) { +} -@supports (transform-style: preserve-3d) or ((-moz-transform-style: preserve-3d) or - ((-o-transform-style: preserve-3d) or (-webkit-transform-style: preserve-3d))) {} +@supports (transform-style: preserve-3d) or + ( + (-moz-transform-style: preserve-3d) or + ( + (-o-transform-style: preserve-3d) or + (-webkit-transform-style: preserve-3d) + ) + ) { +} ``` > **备注:** 在使用 `and` 和 `or` 操作符时,如果是为了定义多个表达式的执行顺序,则必须使用圆括号。如果不这样做的话,该条件就是无效的,会导致整个 at-rule 失效。 @@ -111,9 +128,9 @@ slug: Web/CSS/@supports ```css @supports (animation-name: test) { - … /* 如果支持不带前缀的 animation-name,则下面指定的 CSS 会生效 */ - @keyframes { /* @supports 是一个 CSS 条件组 at-rule,它可以包含其他相关的 at-rules */ - … + /* 如果支持不带前缀的 animation-name,则下面指定的 CSS 会生效 */ + @keyframes { + /* @supports 是一个 CSS 条件组 at-rule,它可以包含其他相关的 at-rules */ } } ``` @@ -123,15 +140,15 @@ slug: Web/CSS/@supports ```css @supports ( (perspective: 10px) or (-moz-perspective: 10px) or (-webkit-perspective: 10px) or (-ms-perspective: 10px) or (-o-perspective: 10px) ) { - … /* 如果支持不带前缀以及带前缀的 perspective 属性,则下面指定的 CSS 会生效 */ + /* 如果支持不带前缀以及带前缀的 perspective 属性,则下面指定的 CSS 会生效 */ } ``` ### 检测是否不支持指定的 CSS 属性 ```css -@supports ( not ((text-align-last:justify) or (-moz-text-align-last:justify) ){ - … /* 这里的 CSS 代码用来模拟 text-align-last:justify */ +@supports not ((text-align-last:justify) or (-moz-text-align-last:justify)) { + /* 这里的 CSS 代码用来模拟 text-align-last:justify */ } ``` @@ -152,14 +169,14 @@ slug: Web/CSS/@supports ```css /* 这条 CSS 规则在不支持 is:() 的浏览器中无效 */ :is(ul, ol) > li { - … /* 支持 :is(...) 选择器时,这里的 CSS 生效 */ + /* 支持 :is(...) 选择器时,这里的 CSS 生效 */ } @supports not selector(:is(a, b)) { /* 不支持 :is() 时的备选方案 */ ul > li, ol > li { - … /* 以上给不支持 :is(...) 的浏览器展开了 CSS 选择器规则 */ + /* 以上给不支持 :is(...) 的浏览器展开了 CSS 选择器规则 */ } } @@ -169,7 +186,7 @@ slug: Web/CSS/@supports 只有部分生效 */ :is(:nth-child(1n of ul, ol) a, details > summary) { - … /* 当:is(...) 选择器以及 :nth-child(…) 的 `of` 参数都支持时, + /* 当:is(...) 选择器以及 :nth-child(…) 的 `of` 参数都支持时, 这里的 CSS 会生效 */ } } diff --git a/files/zh-cn/web/css/_colon_-moz-only-whitespace/index.md b/files/zh-cn/web/css/_colon_-moz-only-whitespace/index.md index e223364382d220..3f365c70bd01c8 100644 --- a/files/zh-cn/web/css/_colon_-moz-only-whitespace/index.md +++ b/files/zh-cn/web/css/_colon_-moz-only-whitespace/index.md @@ -1,5 +1,5 @@ --- -title: ':blank' +title: ":blank" slug: Web/CSS/:-moz-only-whitespace --- @@ -22,7 +22,7 @@ slug: Web/CSS/:-moz-only-whitespace ### HTML ```html -
+
``` ### CSS diff --git a/files/zh-cn/web/css/_colon_active/index.md b/files/zh-cn/web/css/_colon_active/index.md index e8b933102a8c8b..a07b0570ac3fdd 100644 --- a/files/zh-cn/web/css/_colon_active/index.md +++ b/files/zh-cn/web/css/_colon_active/index.md @@ -1,5 +1,5 @@ --- -title: ':active' +title: ":active" slug: Web/CSS/:active --- @@ -33,7 +33,8 @@ a:active { #### HTML ```html -

This paragraph contains a link: +

+ This paragraph contains a link: This link will turn red while you click on it. The paragraph will get a gray background while you click on it or the link.

@@ -42,12 +43,27 @@ a:active { #### CSS ```css -a:link { color: blue; } /* 未访问链接 */ -a:visited { color: purple; } /* 已访问链接 */ -a:hover { background: yellow; } /* 用户鼠标悬停 */ -a:active { color: red; } /* 激活链接 */ +a:link { + /* 未访问链接 */ + color: blue; +} +a:visited { + /* 已访问链接 */ + color: purple; +} +a:hover { + /* 用户鼠标悬停 */ + background: yellow; +} +a:active { + /* 激活链接 */ + color: red; +} -p:active { background: #eee; } /* 激活段落 */ +p:active { + /* 激活段落 */ + background: #eee; +} ``` #### 结果 diff --git a/files/zh-cn/web/css/_colon_any-link/index.md b/files/zh-cn/web/css/_colon_any-link/index.md index 3c1c63049d4273..b389c0b29f440a 100644 --- a/files/zh-cn/web/css/_colon_any-link/index.md +++ b/files/zh-cn/web/css/_colon_any-link/index.md @@ -1,5 +1,5 @@ --- -title: ':any-link' +title: ":any-link" slug: Web/CSS/:any-link --- diff --git a/files/zh-cn/web/css/_colon_blank/index.md b/files/zh-cn/web/css/_colon_blank/index.md index 6f6b5399d9914e..f2870f8df24ab1 100644 --- a/files/zh-cn/web/css/_colon_blank/index.md +++ b/files/zh-cn/web/css/_colon_blank/index.md @@ -1,5 +1,5 @@ --- -title: ':blank' +title: ":blank" slug: Web/CSS/:blank original_slug: Web/CSS/:blank空白伪类 --- diff --git a/files/zh-cn/web/css/_colon_checked/index.md b/files/zh-cn/web/css/_colon_checked/index.md index 587a93bee03698..e0612c36a4fb96 100644 --- a/files/zh-cn/web/css/_colon_checked/index.md +++ b/files/zh-cn/web/css/_colon_checked/index.md @@ -1,5 +1,5 @@ --- -title: ':checked' +title: ":checked" slug: Web/CSS/:checked --- @@ -35,15 +35,15 @@ slug: Web/CSS/:checked ```html
- + - +
- +
@@ -99,14 +99,38 @@ option:checked { - + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + +
Column #1Column #2Column #3
Column #1Column #2Column #3
[cell text][cell text][cell text]
[cell text][cell text][cell text]
[cell text][cell text][cell text]
[cell text][cell text][cell text]
diff --git a/files/zh-cn/web/css/_colon_default/index.md b/files/zh-cn/web/css/_colon_default/index.md index a42bc18111e46b..7a7b945f3ced74 100644 --- a/files/zh-cn/web/css/_colon_default/index.md +++ b/files/zh-cn/web/css/_colon_default/index.md @@ -1,5 +1,5 @@ --- -title: ':default' +title: ":default" slug: Web/CSS/:default --- @@ -27,16 +27,16 @@ input:default { ### HTML ```html - + - + - + - + ``` diff --git a/files/zh-cn/web/css/_colon_defined/index.md b/files/zh-cn/web/css/_colon_defined/index.md index 88d007aea8240d..5c4a28390c5bb8 100644 --- a/files/zh-cn/web/css/_colon_defined/index.md +++ b/files/zh-cn/web/css/_colon_defined/index.md @@ -1,5 +1,5 @@ --- -title: ':defined' +title: ":defined" slug: Web/CSS/:defined --- @@ -30,18 +30,19 @@ simple-custom:defined { 在这个 demo 中我们定义了一个非常简单的自定义元素: ```js -customElements.define('simple-custom', +customElements.define( + "simple-custom", class extends HTMLElement { constructor() { super(); - let divElem = document.createElement('div'); - divElem.textContent = this.getAttribute('text'); + let divElem = document.createElement("div"); + divElem.textContent = this.getAttribute("text"); - let shadowRoot = this.attachShadow({mode: 'open'}) - .appendChild(divElem); - } -}) + let shadowRoot = this.attachShadow({ mode: "open" }).appendChild(divElem); + } + }, +); ``` 然后在文档中插入一个该元素的副本,以及一个标准的 `

` 标签: diff --git a/files/zh-cn/web/css/_colon_dir/index.md b/files/zh-cn/web/css/_colon_dir/index.md index f315de91f9986d..228bbe0f903c01 100644 --- a/files/zh-cn/web/css/_colon_dir/index.md +++ b/files/zh-cn/web/css/_colon_dir/index.md @@ -1,5 +1,5 @@ --- -title: ':dir()' +title: ":dir()" slug: Web/CSS/:dir --- @@ -26,7 +26,8 @@ slug: Web/CSS/:dir ```html

test1 -
test2 +
+ test2
עִבְרִית
diff --git a/files/zh-cn/web/css/_colon_disabled/index.md b/files/zh-cn/web/css/_colon_disabled/index.md index 63fb92b9b3f315..5e22b7854222cd 100644 --- a/files/zh-cn/web/css/_colon_disabled/index.md +++ b/files/zh-cn/web/css/_colon_disabled/index.md @@ -1,5 +1,5 @@ --- -title: ':disabled' +title: ":disabled" slug: Web/CSS/:disabled --- @@ -56,10 +56,14 @@ input[type="text"]:disabled { ```js // 等待页面加载完毕 -document.addEventListener('DOMContentLoaded', function () { - // 将“change”事件监听器附加到复选框 - document.getElementById('billing-checkbox').onchange = toggleBilling; -}, false); +document.addEventListener( + "DOMContentLoaded", + function () { + // 将“change”事件监听器附加到复选框 + document.getElementById("billing-checkbox").onchange = toggleBilling; + }, + false, +); function toggleBilling() { // 选择 billing 文本字段 diff --git a/files/zh-cn/web/css/_colon_enabled/index.md b/files/zh-cn/web/css/_colon_enabled/index.md index d4ce36e608444c..35c0ad0f2acc80 100644 --- a/files/zh-cn/web/css/_colon_enabled/index.md +++ b/files/zh-cn/web/css/_colon_enabled/index.md @@ -1,5 +1,5 @@ --- -title: ':enabled' +title: ":enabled" slug: Web/CSS/:enabled --- diff --git a/files/zh-cn/web/css/_colon_first-child/index.md b/files/zh-cn/web/css/_colon_first-child/index.md index 14a37c5f2e658d..5d8c413a077163 100644 --- a/files/zh-cn/web/css/_colon_first-child/index.md +++ b/files/zh-cn/web/css/_colon_first-child/index.md @@ -1,5 +1,5 @@ --- -title: ':first-child' +title: ":first-child" slug: Web/CSS/:first-child --- diff --git a/files/zh-cn/web/css/_colon_first-of-type/index.md b/files/zh-cn/web/css/_colon_first-of-type/index.md index 48bf168bea359e..97e3bb190dd6d0 100644 --- a/files/zh-cn/web/css/_colon_first-of-type/index.md +++ b/files/zh-cn/web/css/_colon_first-of-type/index.md @@ -1,5 +1,5 @@ --- -title: ':first-of-type' +title: ":first-of-type" slug: Web/CSS/:first-of-type --- diff --git a/files/zh-cn/web/css/_colon_first/index.md b/files/zh-cn/web/css/_colon_first/index.md index b55f8d5f16f325..c09a5daae79824 100644 --- a/files/zh-cn/web/css/_colon_first/index.md +++ b/files/zh-cn/web/css/_colon_first/index.md @@ -1,5 +1,5 @@ --- -title: ':first' +title: ":first" slug: Web/CSS/:first --- diff --git a/files/zh-cn/web/css/_colon_focus-visible/index.md b/files/zh-cn/web/css/_colon_focus-visible/index.md index d91ed03c31643b..73cf130c556468 100644 --- a/files/zh-cn/web/css/_colon_focus-visible/index.md +++ b/files/zh-cn/web/css/_colon_focus-visible/index.md @@ -1,5 +1,5 @@ --- -title: ':focus-visible' +title: ":focus-visible" slug: Web/CSS/:focus-visible --- @@ -26,16 +26,17 @@ slug: Web/CSS/:focus-visible 在这个例子中,`:focus-visible` 选择器利用客户端 (UA) 的行为决定是否匹配。比较一下,当你用鼠标点击控件和用键盘 tab 切换控件有何不同。请注意元素的表现与具有 `:focus` 样式的元素的区别。 ```html -
-
-
-
-
+
+
+
+
+
``` ```css -input, button { +input, +button { margin: 10px; } diff --git a/files/zh-cn/web/css/_colon_focus-within/index.md b/files/zh-cn/web/css/_colon_focus-within/index.md index 23f56b8533ce32..c573e1532d9a08 100644 --- a/files/zh-cn/web/css/_colon_focus-within/index.md +++ b/files/zh-cn/web/css/_colon_focus-within/index.md @@ -1,5 +1,5 @@ --- -title: ':focus-within' +title: ":focus-within" slug: Web/CSS/:focus-within --- @@ -30,10 +30,10 @@ slug: Web/CSS/:focus-within
- -
+ +
- +
``` diff --git a/files/zh-cn/web/css/_colon_focus/index.md b/files/zh-cn/web/css/_colon_focus/index.md index e8d48d7079dde8..d8087f3c8df320 100644 --- a/files/zh-cn/web/css/_colon_focus/index.md +++ b/files/zh-cn/web/css/_colon_focus/index.md @@ -1,5 +1,5 @@ --- -title: ':focus' +title: ":focus" slug: Web/CSS/:focus --- diff --git a/files/zh-cn/web/css/_colon_fullscreen/index.md b/files/zh-cn/web/css/_colon_fullscreen/index.md index 3bd66b5eded55a..f36402dd984d0f 100644 --- a/files/zh-cn/web/css/_colon_fullscreen/index.md +++ b/files/zh-cn/web/css/_colon_fullscreen/index.md @@ -1,5 +1,5 @@ --- -title: ':fullscreen' +title: ":fullscreen" slug: Web/CSS/:fullscreen --- @@ -31,7 +31,8 @@ slug: Web/CSS/:fullscreen

MDN Web 文档演示::fullscreen 伪类

- 此演示使用 :fullscreen 伪类完全使用 CSS 来实现自动更改用于开启和关闭全屏模式的按钮的样式。 + 此演示使用 :fullscreen 伪类完全使用 CSS + 来实现自动更改用于开启和关闭全屏模式的按钮的样式。

diff --git a/files/zh-cn/web/css/_colon_has/index.md b/files/zh-cn/web/css/_colon_has/index.md index 9d3e07e6f2696c..5d1e478625a7f5 100644 --- a/files/zh-cn/web/css/_colon_has/index.md +++ b/files/zh-cn/web/css/_colon_has/index.md @@ -11,7 +11,9 @@ CSS 函数式[伪类](/zh-CN/docs/Web/CSS/Pseudo-classes) **`:has()`** 表示一 /* Selects an h1 heading with a paragraph element that immediately follows the h1 and applies the style to h1 */ -h1:has(+ p) { margin-bottom: 0; } +h1:has(+ p) { + margin-bottom: 0; +} ``` `:has()` 伪类的[优先级](/zh-CN/docs/Web/CSS/Specificity)计算方法与 {{CSSxRef(":is", ":is()")}} 和 {{CSSxRef(":not", ":not()")}} 相同:以其参数中具体的选择器进行计算。 @@ -40,12 +42,18 @@ h1:has(+ p) { margin-bottom: 0; }

Morning Times

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. +

Morning Times

Delivering you news every morning

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. +

``` @@ -54,9 +62,9 @@ h1:has(+ p) { margin-bottom: 0; } ```css hidden section { - display: flex; - align-items: start; - justify-content: space-around; + display: flex; + align-items: start; + justify-content: space-around; } article { @@ -64,19 +72,21 @@ article { width: 40%; } -h1, h2 { +h1, +h2 { font-size: 1.2em; } h2 { - font-size: 1.0em; + font-size: 1em; color: rgb(150, 149, 149); } ``` ```css -h1, h2 { - margin: 0 0 1.0rem 0; +h1, +h2 { + margin: 0 0 1rem 0; } h1:has(+ h2) { @@ -101,13 +111,19 @@ h1:has(+ h2) {

Morning Times

Delivering you news every morning

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. +

Morning Times

Delivering you news every morning

8:00 am

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. +

``` @@ -116,9 +132,9 @@ h1:has(+ h2) { ```css hidden section { - display: flex; - align-items: start; - justify-content: space-around; + display: flex; + align-items: start; + justify-content: space-around; } article { @@ -131,7 +147,7 @@ h1 { } h2 { - font-size: 1.0em; + font-size: 1em; color: rgb(150, 149, 149); } @@ -142,8 +158,10 @@ h3 { ``` ```css -h1, h2, h3 { - margin: 0 0 1.0rem 0; +h1, +h2, +h3 { + margin: 0 0 1rem 0; } :is(h1, h2, h3):has(+ :is(h2, h3, h4)) { diff --git a/files/zh-cn/web/css/_colon_host_function/index.md b/files/zh-cn/web/css/_colon_host_function/index.md index 64bbed0dfe156d..0ec3976c55b02a 100644 --- a/files/zh-cn/web/css/_colon_host_function/index.md +++ b/files/zh-cn/web/css/_colon_host_function/index.md @@ -1,5 +1,5 @@ --- -title: ':host()' +title: ":host()" slug: Web/CSS/:host_function original_slug: Web/CSS/:host() --- @@ -14,9 +14,9 @@ original_slug: Web/CSS/:host() ```css /* 选择阴影根元素,仅当它与选择器参数匹配 */ - :host(.special-custom-element) { - font-weight: bold; - } +:host(.special-custom-element) { + font-weight: bold; +} ``` ## 语法 @@ -32,26 +32,29 @@ original_slug: Web/CSS/:host() 在这个例子中,有一个简单的自定义元素 `` 可以用它包裹文本: ```html -

Host selectors example

+

+ Host selectors example +

``` 在元素的构造函数中,创建`style`和`span`元素,填充`span`自定义元素的内容,并`style`使用一些 CSS 规则填充元素: ```js -let style = document.createElement('style'); -let span = document.createElement('span'); +let style = document.createElement("style"); +let span = document.createElement("span"); span.textContent = this.textContent; -const shadowRoot = this.attachShadow({mode: 'open'}); +const shadowRoot = this.attachShadow({ mode: "open" }); shadowRoot.appendChild(style); shadowRoot.appendChild(span); -style.textContent = 'span:hover { text-decoration: underline; }' + - ':host-context(h1) { font-style: italic; }' + - ':host-context(h1):after { content: " - no links in headers!" }' + - ':host-context(article, aside) { color: gray; }' + - ':host(.footer) { color : red; }' + - ':host { background: rgba(0,0,0,0.1); padding: 2px 5px; }'; +style.textContent = + "span:hover { text-decoration: underline; }" + + ":host-context(h1) { font-style: italic; }" + + ':host-context(h1):after { content: " - no links in headers!" }' + + ":host-context(article, aside) { color: gray; }" + + ":host(.footer) { color : red; }" + + ":host { background: rgba(0,0,0,0.1); padding: 2px 5px; }"; ``` `:host(.footer) { color : red; }` 规则为文档中所有在其上设置了 `footer` 类的`` 元素实例(此实例中的影子宿主)设置样式——使用它来为 {{htmlelement("footer")}} 中的元素提供实例一种特殊的颜色。 diff --git a/files/zh-cn/web/css/_colon_hover/index.md b/files/zh-cn/web/css/_colon_hover/index.md index 791e04bae686a5..7813f9f8c2939e 100644 --- a/files/zh-cn/web/css/_colon_hover/index.md +++ b/files/zh-cn/web/css/_colon_hover/index.md @@ -1,11 +1,11 @@ --- -title: ':hover' +title: ":hover" slug: Web/CSS/:hover --- {{CSSRef}} - **`:hover`** [CSS](/zh-CN/docs/Web/CSS) [伪类](/zh-CN/docs/Web/CSS/Pseudo-classes)在用户使用指针设备与元素进行交互时匹配,但不一定激活它。通常情况下,用户将光标(鼠标指针)悬停在元素上时触发。 +**`:hover`** [CSS](/zh-CN/docs/Web/CSS) [伪类](/zh-CN/docs/Web/CSS/Pseudo-classes)在用户使用指针设备与元素进行交互时匹配,但不一定激活它。通常情况下,用户将光标(鼠标指针)悬停在元素上时触发。 {{EmbedInteractiveExample("pages/tabbed/pseudo-class-hover.html", "tabbed-shorter")}} diff --git a/files/zh-cn/web/css/_colon_in-range/index.md b/files/zh-cn/web/css/_colon_in-range/index.md index 6bf2742f9b3de4..a5b6272057d8aa 100644 --- a/files/zh-cn/web/css/_colon_in-range/index.md +++ b/files/zh-cn/web/css/_colon_in-range/index.md @@ -1,5 +1,5 @@ --- -title: ':in-range' +title: ":in-range" slug: Web/CSS/:in-range --- diff --git a/files/zh-cn/web/css/_colon_lang/index.md b/files/zh-cn/web/css/_colon_lang/index.md index 5798a762bd3f27..86580e5d52b656 100644 --- a/files/zh-cn/web/css/_colon_lang/index.md +++ b/files/zh-cn/web/css/_colon_lang/index.md @@ -48,13 +48,13 @@ slug: Web/CSS/:lang ```css :lang(en) > q { - quotes: "\201C""\201D""\2018""\2019"; + quotes: "\201C" "\201D" "\2018" "\2019"; } :lang(fr) > q { quotes: "« " " »"; } :lang(de) > q { - quotes: "»" "«" "\2039""\203A"; + quotes: "»" "«" "\2039" "\203A"; } ``` diff --git a/files/zh-cn/web/css/_colon_last-of-type/index.md b/files/zh-cn/web/css/_colon_last-of-type/index.md index 5fefa76a424a47..07b9bc1ead1e20 100644 --- a/files/zh-cn/web/css/_colon_last-of-type/index.md +++ b/files/zh-cn/web/css/_colon_last-of-type/index.md @@ -1,5 +1,5 @@ --- -title: ':last-of-type' +title: ":last-of-type" slug: Web/CSS/:last-of-type --- @@ -25,22 +25,23 @@ p em:last-of-type { ```html

- 我没有颜色 :(
- 我没有颜色 :(
- 我有颜色 :D
- 我也没有颜色 :(
+ 我没有颜色 :(
+ 我没有颜色 :(
+ 我有颜色 :D
+ 我也没有颜色 :(

- 我没有颜色 :(
- 我有颜色!
- 我没有颜色 :(
- 我有颜色 :D
+ 我没有颜色 :(
+ 我有颜色!
+ 我没有颜色 :(
+ 我有颜色 :D
- 我在子元素里,但没有颜色!
- 我没有颜色
- 我却有颜色!
-

+ 我在子元素里,但没有颜色!
+ 我没有颜色
+ 我却有颜色!

我也没有颜色 :(

``` diff --git a/files/zh-cn/web/css/_colon_left/index.md b/files/zh-cn/web/css/_colon_left/index.md index a8fe23dd12cc4a..2efb7905f122ef 100644 --- a/files/zh-cn/web/css/_colon_left/index.md +++ b/files/zh-cn/web/css/_colon_left/index.md @@ -1,5 +1,5 @@ --- -title: ':left' +title: ":left" slug: Web/CSS/:left --- diff --git a/files/zh-cn/web/css/_colon_link/index.md b/files/zh-cn/web/css/_colon_link/index.md index e3c5deaaa98cca..d06ae0fe13ca5b 100644 --- a/files/zh-cn/web/css/_colon_link/index.md +++ b/files/zh-cn/web/css/_colon_link/index.md @@ -1,5 +1,5 @@ --- -title: ':link' +title: ":link" slug: Web/CSS/:link --- diff --git a/files/zh-cn/web/css/_colon_not/index.md b/files/zh-cn/web/css/_colon_not/index.md index 82768ad1d3c95b..7e9f7d8fb92ee7 100644 --- a/files/zh-cn/web/css/_colon_not/index.md +++ b/files/zh-cn/web/css/_colon_not/index.md @@ -1,5 +1,5 @@ --- -title: ':not()' +title: ":not()" slug: Web/CSS/:not --- diff --git a/files/zh-cn/web/css/_colon_nth-child/index.md b/files/zh-cn/web/css/_colon_nth-child/index.md index f8201cc89e544c..88843c5f9b4bbf 100644 --- a/files/zh-cn/web/css/_colon_nth-child/index.md +++ b/files/zh-cn/web/css/_colon_nth-child/index.md @@ -1,5 +1,5 @@ --- -title: ':nth-child' +title: ":nth-child" slug: Web/CSS/:nth-child --- @@ -45,8 +45,10 @@ slug: Web/CSS/:nth-child #### HTML ```html -

span:nth-child(2n+1), WITHOUT an - <em> among the child elements.

+

+ span:nth-child(2n+1), WITHOUT an <em> among + the child elements. +

Children 1, 3, 5, and 7 are selected.

Span 1! @@ -58,13 +60,17 @@ slug: Web/CSS/:nth-child Span 7!
-
- -

span:nth-child(2n+1), WITH an - <em> among the child elements.

-

Children 1, 5, and 7 are selected.
- 3 is used in the counting because it is a child, but it isn't - selected because it isn't a <span>.

+
+ +

+ span:nth-child(2n+1), WITH an <em> among the + child elements. +

+

+ Children 1, 5, and 7 are selected.
+ 3 is used in the counting because it is a child, but it isn't selected because + it isn't a <span>. +

Span! Span @@ -76,15 +82,19 @@ slug: Web/CSS/:nth-child Span
-
- -

span:nth-of-type(2n+1), WITH an - <em> among the child elements.

-

Children 1, 4, 6, and 8 are selected.
- 3 isn't used in the counting or selected because it is an <em>, - not a <span>, and nth-of-type only selects - children of that type. The <em> is completely skipped - over and ignored.

+
+ +

+ span:nth-of-type(2n+1), WITH an <em> among the + child elements. +

+

+ Children 1, 4, 6, and 8 are selected.
+ 3 isn't used in the counting or selected because it is an + <em>, not a <span>, and + nth-of-type only selects children of that type. The + <em> is completely skipped over and ignored. +

Span! Span @@ -112,9 +122,9 @@ div em { margin-bottom: 3px; } -.first span:nth-child(2n+1), -.second span:nth-child(2n+1), -.third span:nth-of-type(2n+1) { +.first span:nth-child(2n + 1), +.second span:nth-child(2n + 1), +.third span:nth-of-type(2n + 1) { background-color: lime; } ``` diff --git a/files/zh-cn/web/css/_colon_nth-last-child/index.md b/files/zh-cn/web/css/_colon_nth-last-child/index.md index 639ca859508e89..fe9d74c1efc718 100644 --- a/files/zh-cn/web/css/_colon_nth-last-child/index.md +++ b/files/zh-cn/web/css/_colon_nth-last-child/index.md @@ -1,5 +1,5 @@ --- -title: ':nth-last-child' +title: ":nth-last-child" slug: Web/CSS/:nth-last-child --- @@ -69,16 +69,16 @@ slug: Web/CSS/:nth-last-child First line - Second line + Second line - Third line + Third line - Fourth line + Fourth line - Fifth line + Fifth line @@ -92,12 +92,12 @@ table { } /* Selects the last three elements */ -tr:nth-last-child(-n+3) { +tr:nth-last-child(-n + 3) { background-color: pink; } /* Selects every element starting from the second to last item */ -tr:nth-last-child(n+2) { +tr:nth-last-child(n + 2) { color: blue; } @@ -138,8 +138,8 @@ tr:nth-last-child(2) { ```css /* If there are at least three list items, style them all */ -li:nth-last-child(n+3), -li:nth-last-child(n+3) ~ li { +li:nth-last-child(n + 3), +li:nth-last-child(n + 3) ~ li { color: red; } ``` diff --git a/files/zh-cn/web/css/_colon_nth-of-type/index.md b/files/zh-cn/web/css/_colon_nth-of-type/index.md index 67bab59ebb6f6e..6423c2c8dd27f0 100644 --- a/files/zh-cn/web/css/_colon_nth-of-type/index.md +++ b/files/zh-cn/web/css/_colon_nth-of-type/index.md @@ -1,5 +1,5 @@ --- -title: ':nth-of-type' +title: ":nth-of-type" slug: Web/CSS/:nth-of-type --- @@ -42,7 +42,7 @@ slug: Web/CSS/:nth-of-type ```css /* 奇数段 */ -p:nth-of-type(2n+1) { +p:nth-of-type(2n + 1) { color: red; } diff --git a/files/zh-cn/web/css/_colon_only-of-type/index.md b/files/zh-cn/web/css/_colon_only-of-type/index.md index 4d5f62548eec4f..3fdbbf74d15e10 100644 --- a/files/zh-cn/web/css/_colon_only-of-type/index.md +++ b/files/zh-cn/web/css/_colon_only-of-type/index.md @@ -1,5 +1,5 @@ --- -title: ':only-of-type' +title: ":only-of-type" slug: Web/CSS/:only-of-type --- diff --git a/files/zh-cn/web/css/_colon_optional/index.md b/files/zh-cn/web/css/_colon_optional/index.md index a200c64a68dbff..08d0280085bc0b 100644 --- a/files/zh-cn/web/css/_colon_optional/index.md +++ b/files/zh-cn/web/css/_colon_optional/index.md @@ -1,5 +1,5 @@ --- -title: ':optional' +title: ":optional" slug: Web/CSS/:optional --- diff --git a/files/zh-cn/web/css/_colon_out-of-range/index.md b/files/zh-cn/web/css/_colon_out-of-range/index.md index 12a8581231d664..7caeaa1c6375e9 100644 --- a/files/zh-cn/web/css/_colon_out-of-range/index.md +++ b/files/zh-cn/web/css/_colon_out-of-range/index.md @@ -1,5 +1,5 @@ --- -title: ':out-of-range' +title: ":out-of-range" slug: Web/CSS/:out-of-range --- diff --git a/files/zh-cn/web/css/_colon_picture-in-picture/index.md b/files/zh-cn/web/css/_colon_picture-in-picture/index.md index 815651514a7c13..d7c4d2e84e1b22 100644 --- a/files/zh-cn/web/css/_colon_picture-in-picture/index.md +++ b/files/zh-cn/web/css/_colon_picture-in-picture/index.md @@ -1,5 +1,5 @@ --- -title: ':picture-in-picture' +title: ":picture-in-picture" slug: Web/CSS/:picture-in-picture --- diff --git a/files/zh-cn/web/css/_colon_placeholder-shown/index.md b/files/zh-cn/web/css/_colon_placeholder-shown/index.md index 6fdf4bb5c4ebd2..1f14db98074ac5 100644 --- a/files/zh-cn/web/css/_colon_placeholder-shown/index.md +++ b/files/zh-cn/web/css/_colon_placeholder-shown/index.md @@ -26,7 +26,7 @@ slug: Web/CSS/:placeholder-shown #### HTML ```html - + ``` #### CSS diff --git a/files/zh-cn/web/css/_colon_read-only/index.md b/files/zh-cn/web/css/_colon_read-only/index.md index 2c864edd2b5392..fa65bb5f809e8e 100644 --- a/files/zh-cn/web/css/_colon_read-only/index.md +++ b/files/zh-cn/web/css/_colon_read-only/index.md @@ -1,5 +1,5 @@ --- -title: ':read-only' +title: ":read-only" slug: Web/CSS/:read-only --- @@ -31,8 +31,8 @@ input:read-only { ### HTML ```html - - + +

This is a normal paragraph.

You can edit this paragraph!

``` @@ -40,13 +40,25 @@ input:read-only { ### CSS ```css -input { min-width: 25em; } -input:-moz-read-only { background: cyan; } -input:read-only { background: cyan; } +input { + min-width: 25em; +} +input:-moz-read-only { + background: cyan; +} +input:read-only { + background: cyan; +} -p:-moz-read-only { background: lightgray; } -p:read-only { background: lightgray; } -p[contenteditable="true"] { color: blue; } +p:-moz-read-only { + background: lightgray; +} +p:read-only { + background: lightgray; +} +p[contenteditable="true"] { + color: blue; +} ``` ### 结果 diff --git a/files/zh-cn/web/css/_colon_read-write/index.md b/files/zh-cn/web/css/_colon_read-write/index.md index 763770085f2b53..cbaa8179036aa8 100644 --- a/files/zh-cn/web/css/_colon_read-write/index.md +++ b/files/zh-cn/web/css/_colon_read-write/index.md @@ -1,5 +1,5 @@ --- -title: ':read-write' +title: ":read-write" slug: Web/CSS/:read-write --- @@ -31,8 +31,8 @@ input:read-write { ### HTML ```html - - + +

This is a normal paragraph.

You can edit this paragraph!

``` @@ -40,13 +40,25 @@ input:read-write { ### CSS ```css -input { min-width: 25em; } -input:-moz-read-write { background: cyan; } -input:read-write { background: cyan; } +input { + min-width: 25em; +} +input:-moz-read-write { + background: cyan; +} +input:read-write { + background: cyan; +} -p:-moz-read-write { background: lightgray; } -p:read-write { background: lightgray; } -p[contenteditable="true"] { color: blue; } +p:-moz-read-write { + background: lightgray; +} +p:read-write { + background: lightgray; +} +p[contenteditable="true"] { + color: blue; +} ``` ### 结果 diff --git a/files/zh-cn/web/css/_colon_required/index.md b/files/zh-cn/web/css/_colon_required/index.md index 3add5337b39651..5bca0cf3d3e32d 100644 --- a/files/zh-cn/web/css/_colon_required/index.md +++ b/files/zh-cn/web/css/_colon_required/index.md @@ -1,5 +1,5 @@ --- -title: ':required' +title: ":required" slug: Web/CSS/:required --- diff --git a/files/zh-cn/web/css/_colon_right/index.md b/files/zh-cn/web/css/_colon_right/index.md index 4533d97e83b841..c4f2f8576002c8 100644 --- a/files/zh-cn/web/css/_colon_right/index.md +++ b/files/zh-cn/web/css/_colon_right/index.md @@ -1,5 +1,5 @@ --- -title: ':right' +title: ":right" slug: Web/CSS/:right --- diff --git a/files/zh-cn/web/css/_colon_root/index.md b/files/zh-cn/web/css/_colon_root/index.md index a9446cc8ec1c75..ea0121a38cf572 100644 --- a/files/zh-cn/web/css/_colon_root/index.md +++ b/files/zh-cn/web/css/_colon_root/index.md @@ -1,5 +1,5 @@ --- -title: ':root' +title: ":root" slug: Web/CSS/:root --- diff --git a/files/zh-cn/web/css/_colon_scope/index.md b/files/zh-cn/web/css/_colon_scope/index.md index 23c4ca5878ea41..598b9bfc87a16f 100644 --- a/files/zh-cn/web/css/_colon_scope/index.md +++ b/files/zh-cn/web/css/_colon_scope/index.md @@ -1,5 +1,5 @@ --- -title: ':scope' +title: ":scope" slug: Web/CSS/:scope --- @@ -57,29 +57,31 @@ if (paragraph.matches(":scope")) { #### JavaScript ```js -var context = document.getElementById('context'); -var selected = context.querySelectorAll(':scope > div'); - -document.getElementById('results').innerHTML = Array.prototype.map.call(selected, function (element) { - return '#' + element.getAttribute('id'); -}).join(', '); +var context = document.getElementById("context"); +var selected = context.querySelectorAll(":scope > div"); + +document.getElementById("results").innerHTML = Array.prototype.map + .call(selected, function (element) { + return "#" + element.getAttribute("id"); + }) + .join(", "); ``` #### HTML ```html
-
-
-
-
-
-
-
+
+
+
+
+
+
+

- Selected elements ids : - + Selected elements ids : +

``` diff --git a/files/zh-cn/web/css/_colon_target/index.md b/files/zh-cn/web/css/_colon_target/index.md index cea83a42044d04..340af2e6bd4a2e 100644 --- a/files/zh-cn/web/css/_colon_target/index.md +++ b/files/zh-cn/web/css/_colon_target/index.md @@ -1,5 +1,5 @@ --- -title: ':target' +title: ":target" slug: Web/CSS/:target --- @@ -45,9 +45,9 @@ http://www.example.com/index.html#section2 ```html

目录

    -
  1. 跳转到第一个段落!
  2. -
  3. 跳转到第二个段落!
  4. -
  5. 此链接不会跳转,因为目标不存在。
  6. +
  7. 跳转到第一个段落!
  8. +
  9. 跳转到第二个段落!
  10. +
  11. 此链接不会跳转,因为目标不存在。

我的趣味文章

@@ -67,7 +67,7 @@ p:target::before { font: 70% sans-serif; content: "►"; color: limegreen; - margin-right: .25em; + margin-right: 0.25em; } /*在目标元素中使用 italic 样式*/ @@ -97,17 +97,20 @@ p:target i { ``` @@ -170,7 +173,7 @@ p:target i { width: 100%; height: 100%; position: fixed; - background-color: rgba(0,0,0,.7); + background-color: rgba(0, 0, 0, 0.7); content: ""; cursor: default; } diff --git a/files/zh-cn/web/css/_colon_valid/index.md b/files/zh-cn/web/css/_colon_valid/index.md index b3816c255b1f9a..f5e971101d2dc4 100644 --- a/files/zh-cn/web/css/_colon_valid/index.md +++ b/files/zh-cn/web/css/_colon_valid/index.md @@ -1,5 +1,5 @@ --- -title: ':valid' +title: ":valid" slug: Web/CSS/:valid --- diff --git a/files/zh-cn/web/css/_colon_where/index.md b/files/zh-cn/web/css/_colon_where/index.md index dc9aeca91dfdfc..dbf73b7b85e063 100644 --- a/files/zh-cn/web/css/_colon_where/index.md +++ b/files/zh-cn/web/css/_colon_where/index.md @@ -1,5 +1,5 @@ --- -title: ':where()' +title: ":where()" slug: Web/CSS/:where --- diff --git a/files/zh-cn/web/css/_doublecolon_-moz-progress-bar/index.md b/files/zh-cn/web/css/_doublecolon_-moz-progress-bar/index.md index 5d440d2d36d591..e836c684145c41 100644 --- a/files/zh-cn/web/css/_doublecolon_-moz-progress-bar/index.md +++ b/files/zh-cn/web/css/_doublecolon_-moz-progress-bar/index.md @@ -1,5 +1,5 @@ --- -title: '::-moz-progress-bar' +title: "::-moz-progress-bar" slug: Web/CSS/::-moz-progress-bar --- diff --git a/files/zh-cn/web/css/_doublecolon_-moz-range-progress/index.md b/files/zh-cn/web/css/_doublecolon_-moz-range-progress/index.md index 5bb82d0f2172b0..cc5c9089442e97 100644 --- a/files/zh-cn/web/css/_doublecolon_-moz-range-progress/index.md +++ b/files/zh-cn/web/css/_doublecolon_-moz-range-progress/index.md @@ -1,5 +1,5 @@ --- -title: '::-moz-range-progress' +title: "::-moz-range-progress" slug: Web/CSS/::-moz-range-progress --- @@ -18,13 +18,13 @@ The **`::-moz-range-progress`** [CSS](/zh-CN/docs/Web/CSS) [伪元素](/zh-CN/do ### HTML ```html - + ``` ### CSS ```css -input[type=range]::-moz-range-progress { +input[type="range"]::-moz-range-progress { background-color: green; height: 1em; } diff --git a/files/zh-cn/web/css/_doublecolon_-webkit-progress-bar/index.md b/files/zh-cn/web/css/_doublecolon_-webkit-progress-bar/index.md index ba8d86ecf199bf..84127ebed75b03 100644 --- a/files/zh-cn/web/css/_doublecolon_-webkit-progress-bar/index.md +++ b/files/zh-cn/web/css/_doublecolon_-webkit-progress-bar/index.md @@ -1,5 +1,5 @@ --- -title: '::-webkit-progress-bar' +title: "::-webkit-progress-bar" slug: Web/CSS/::-webkit-progress-bar --- @@ -21,14 +21,14 @@ progress { } ::-webkit-progress-bar { - background-color: orange; + background-color: orange; } ``` ### HTML ```html - + ``` ### 结果 diff --git a/files/zh-cn/web/css/_doublecolon_-webkit-progress-inner-element/index.md b/files/zh-cn/web/css/_doublecolon_-webkit-progress-inner-element/index.md index cbc523c0023318..eed61af3bad8a9 100644 --- a/files/zh-cn/web/css/_doublecolon_-webkit-progress-inner-element/index.md +++ b/files/zh-cn/web/css/_doublecolon_-webkit-progress-inner-element/index.md @@ -1,5 +1,5 @@ --- -title: '::-webkit-progress-inner-element' +title: "::-webkit-progress-inner-element" slug: Web/CSS/::-webkit-progress-inner-element --- @@ -14,7 +14,7 @@ slug: Web/CSS/::-webkit-progress-inner-element ### HTML ```html - + ``` ### CSS diff --git a/files/zh-cn/web/css/_doublecolon_-webkit-progress-value/index.md b/files/zh-cn/web/css/_doublecolon_-webkit-progress-value/index.md index aede3b97e27eb6..dc4602d77c5ab3 100644 --- a/files/zh-cn/web/css/_doublecolon_-webkit-progress-value/index.md +++ b/files/zh-cn/web/css/_doublecolon_-webkit-progress-value/index.md @@ -1,5 +1,5 @@ --- -title: '::-webkit-progress-value' +title: "::-webkit-progress-value" slug: Web/CSS/::-webkit-progress-value --- @@ -14,7 +14,7 @@ slug: Web/CSS/::-webkit-progress-value ### HTML ```html - + ``` ### CSS diff --git a/files/zh-cn/web/css/_doublecolon_-webkit-scrollbar/index.md b/files/zh-cn/web/css/_doublecolon_-webkit-scrollbar/index.md index ef6e6a200b3bbd..5cedcf10136e21 100644 --- a/files/zh-cn/web/css/_doublecolon_-webkit-scrollbar/index.md +++ b/files/zh-cn/web/css/_doublecolon_-webkit-scrollbar/index.md @@ -1,6 +1,6 @@ --- -title: '::-webkit-scrollbar' -slug: 'Web/CSS/::-webkit-scrollbar' +title: "::-webkit-scrollbar" +slug: "Web/CSS/::-webkit-scrollbar" --- {{CSSRef}}{{Non-standard_Header}} @@ -28,7 +28,9 @@ slug: 'Web/CSS/::-webkit-scrollbar' ### CSS ```css -.visible-scrollbar, .invisible-scrollbar, .mostly-customized-scrollbar { +.visible-scrollbar, +.invisible-scrollbar, +.mostly-customized-scrollbar { display: block; width: 10em; overflow: auto; @@ -57,28 +59,27 @@ slug: 'Web/CSS/::-webkit-scrollbar' ```html
- Etiam sagittis sem sed lacus laoreet, eu fermentum eros auctor. - Proin at nulla elementum, consectetur ex eget, commodo ante. - Sed eros mi, bibendum ut dignissim et, maximus eget nibh. Phasellus - blandit quam turpis, at mollis velit pretium ut. Nunc consequat - efficitur ultrices. Nullam hendrerit posuere est. Nulla libero - sapien, egestas ac felis porta, cursus ultricies quam. Vestibulum - tincidunt accumsan sapien, a fringilla dui semper in. Vivamus - consectetur ipsum a ornare blandit. Aenean tempus at lorem sit - amet faucibus. Curabitur nibh justo, faucibus sed velit cursus, - mattis cursus dolor. Pellentesque id pretium est. Quisque - convallis nisi a diam malesuada mollis. Aliquam at enim ligula. + Etiam sagittis sem sed lacus laoreet, eu fermentum eros auctor. Proin at nulla + elementum, consectetur ex eget, commodo ante. Sed eros mi, bibendum ut + dignissim et, maximus eget nibh. Phasellus blandit quam turpis, at mollis + velit pretium ut. Nunc consequat efficitur ultrices. Nullam hendrerit posuere + est. Nulla libero sapien, egestas ac felis porta, cursus ultricies quam. + Vestibulum tincidunt accumsan sapien, a fringilla dui semper in. Vivamus + consectetur ipsum a ornare blandit. Aenean tempus at lorem sit amet faucibus. + Curabitur nibh justo, faucibus sed velit cursus, mattis cursus dolor. + Pellentesque id pretium est. Quisque convallis nisi a diam malesuada mollis. + Aliquam at enim ligula.
-Thisisaveeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeerylongword + Thisisaveeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeerylongword
-Thisisaveeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeerylongword
-And pretty tall
-thing with weird scrollbars.
-Who thought scrollbars could be made weeeeird? + Thisisaveeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeerylongword
+ And pretty tall
+ thing with weird scrollbars.
+ Who thought scrollbars could be made weeeeird?
``` diff --git a/files/zh-cn/web/css/_doublecolon_-webkit-slider-runnable-track/index.md b/files/zh-cn/web/css/_doublecolon_-webkit-slider-runnable-track/index.md index f652ab1c6f7d9d..96623fbff88318 100644 --- a/files/zh-cn/web/css/_doublecolon_-webkit-slider-runnable-track/index.md +++ b/files/zh-cn/web/css/_doublecolon_-webkit-slider-runnable-track/index.md @@ -1,5 +1,5 @@ --- -title: '::-webkit-slider-runnable-track' +title: "::-webkit-slider-runnable-track" slug: Web/CSS/::-webkit-slider-runnable-track --- diff --git a/files/zh-cn/web/css/_doublecolon_-webkit-slider-thumb/index.md b/files/zh-cn/web/css/_doublecolon_-webkit-slider-thumb/index.md index c73e00977d47cf..a385be36ff28ba 100644 --- a/files/zh-cn/web/css/_doublecolon_-webkit-slider-thumb/index.md +++ b/files/zh-cn/web/css/_doublecolon_-webkit-slider-thumb/index.md @@ -1,5 +1,5 @@ --- -title: '::-webkit-slider-thumb' +title: "::-webkit-slider-thumb" slug: Web/CSS/::-webkit-slider-thumb --- @@ -16,19 +16,19 @@ slug: Web/CSS/::-webkit-slider-thumb 该伪类需要配和 **::-webkit-slider-runnable-track** 使用,否则会没有效果 ```css -input[type=range]::-webkit-slider-thumb{ - -webkit-appearance: none;/*清除默认样式*/ - height:7vw;/*设置滑块高度*/ - width:5vw;/*设置滑块宽度*/ - background:#000;/*设置背景色*/ - border-radius:10vw 10vw;/*加个圆角边*/ - margin-top:-1vw;/*使用 position 的话会导致滑块不滑动,但是绑定的 value 是改变的,所以这里使用 margin-top 去做定位*/ +input[type="range"]::-webkit-slider-thumb { + -webkit-appearance: none; /*清除默认样式*/ + height: 7vw; /*设置滑块高度*/ + width: 5vw; /*设置滑块宽度*/ + background: #000; /*设置背景色*/ + border-radius: 10vw 10vw; /*加个圆角边*/ + margin-top: -1vw; /*使用 position 的话会导致滑块不滑动,但是绑定的 value 是改变的,所以这里使用 margin-top 去做定位*/ } -input[type=range]::-webkit-slider-runnable-track{ +input[type="range"]::-webkit-slider-runnable-track { border-radius: 30px; - background:#128; - height:15px; + background: #128; + height: 15px; } ``` diff --git a/files/zh-cn/web/css/_doublecolon_after/index.md b/files/zh-cn/web/css/_doublecolon_after/index.md index 4d3407084289eb..65d7e81383e20c 100644 --- a/files/zh-cn/web/css/_doublecolon_after/index.md +++ b/files/zh-cn/web/css/_doublecolon_after/index.md @@ -1,5 +1,5 @@ --- -title: '::after (:after)' +title: "::after (:after)" slug: Web/CSS/::after --- @@ -28,8 +28,9 @@ CSS[伪元素](/zh-CN/CSS/Pseudo-elements)`::after`用来创建一个伪元素 ```html

这是些无聊的文字

这是不无聊也不有趣的文字

-

在 MDN 上做贡献简单又轻松。 -按右上角的编辑按钮添加新示例或改进旧示例!

+

+ 在 MDN 上做贡献简单又轻松。 按右上角的编辑按钮添加新示例或改进旧示例! +

``` ```css @@ -58,14 +59,14 @@ CSS[伪元素](/zh-CN/CSS/Pseudo-elements)`::after`用来创建一个伪元素 ```css .ribbon { - background-color: #5BC8F7; + background-color: #5bc8f7; } .ribbon::after { - content: "Look at this orange box."; - background-color: #FFBA10; - border-color: black; - border-style: dotted; + content: "Look at this orange box."; + background-color: #ffba10; + border-color: black; + border-style: dotted; } ``` @@ -78,8 +79,10 @@ CSS[伪元素](/zh-CN/CSS/Pseudo-elements)`::after`用来创建一个伪元素 接下来的示例展示了用`::after`[伪元素](/zh-CN/CSS/Pseudo-elements),[`attr()`](/zh-CN/docs/CSS/attr)CSS 表达式和一个[自定义数据属性](/zh-CN/HTML/Global_attributes#attr-data-*) `data-descr` 创建一个纯 CSS,词汇表提示工具。在[单独页面](/files/4591/css-only_tooltips.html)看这个例子。 ```html -

这是上面代码的实现
- 我们有一些 文字 有一些 +

+ 这是上面代码的实现
+ 我们有一些 + 文字 有一些 提示
把鼠标放上去看看

@@ -87,25 +90,25 @@ CSS[伪元素](/zh-CN/CSS/Pseudo-elements)`::after`用来创建一个伪元素 ```css span[data-descr] { - position: relative; - text-decoration: underline; - color: #00F; - cursor: help; + position: relative; + text-decoration: underline; + color: #00f; + cursor: help; } span[data-descr]:hover::after { - content: attr(data-descr); - position: absolute; - left: 0; - top: 24px; - min-width: 200px; - border: 1px #aaaaaa solid; - border-radius: 10px; - background-color: #ffffcc; - padding: 12px; - color: #000000; - font-size: 14px; - z-index: 1; + content: attr(data-descr); + position: absolute; + left: 0; + top: 24px; + min-width: 200px; + border: 1px #aaaaaa solid; + border-radius: 10px; + background-color: #ffffcc; + padding: 12px; + color: #000000; + font-size: 14px; + z-index: 1; } ``` diff --git a/files/zh-cn/web/css/_doublecolon_backdrop/index.md b/files/zh-cn/web/css/_doublecolon_backdrop/index.md index 46e59a109e750e..43d92b5446efe7 100644 --- a/files/zh-cn/web/css/_doublecolon_backdrop/index.md +++ b/files/zh-cn/web/css/_doublecolon_backdrop/index.md @@ -1,5 +1,5 @@ --- -title: '::backdrop' +title: "::backdrop" slug: Web/CSS/::backdrop --- @@ -10,7 +10,7 @@ slug: Web/CSS/::backdrop ```css /* Backdrop 只有通过 dialog.showModal() 打开对话框时会被显示 */ dialog::backdrop { - background: rgba(255,0,0,.25); + background: rgba(255, 0, 0, 0.25); } ``` diff --git a/files/zh-cn/web/css/_doublecolon_before/index.md b/files/zh-cn/web/css/_doublecolon_before/index.md index ce540d8067ff44..f3d1d1d34f6faf 100644 --- a/files/zh-cn/web/css/_doublecolon_before/index.md +++ b/files/zh-cn/web/css/_doublecolon_before/index.md @@ -1,5 +1,5 @@ --- -title: '::before (:before)' +title: "::before (:before)" slug: Web/CSS/::before --- @@ -14,7 +14,7 @@ a::before { } ``` -> **备注:** 由 `::before` 和`::after` 生成的伪元素[包含在元素格式框内](https://www.w3.org/TR/CSS2/generate.html#before-after-content),因此不能应用在[*替换元素上*](/zh-CN/docs/Web/CSS/Replaced_element),比如 {{htmlelement("img")}} 或 {{htmlelement("br")}} 元素。 +> **备注:** 由 `::before` 和`::after` 生成的伪元素[包含在元素格式框内](https://www.w3.org/TR/CSS2/generate.html#before-after-content),因此不能应用在[_替换元素上_](/zh-CN/docs/Web/CSS/Replaced_element),比如 {{htmlelement("img")}} 或 {{htmlelement("br")}} 元素。 ## 语法 @@ -74,14 +74,14 @@ q::after { ```css .ribbon { - background-color: #5BC8F7; + background-color: #5bc8f7; } .ribbon::before { - content: "Look at this orange box."; - background-color: #FFBA10; - border-color: black; - border-style: dotted; + content: "Look at this orange box."; + background-color: #ffba10; + border-color: black; + border-style: dotted; } ``` @@ -119,11 +119,11 @@ li { } li.done { - background: #CCFF99; + background: #ccff99; } li.done::before { - content: ''; + content: ""; position: absolute; border-color: #009933; border-style: solid; @@ -140,15 +140,19 @@ li.done::before { #### JavaScript ```js -var list = document.querySelector('ul'); -list.addEventListener('click', function(ev) { - if( ev.target.tagName === 'LI') { - ev.target.classList.toggle('done'); - } -}, false); +var list = document.querySelector("ul"); +list.addEventListener( + "click", + function (ev) { + if (ev.target.tagName === "LI") { + ev.target.classList.toggle("done"); + } + }, + false, +); ``` -下面展示的是最终得到的结果。请注意我们没有使用任何图标,对勾标识实际上是使用 CSS 定义了样式的` ::before `伪元素。接下来建立几个待办事项来完成它们吧。 +下面展示的是最终得到的结果。请注意我们没有使用任何图标,对勾标识实际上是使用 CSS 定义了样式的`::before`伪元素。接下来建立几个待办事项来完成它们吧。 #### 结果 @@ -162,32 +166,38 @@ list.addEventListener('click', function(ev) { ```html
-"Floated Before" should be generated on the left of the -viewport and not allow overflow in this line to flow under it. Likewise -should "Floated After" appear on the right of the viewport and not allow this -line to flow under it. + "Floated Before" should be generated on the left of the viewport and not + allow overflow in this line to flow under it. Likewise should "Floated + After" appear on the right of the viewport and not allow this line to flow + under it.
``` #### CSS ```css -#floatme { float: left; width: 50%; } +#floatme { + float: left; + width: 50%; +} /* To get an empty column, just indicate a hex code for a non-breaking space: \a0 as the content (use \0000a0 when following such a space with other characters) */ .example::before { content: "Floated Before"; float: left; - width: 25% + width: 25%; } .example::after { content: "Floated After"; float: right; - width:25% + width: 25%; } /* For styling */ -.example::before, .example::after{ +.example::before, +.example::after { background: yellow; color: red; } diff --git a/files/zh-cn/web/css/_doublecolon_cue/index.md b/files/zh-cn/web/css/_doublecolon_cue/index.md index 8214e95161151b..19c2873ab6f4c0 100644 --- a/files/zh-cn/web/css/_doublecolon_cue/index.md +++ b/files/zh-cn/web/css/_doublecolon_cue/index.md @@ -1,5 +1,5 @@ --- -title: '::cue (:cue)' +title: "::cue (:cue)" slug: Web/CSS/::cue --- diff --git a/files/zh-cn/web/css/_doublecolon_file-selector-button/index.md b/files/zh-cn/web/css/_doublecolon_file-selector-button/index.md index 1dc6ec2470786b..0ac07b66ae35aa 100644 --- a/files/zh-cn/web/css/_doublecolon_file-selector-button/index.md +++ b/files/zh-cn/web/css/_doublecolon_file-selector-button/index.md @@ -1,5 +1,5 @@ --- -title: '::file-selector-button' +title: "::file-selector-button" slug: Web/CSS/::file-selector-button --- diff --git a/files/zh-cn/web/css/_doublecolon_first-letter/index.md b/files/zh-cn/web/css/_doublecolon_first-letter/index.md index 4de3f9dfec6426..a2f83fed8873f6 100644 --- a/files/zh-cn/web/css/_doublecolon_first-letter/index.md +++ b/files/zh-cn/web/css/_doublecolon_first-letter/index.md @@ -1,5 +1,5 @@ --- -title: '::first-letter (:first-letter)' +title: "::first-letter (:first-letter)" slug: Web/CSS/::first-letter --- @@ -47,7 +47,8 @@ p::first-letter { ```css /* 使每段开头的第一个字母变红变大 */ -p::first-letter { /* 使用:first 来兼容 IE8- */ +p::first-letter { + /* 使用:first 来兼容 IE8- */ color: red; font-size: 130%; } diff --git a/files/zh-cn/web/css/_doublecolon_first-line/index.md b/files/zh-cn/web/css/_doublecolon_first-line/index.md index 81987c86ef5fef..484f64cb27984a 100644 --- a/files/zh-cn/web/css/_doublecolon_first-line/index.md +++ b/files/zh-cn/web/css/_doublecolon_first-line/index.md @@ -1,5 +1,5 @@ --- -title: '::first-line (:first-line)' +title: "::first-line (:first-line)" slug: Web/CSS/::first-line --- @@ -42,14 +42,18 @@ slug: Web/CSS/::first-line #### HTML ```html -

Lorem ipsum dolor sit amet, consectetur adipisicing elit, -sed do eiusmod tempor incididunt ut labore.

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod + tempor incididunt ut labore. +

``` #### CSS ```css -p::first-line { text-transform: uppercase } +p::first-line { + text-transform: uppercase; +} ``` #### 输出 @@ -63,14 +67,18 @@ p::first-line { text-transform: uppercase } #### HTML ```html -

Lorem ipsum dolor sit amet, consectetur adipisicing elit, -sed do eiusmod tempor incididunt ut labore.

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod + tempor incididunt ut labore. +

``` #### CSS ```css -p::first-line { margin-left: 20px } +p::first-line { + margin-left: 20px; +} ``` #### 输出 @@ -84,14 +92,18 @@ p::first-line { margin-left: 20px } #### HTML ```html -

Lorem ipsum dolor sit amet, consectetur adipisicing elit, -sed do eiusmod tempor incididunt ut labore.

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod + tempor incididunt ut labore. +

``` #### CSS ```css -p::first-line { text-indent: 20px } +p::first-line { + text-indent: 20px; +} ``` #### 输出 diff --git a/files/zh-cn/web/css/_doublecolon_grammar-error/index.md b/files/zh-cn/web/css/_doublecolon_grammar-error/index.md index 26778bd14d3972..05d7b6e03aed2d 100644 --- a/files/zh-cn/web/css/_doublecolon_grammar-error/index.md +++ b/files/zh-cn/web/css/_doublecolon_grammar-error/index.md @@ -1,5 +1,5 @@ --- -title: '::grammar-error' +title: "::grammar-error" slug: Web/CSS/::grammar-error --- diff --git a/files/zh-cn/web/css/_doublecolon_part/index.md b/files/zh-cn/web/css/_doublecolon_part/index.md index 2d12710f153e42..ebd2e068f7e88b 100644 --- a/files/zh-cn/web/css/_doublecolon_part/index.md +++ b/files/zh-cn/web/css/_doublecolon_part/index.md @@ -1,5 +1,5 @@ --- -title: '::part()' +title: "::part()" slug: Web/CSS/::part --- @@ -23,18 +23,20 @@ custom-element::part(foo) { ```html @@ -74,13 +76,16 @@ tabbed-custom-element::part(active) { ```js let template = document.querySelector("#tabbed-custom-element"); -globalThis.customElements.define(template.id, class extends HTMLElement { - constructor() { - super(); - this.attachShadow({ mode: "open" }); - this.shadowRoot.appendChild(template.content); - } -}); +globalThis.customElements.define( + template.id, + class extends HTMLElement { + constructor() { + super(); + this.attachShadow({ mode: "open" }); + this.shadowRoot.appendChild(template.content); + } + }, +); ``` ### 结果 diff --git a/files/zh-cn/web/css/_doublecolon_placeholder/index.md b/files/zh-cn/web/css/_doublecolon_placeholder/index.md index 69977f79671e86..61f9c8c53ee199 100644 --- a/files/zh-cn/web/css/_doublecolon_placeholder/index.md +++ b/files/zh-cn/web/css/_doublecolon_placeholder/index.md @@ -1,5 +1,5 @@ --- -title: '::placeholder' +title: "::placeholder" slug: Web/CSS/::placeholder --- @@ -27,7 +27,7 @@ slug: Web/CSS/::placeholder #### HTML ```html - + ``` #### CSS @@ -49,7 +49,7 @@ input::placeholder { #### HTML ```html - + ``` #### CSS diff --git a/files/zh-cn/web/css/_doublecolon_selection/index.md b/files/zh-cn/web/css/_doublecolon_selection/index.md index 846045d65804ef..a5671296bcef27 100644 --- a/files/zh-cn/web/css/_doublecolon_selection/index.md +++ b/files/zh-cn/web/css/_doublecolon_selection/index.md @@ -1,5 +1,5 @@ --- -title: '::selection' +title: "::selection" slug: Web/CSS/::selection --- diff --git a/files/zh-cn/web/css/_doublecolon_slotted/index.md b/files/zh-cn/web/css/_doublecolon_slotted/index.md index 505bb511a3d621..8b090e24cecd0a 100644 --- a/files/zh-cn/web/css/_doublecolon_slotted/index.md +++ b/files/zh-cn/web/css/_doublecolon_slotted/index.md @@ -1,5 +1,5 @@ --- -title: '::slotted()' +title: "::slotted()" slug: Web/CSS/::slotted --- @@ -47,26 +47,29 @@ slug: Web/CSS/::slotted 自定义元素 `` 的定义如下: ```js -customElements.define('person-details', +customElements.define( + "person-details", class extends HTMLElement { constructor() { super(); - let template = document.getElementById('person-template'); + let template = document.getElementById("person-template"); let templateContent = template.content; - const shadowRoot = this.attachShadow({mode: 'open'}); + const shadowRoot = this.attachShadow({ mode: "open" }); - let style = document.createElement('style'); - style.textContent = 'div { padding: 10px; border: 1px solid gray; width: 200px; margin: 10px; }' + - 'h2 { margin: 0 0 10px; }' + - 'ul { margin: 0; }' + - 'p { margin: 10px 0; }' + - '::slotted(*) { color: gray; font-family: sans-serif; } '; + let style = document.createElement("style"); + style.textContent = + "div { padding: 10px; border: 1px solid gray; width: 200px; margin: 10px; }" + + "h2 { margin: 0 0 10px; }" + + "ul { margin: 0; }" + + "p { margin: 10px 0; }" + + "::slotted(*) { color: gray; font-family: sans-serif; } "; shadowRoot.appendChild(style); shadowRoot.appendChild(templateContent.cloneNode(true)); - } -}) + } + }, +); ``` 为了更好地区分**未被成功填充的插槽**和**成功填充的插槽**, 我们在 CSS 中选择了所有的插槽元素 (`::slotted(*)`), 并填充了不一样的颜色和字体。结果也是如此。 diff --git a/files/zh-cn/web/css/_doublecolon_spelling-error/index.md b/files/zh-cn/web/css/_doublecolon_spelling-error/index.md index 2f34525ab08462..15667a6d7d1b87 100644 --- a/files/zh-cn/web/css/_doublecolon_spelling-error/index.md +++ b/files/zh-cn/web/css/_doublecolon_spelling-error/index.md @@ -1,5 +1,5 @@ --- -title: '::spelling-error' +title: "::spelling-error" slug: Web/CSS/::spelling-error --- diff --git a/files/zh-cn/web/css/align-content/index.md b/files/zh-cn/web/css/align-content/index.md index d03d73bd37dde3..e485720e94c092 100644 --- a/files/zh-cn/web/css/align-content/index.md +++ b/files/zh-cn/web/css/align-content/index.md @@ -16,11 +16,11 @@ slug: Web/CSS/align-content ```css /* 基本位置对齐 */ /*align-content 不采用左右值 */ -align-content: center; /* 将项目放置在中点 */ -align-content: start; /* 最先放置项目 */ -align-content: end; /* 最后放置项目 */ +align-content: center; /* 将项目放置在中点 */ +align-content: start; /* 最先放置项目 */ +align-content: end; /* 最后放置项目 */ align-content: flex-start; /* 从起始点开始放置 flex 元素 */ -align-content: flex-end; /* 从终止点开始放置 flex 元素 */ +align-content: flex-end; /* 从终止点开始放置 flex 元素 */ /* 默认对齐 */ align-content: normal; @@ -34,11 +34,11 @@ align-content: last baseline; align-content: space-between; /* 均匀分布项目 第一项与起始点齐平, 最后一项与终止点齐平 */ -align-content: space-around; /* 均匀分布项目 +align-content: space-around; /* 均匀分布项目 项目在两端有一半大小的空间*/ -align-content: space-evenly; /* 均匀分布项目 +align-content: space-evenly; /* 均匀分布项目 项目周围有相等的空间 */ -align-content: stretch; /* 均匀分布项目 +align-content: stretch; /* 均匀分布项目 拉伸‘自动’ - 大小的项目以充满容器 */ /* 溢出对齐 */ @@ -47,7 +47,7 @@ align-content: unsafe center; /* 全局属性 */ align-content: inherit; /* 继承 */ -align-content: initial; /* 初始值 */ +align-content: initial; /* 初始值 */ align-content: unset; /* 未设置 */ ``` @@ -96,7 +96,7 @@ align-content: unset; /* 未设置 */ ```css #container { - height:200px; + height: 200px; width: 240px; align-content: center; /* Can be changed in the live sample */ background-color: #8c8c8c; @@ -215,15 +215,15 @@ select { ``` ```js hidden -var values = document.getElementById('values'); -var display = document.getElementById('display'); -var container = document.getElementById('container'); +var values = document.getElementById("values"); +var display = document.getElementById("display"); +var container = document.getElementById("container"); -values.addEventListener('change', function (evt) { +values.addEventListener("change", function (evt) { container.style.alignContent = evt.target.value; }); -display.addEventListener('change', function (evt) { +display.addEventListener("change", function (evt) { container.className = evt.target.value; }); ``` diff --git a/files/zh-cn/web/css/align-items/index.md b/files/zh-cn/web/css/align-items/index.md index 1045e30bb5d62c..7d27945e378988 100644 --- a/files/zh-cn/web/css/align-items/index.md +++ b/files/zh-cn/web/css/align-items/index.md @@ -89,7 +89,7 @@ align-items: unset; ```css #container { - height:200px; + height: 200px; width: 240px; align-items: center; /* Can be changed in the live sample */ background-color: #8c8c8c; @@ -209,15 +209,15 @@ select { ``` ```js hidden -var values = document.getElementById('values'); -var display = document.getElementById('display'); -var container = document.getElementById('container'); +var values = document.getElementById("values"); +var display = document.getElementById("display"); +var container = document.getElementById("container"); -values.addEventListener('change', function (evt) { +values.addEventListener("change", function (evt) { container.style.alignItems = evt.target.value; }); -display.addEventListener('change', function (evt) { +display.addEventListener("change", function (evt) { container.className = evt.target.value; }); ``` From 881e54e12075b75078d992cae56efd1c83de0e75 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Thu, 27 Jul 2023 18:11:37 -0700 Subject: [PATCH 05/30] zh-cn: Format /web/css using Prettier (part 4) (#14662) Co-authored-by: A1lo --- files/zh-cn/web/css/overflow-wrap/index.md | 71 ++++++---- files/zh-cn/web/css/overflow-y/index.md | 34 +++-- files/zh-cn/web/css/padding-left/index.md | 8 +- files/zh-cn/web/css/padding-right/index.md | 8 +- files/zh-cn/web/css/padding-top/index.md | 8 +- files/zh-cn/web/css/padding/index.md | 24 ++-- files/zh-cn/web/css/page-break-after/index.md | 2 +- .../zh-cn/web/css/page-break-inside/index.md | 18 ++- files/zh-cn/web/css/percentage/index.md | 8 +- .../zh-cn/web/css/perspective-origin/index.md | 8 +- files/zh-cn/web/css/perspective/index.md | 18 ++- files/zh-cn/web/css/place-content/index.md | 29 ++-- files/zh-cn/web/css/place-items/index.md | 12 +- files/zh-cn/web/css/pointer-events/index.md | 21 +-- files/zh-cn/web/css/position/index.md | 61 +++++--- .../index.md | 12 +- files/zh-cn/web/css/pseudo-classes/index.md | 2 +- files/zh-cn/web/css/quotes/index.md | 37 +++-- files/zh-cn/web/css/ratio/index.md | 4 +- files/zh-cn/web/css/repeat/index.md | 20 +-- files/zh-cn/web/css/resize/index.md | 3 +- files/zh-cn/web/css/right/index.md | 6 +- files/zh-cn/web/css/scroll-behavior/index.md | 3 +- files/zh-cn/web/css/scroll-margin/index.md | 2 +- files/zh-cn/web/css/scroll-snap-type/index.md | 134 +++++++++--------- files/zh-cn/web/css/scrollbar-color/index.md | 12 +- files/zh-cn/web/css/selector_list/index.md | 11 +- .../web/css/shape-image-threshold/index.md | 22 ++- files/zh-cn/web/css/shape-margin/index.md | 17 +-- files/zh-cn/web/css/shape-outside/index.md | 7 +- .../web/css/shorthand_properties/index.md | 7 +- files/zh-cn/web/css/specificity/index.md | 70 ++++++--- files/zh-cn/web/css/system-color/index.md | 4 +- files/zh-cn/web/css/text-align-last/index.md | 6 +- .../web/css/text-decoration-color/index.md | 6 +- .../web/css/text-decoration-line/index.md | 4 +- .../web/css/text-decoration-style/index.md | 12 +- files/zh-cn/web/css/text-decoration/index.md | 5 +- files/zh-cn/web/css/text-indent/index.md | 6 +- files/zh-cn/web/css/text-justify/index.md | 35 ++++- files/zh-cn/web/css/text-overflow/index.md | 40 ++++-- files/zh-cn/web/css/text-rendering/index.md | 9 +- files/zh-cn/web/css/text-shadow/index.md | 26 ++-- files/zh-cn/web/css/text-transform/index.md | 8 +- files/zh-cn/web/css/touch-action/index.md | 2 +- .../zh-cn/web/css/transform-function/index.md | 14 +- .../css/transform-function/matrix3d/index.md | 31 +--- .../css/transform-function/translate/index.md | 4 +- .../transform-function/translate3d/index.md | 4 +- files/zh-cn/web/css/transform/index.md | 6 +- .../web/css/transition-property/index.md | 5 +- files/zh-cn/web/css/transition/index.md | 4 +- files/zh-cn/web/css/unicode-bidi/index.md | 8 +- .../web/css/universal_selectors/index.md | 12 +- files/zh-cn/web/css/url/index.md | 8 +- files/zh-cn/web/css/user-select/index.md | 2 + .../css/using_css_custom_properties/index.md | 25 +++- files/zh-cn/web/css/var/index.md | 5 +- files/zh-cn/web/css/vertical-align/index.md | 35 ++++- .../zh-cn/web/css/viewport_concepts/index.md | 36 ++--- files/zh-cn/web/css/visibility/index.md | 5 +- files/zh-cn/web/css/white-space/index.md | 4 +- files/zh-cn/web/css/widows/index.md | 10 +- files/zh-cn/web/css/width/index.md | 6 +- files/zh-cn/web/css/will-change/index.md | 6 +- files/zh-cn/web/css/word-break/index.md | 32 +++-- files/zh-cn/web/css/word-spacing/index.md | 2 +- files/zh-cn/web/css/z-index/index.md | 2 +- 68 files changed, 677 insertions(+), 451 deletions(-) diff --git a/files/zh-cn/web/css/overflow-wrap/index.md b/files/zh-cn/web/css/overflow-wrap/index.md index 0c7ec9bee9fbfc..92dbe23fe23477 100644 --- a/files/zh-cn/web/css/overflow-wrap/index.md +++ b/files/zh-cn/web/css/overflow-wrap/index.md @@ -53,52 +53,67 @@ overflow-wrap: unset; #### HTML ```html -

They say the fishing is excellent at - Lake Chargoggagoggmanchauggagoggchaubunagungamaugg, - though I've never been there myself. (normal)

-

They say the fishing is excellent at - Lake Chargoggagoggmanchauggagoggchaubunagungamaugg, - though I've never been there myself. (overflow-wrap: anywhere)

-

They say the fishing is excellent at - Lake Chargoggagoggmanchauggagoggchaubunagungamaugg, - though I've never been there myself. (overflow-wrap: break-word)

-

They say the fishing is excellent at - Lake Chargoggagoggmanchauggagoggchaubunagungamaugg, - though I've never been there myself. (word-break)

-

They say the fishing is excellent at - Lake Chargoggagoggmanchauggagoggchaubunagungamaugg, - though I've never been there myself. (hyphens, without lang attribute)

-

They say the fishing is excellent at - Lake Chargoggagoggmanchauggagoggchaubunagungamaugg, - though I've never been there myself. (hyphens, English rules)

-

They say the fishing is excellent at - Lake Chargoggagoggmanchauggagoggchaubunagungamaugg, - though I've never been there myself. (hyphens, German rules)

+

+ They say the fishing is excellent at Lake + Chargoggagoggmanchauggagoggchaubunagungamaugg, though + I've never been there myself. (normal) +

+

+ They say the fishing is excellent at Lake + Chargoggagoggmanchauggagoggchaubunagungamaugg, + though I've never been there myself. (overflow-wrap: anywhere) +

+

+ They say the fishing is excellent at Lake + Chargoggagoggmanchauggagoggchaubunagungamaugg, + though I've never been there myself. (overflow-wrap: break-word) +

+

+ They say the fishing is excellent at Lake + Chargoggagoggmanchauggagoggchaubunagungamaugg, + though I've never been there myself. (word-break) +

+

+ They say the fishing is excellent at Lake + Chargoggagoggmanchauggagoggchaubunagungamaugg, though + I've never been there myself. (hyphens, without + lang attribute) +

+

+ They say the fishing is excellent at Lake + Chargoggagoggmanchauggagoggchaubunagungamaugg, though + I've never been there myself. (hyphens, English rules) +

+

+ They say the fishing is excellent at Lake + Chargoggagoggmanchauggagoggchaubunagungamaugg, though + I've never been there myself. (hyphens, German rules) +

``` #### CSS ```css p { - width: 13em; - margin: 2px; - background: gold; + width: 13em; + margin: 2px; + background: gold; } .ow-anywhere { - overflow-wrap: anywhere; + overflow-wrap: anywhere; } .ow-break-word { - overflow-wrap: break-word; + overflow-wrap: break-word; } .word-break { - word-break: break-all; + word-break: break-all; } .hyphens { - hyphens: auto; + hyphens: auto; } ``` diff --git a/files/zh-cn/web/css/overflow-y/index.md b/files/zh-cn/web/css/overflow-y/index.md index 24fb095cad88c4..19d742409689c5 100644 --- a/files/zh-cn/web/css/overflow-y/index.md +++ b/files/zh-cn/web/css/overflow-y/index.md @@ -60,30 +60,34 @@ overflow-y: unset; ```html
    -
  • overflow-y:hidden — 在盒子外隐藏溢出的内容 -
    - 歌词是诗歌的一种,入乐的叫歌,不入乐的叫诗(或词)。入乐的歌在感情抒发、形象塑造上和诗没有任何区别,但在结构上、节奏上要受音乐的制约,在韵律上要照顾演唱的方便,在遣词炼字上要考虑听觉艺术的特点,因为它要入乐歌唱。歌词与诗的分别,主要是诗不一定要入乐(合乐),歌词是要合乐的。合乐成为歌曲。歌词一般是配合曲子旋律一同出现的,歌词是歌曲的本意所在。现代一般是配合音乐,便于哼唱的语句。 -
    +
  • + overflow-y:hidden — 在盒子外隐藏溢出的内容 +
    + 歌词是诗歌的一种,入乐的叫歌,不入乐的叫诗(或词)。入乐的歌在感情抒发、形象塑造上和诗没有任何区别,但在结构上、节奏上要受音乐的制约,在韵律上要照顾演唱的方便,在遣词炼字上要考虑听觉艺术的特点,因为它要入乐歌唱。歌词与诗的分别,主要是诗不一定要入乐(合乐),歌词是要合乐的。合乐成为歌曲。歌词一般是配合曲子旋律一同出现的,歌词是歌曲的本意所在。现代一般是配合音乐,便于哼唱的语句。 +
  • -
  • overflow-y:scroll — 总是显示滚动条 -
    - 歌词是诗歌的一种,入乐的叫歌,不入乐的叫诗(或词)。入乐的歌在感情抒发、形象塑造上和诗没有任何区别,但在结构上、节奏上要受音乐的制约,在韵律上要照顾演唱的方便,在遣词炼字上要考虑听觉艺术的特点,因为它要入乐歌唱。歌词与诗的分别,主要是诗不一定要入乐(合乐),歌词是要合乐的。合乐成为歌曲。歌词一般是配合曲子旋律一同出现的,歌词是歌曲的本意所在。现代一般是配合音乐,便于哼唱的语句。 -
    +
  • + overflow-y:scroll — 总是显示滚动条 +
    + 歌词是诗歌的一种,入乐的叫歌,不入乐的叫诗(或词)。入乐的歌在感情抒发、形象塑造上和诗没有任何区别,但在结构上、节奏上要受音乐的制约,在韵律上要照顾演唱的方便,在遣词炼字上要考虑听觉艺术的特点,因为它要入乐歌唱。歌词与诗的分别,主要是诗不一定要入乐(合乐),歌词是要合乐的。合乐成为歌曲。歌词一般是配合曲子旋律一同出现的,歌词是歌曲的本意所在。现代一般是配合音乐,便于哼唱的语句。 +
  • -
  • overflow-y:visible — 在盒子外显示溢出的内容 -
    - 歌词是诗歌的一种,入乐的叫歌,不入乐的叫诗(或词)。入乐的歌在感情抒发、形象塑造上和诗没有任何区别,但在结构上、节奏上要受音乐的制约,在韵律上要照顾演唱的方便,在遣词炼字上要考虑听觉艺术的特点,因为它要入乐歌唱。歌词与诗的分别,主要是诗不一定要入乐(合乐),歌词是要合乐的。合乐成为歌曲。歌词一般是配合曲子旋律一同出现的,歌词是歌曲的本意所在。现代一般是配合音乐,便于哼唱的语句。 +
  • + overflow-y:visible — 在盒子外显示溢出的内容 +
    + 歌词是诗歌的一种,入乐的叫歌,不入乐的叫诗(或词)。入乐的歌在感情抒发、形象塑造上和诗没有任何区别,但在结构上、节奏上要受音乐的制约,在韵律上要照顾演唱的方便,在遣词炼字上要考虑听觉艺术的特点,因为它要入乐歌唱。歌词与诗的分别,主要是诗不一定要入乐(合乐),歌词是要合乐的。合乐成为歌曲。歌词一般是配合曲子旋律一同出现的,歌词是歌曲的本意所在。现代一般是配合音乐,便于哼唱的语句。
  • -
  • overflow-y:auto — 在大多数浏览器中,auto 效果等于 scroll -
    - 歌词是诗歌的一种,入乐的叫歌,不入乐的叫诗(或词)。入乐的歌在感情抒发、形象塑造上和诗没有任何区别,但在结构上、节奏上要受音乐的制约,在韵律上要照顾演唱的方便,在遣词炼字上要考虑听觉艺术的特点,因为它要入乐歌唱。歌词与诗的分别,主要是诗不一定要入乐(合乐),歌词是要合乐的。合乐成为歌曲。歌词一般是配合曲子旋律一同出现的,歌词是歌曲的本意所在。现代一般是配合音乐,便于哼唱的语句。 +
  • + overflow-y:auto — 在大多数浏览器中,auto 效果等于 + scroll +
    + 歌词是诗歌的一种,入乐的叫歌,不入乐的叫诗(或词)。入乐的歌在感情抒发、形象塑造上和诗没有任何区别,但在结构上、节奏上要受音乐的制约,在韵律上要照顾演唱的方便,在遣词炼字上要考虑听觉艺术的特点,因为它要入乐歌唱。歌词与诗的分别,主要是诗不一定要入乐(合乐),歌词是要合乐的。合乐成为歌曲。歌词一般是配合曲子旋律一同出现的,歌词是歌曲的本意所在。现代一般是配合音乐,便于哼唱的语句。
  • -
``` diff --git a/files/zh-cn/web/css/padding-left/index.md b/files/zh-cn/web/css/padding-left/index.md index 513a76fa91f18f..f3d66f1ff9ef0a 100644 --- a/files/zh-cn/web/css/padding-left/index.md +++ b/files/zh-cn/web/css/padding-left/index.md @@ -52,8 +52,12 @@ padding-left: unset; ### 使用“px”单位和百分比设置 padding-left 的样例 ```css -.content { padding-left: 5%; } -.sidebox { padding-left: 10px; } +.content { + padding-left: 5%; +} +.sidebox { + padding-left: 10px; +} ``` ## 规范 diff --git a/files/zh-cn/web/css/padding-right/index.md b/files/zh-cn/web/css/padding-right/index.md index 24195c7bf412d4..6d756a1c1beb93 100644 --- a/files/zh-cn/web/css/padding-right/index.md +++ b/files/zh-cn/web/css/padding-right/index.md @@ -40,8 +40,12 @@ padding-right: unset; ## Examples ```css -.content { padding-right: 5%; } -.sidebox { padding-right: 10px; } +.content { + padding-right: 5%; +} +.sidebox { + padding-right: 10px; +} ``` ## Specifications diff --git a/files/zh-cn/web/css/padding-top/index.md b/files/zh-cn/web/css/padding-top/index.md index 86f9c29059ca82..a88314e448a967 100644 --- a/files/zh-cn/web/css/padding-top/index.md +++ b/files/zh-cn/web/css/padding-top/index.md @@ -42,8 +42,12 @@ padding-top: unset; ## 实例 ```css -.content { padding-top: 5%; } -.sidebox { padding-top: 10px; } +.content { + padding-top: 5%; +} +.sidebox { + padding-top: 10px; +} ``` ## 规范 diff --git a/files/zh-cn/web/css/padding/index.md b/files/zh-cn/web/css/padding/index.md index f03531c4f95f2a..060183b092666f 100644 --- a/files/zh-cn/web/css/padding/index.md +++ b/files/zh-cn/web/css/padding/index.md @@ -73,7 +73,7 @@ padding: unset; ```html

此元素有合适的内边距。

-

此元素的内边距很 大!

+

此元素的内边距很大!

``` #### CSS @@ -97,21 +97,21 @@ h3 { ### 以像素和百分数为单位设置内边距 ```css -padding: 5%; /* 所有边:5% 的内边距 */ +padding: 5%; /* 所有边:5% 的内边距 */ -padding: 10px; /* 所有边:10px 的内边距 */ +padding: 10px; /* 所有边:10px 的内边距 */ -padding: 10px 20px; /* 上边和下边:10px 的内边距 */ - /* 左边和右边:20px 的内边距 */ +padding: 10px 20px; /* 上边和下边:10px 的内边距 */ +/* 左边和右边:20px 的内边距 */ -padding: 10px 3% 20px; /* 上边:10px 的内边距 */ - /* 左边和右边:3% 的内边距 */ - /* 下边:20px 的内边距 */ +padding: 10px 3% 20px; /* 上边:10px 的内边距 */ +/* 左边和右边:3% 的内边距 */ +/* 下边:20px 的内边距 */ -padding: 1em 3px 30px 5px; /* 上边:1em 的内边距*/ - /* 右边:3px 的内边距*/ - /* 下边:30px 的内边距*/ - /* 左边:5px 的内边距*/ +padding: 1em 3px 30px 5px; /* 上边:1em 的内边距*/ +/* 右边:3px 的内边距*/ +/* 下边:30px 的内边距*/ +/* 左边:5px 的内边距*/ ``` ## 规范 diff --git a/files/zh-cn/web/css/page-break-after/index.md b/files/zh-cn/web/css/page-break-after/index.md index ed6ced02dcd2b6..5f76784f36fe2c 100644 --- a/files/zh-cn/web/css/page-break-after/index.md +++ b/files/zh-cn/web/css/page-break-after/index.md @@ -73,7 +73,7 @@ page-break-after: unset; ```css /* move to a new page after footnotes */ div.footnotes { - page-break-after:always; + page-break-after: always; } ``` diff --git a/files/zh-cn/web/css/page-break-inside/index.md b/files/zh-cn/web/css/page-break-inside/index.md index df5ff21bf44e4e..bdc4458d66957e 100644 --- a/files/zh-cn/web/css/page-break-inside/index.md +++ b/files/zh-cn/web/css/page-break-inside/index.md @@ -44,16 +44,19 @@ page-break-inside: unset; A list
  1. one
  2. - +
  • one
  • - +

This is the second paragraph.

This is the third paragraph, it contains more text.

-

This is the fourth paragraph. It has a little bit more text than the third one.

+

+ This is the fourth paragraph. It has a little bit more text than the third + one. +

``` @@ -68,7 +71,10 @@ page-break-inside: unset; column-width: 100px; } -.list, ol, ul, p { +.list, +ol, +ul, +p { break-inside: avoid; } @@ -76,7 +82,9 @@ p { background-color: #8ca0ff; } -ol, ul, .list { +ol, +ul, +.list { margin: 0.5em 0; display: block; background-color: orange; diff --git a/files/zh-cn/web/css/percentage/index.md b/files/zh-cn/web/css/percentage/index.md index ebf428b416e6e8..46218ca4ad8e02 100644 --- a/files/zh-cn/web/css/percentage/index.md +++ b/files/zh-cn/web/css/percentage/index.md @@ -25,8 +25,12 @@ slug: Web/CSS/percentage ```html
-
Width: 50%, Left margin: 20%
-
Width: 30%, Left margin: 60%
+
+ Width: 50%, Left margin: 20% +
+
+ Width: 30%, Left margin: 60% +
``` diff --git a/files/zh-cn/web/css/perspective-origin/index.md b/files/zh-cn/web/css/perspective-origin/index.md index 23f13e6c5c918f..71462978d88850 100644 --- a/files/zh-cn/web/css/perspective-origin/index.md +++ b/files/zh-cn/web/css/perspective-origin/index.md @@ -328,7 +328,7 @@ perspective-origin: unset; .top { background: rgba(196, 196, 0, 0.7); transform: rotateX(90deg) translateZ(50px); - -webkit-transform: rotateX(90deg) translateZ(50px) + -webkit-transform: rotateX(90deg) translateZ(50px); } .bottom { @@ -338,8 +338,10 @@ perspective-origin: unset; } /* Make the table a little nicer */ -th, p, td { - background-color: #EEEEEE; +th, +p, +td { + background-color: #eeeeee; padding: 10px; font-family: sans-serif; text-align: left; diff --git a/files/zh-cn/web/css/perspective/index.md b/files/zh-cn/web/css/perspective/index.md index 266d85db4ad617..24adfd6a50f416 100644 --- a/files/zh-cn/web/css/perspective/index.md +++ b/files/zh-cn/web/css/perspective/index.md @@ -60,10 +60,8 @@ perspective: unset; - - + + - - + +
perspective: 250px; - perspective: 350px; - perspective: 250px;perspective: 350px;
@@ -92,10 +90,8 @@ perspective: unset;
perspective: 500px; - perspective: 650px; - perspective: 500px;perspective: 650px;
@@ -211,8 +207,10 @@ CSS 建立了不同透视距离的 class,还包括容器盒、立方体本身 } /* Make the table a little nicer */ -th, p, td { - background-color: #EEEEEE; +th, +p, +td { + background-color: #eeeeee; padding: 10px; font-family: sans-serif; text-align: left; diff --git a/files/zh-cn/web/css/place-content/index.md b/files/zh-cn/web/css/place-content/index.md index 8a4db1c93f7d3d..ba1e89d85c8307 100644 --- a/files/zh-cn/web/css/place-content/index.md +++ b/files/zh-cn/web/css/place-content/index.md @@ -93,20 +93,23 @@ place-content: unset; ``` ```html hidden -writing-mode: - -;
+ ;
-direction: ;
-place-content: @@ -137,29 +140,33 @@ place-content: unset; - ; + ; ``` ```js hidden function update() { - document.getElementById("container").style.placeContent = `${document.getElementById("alignContentAlignment").value} ` - + `${document.getElementById("justifyContentAlignment").value}`; + document.getElementById("container").style.placeContent = + `${document.getElementById("alignContentAlignment").value} ` + + `${document.getElementById("justifyContentAlignment").value}`; } const alignContentAlignment = document.getElementById("alignContentAlignment"); alignContentAlignment.addEventListener("change", update); -const justifyContentAlignment = document.getElementById("justifyContentAlignment"); +const justifyContentAlignment = document.getElementById( + "justifyContentAlignment", +); justifyContentAlignment.addEventListener("change", update); const writingM = document.getElementById("writingMode"); writingM.addEventListener("change", (evt) => { - document.getElementById("container").style.writingMode = evt.target.value; + document.getElementById("container").style.writingMode = evt.target.value; }); const direction = document.getElementById("direction"); direction.addEventListener("change", (evt) => { - document.getElementById("container").style.direction = evt.target.value; + document.getElementById("container").style.direction = evt.target.value; }); ``` diff --git a/files/zh-cn/web/css/place-items/index.md b/files/zh-cn/web/css/place-items/index.md index 4b7731e8830534..a0e4960b8a658d 100644 --- a/files/zh-cn/web/css/place-items/index.md +++ b/files/zh-cn/web/css/place-items/index.md @@ -195,15 +195,15 @@ select { ``` ```js hidden -var values = document.getElementById('values'); -var display = document.getElementById('display'); -var container = document.getElementById('container'); +var values = document.getElementById("values"); +var display = document.getElementById("display"); +var container = document.getElementById("container"); -values.addEventListener('change', function (evt) { +values.addEventListener("change", function (evt) { container.style.placeItems = evt.target.value; }); -display.addEventListener('change', function (evt) { +display.addEventListener("change", function (evt) { container.className = evt.target.value; }); ``` @@ -212,7 +212,7 @@ display.addEventListener('change', function (evt) { ```css #container { - height:200px; + height: 200px; width: 240px; place-items: center; /* You can change this value by selecting another option in the list */ background-color: #8c8c8c; diff --git a/files/zh-cn/web/css/pointer-events/index.md b/files/zh-cn/web/css/pointer-events/index.md index 5a69d706b3be21..51f3dc248364f5 100644 --- a/files/zh-cn/web/css/pointer-events/index.md +++ b/files/zh-cn/web/css/pointer-events/index.md @@ -12,13 +12,13 @@ slug: Web/CSS/pointer-events pointer-events: auto; pointer-events: none; pointer-events: visiblePainted; /* SVG only */ -pointer-events: visibleFill; /* SVG only */ -pointer-events: visibleStroke; /* SVG only */ -pointer-events: visible; /* SVG only */ -pointer-events: painted; /* SVG only */ -pointer-events: fill; /* SVG only */ -pointer-events: stroke; /* SVG only */ -pointer-events: all; /* SVG only */ +pointer-events: visibleFill; /* SVG only */ +pointer-events: visibleStroke; /* SVG only */ +pointer-events: visible; /* SVG only */ +pointer-events: painted; /* SVG only */ +pointer-events: fill; /* SVG only */ +pointer-events: stroke; /* SVG only */ +pointer-events: all; /* SVG only */ /* Global values */ pointer-events: inherit; @@ -88,13 +88,14 @@ img { ```html ``` ```css -a[href="http://example.com"] { +a[href="http://example.com"] +{ pointer-events: none; } ``` diff --git a/files/zh-cn/web/css/position/index.md b/files/zh-cn/web/css/position/index.md index 142356933347c8..88a5612d49ff57 100644 --- a/files/zh-cn/web/css/position/index.md +++ b/files/zh-cn/web/css/position/index.md @@ -161,22 +161,30 @@ span { ```html

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam congue tortor eget pulvinar lobortis. - Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nam ac dolor augue. - Pellentesque mi mi, laoreet et dolor sit amet, ultrices varius risus. Nam vitae iaculis elit. - Aliquam mollis interdum libero. Sed sodales placerat egestas. Vestibulum ut arcu aliquam purus viverra dictum vel sit amet mi. - Duis nisl mauris, aliquam sit amet luctus eget, dapibus in enim. Sed velit augue, pretium a sem aliquam, congue porttitor tortor. - Sed tempor nisl a lorem consequat, id maximus erat aliquet. Sed sagittis porta libero sed condimentum. - Aliquam finibus lectus nec ante congue rutrum. Curabitur quam quam, accumsan id ultrices ultrices, tempor et tellus. + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam congue tortor + eget pulvinar lobortis. Vestibulum ante ipsum primis in faucibus orci luctus + et ultrices posuere cubilia Curae; Nam ac dolor augue. Pellentesque mi mi, + laoreet et dolor sit amet, ultrices varius risus. Nam vitae iaculis elit. + Aliquam mollis interdum libero. Sed sodales placerat egestas. Vestibulum ut + arcu aliquam purus viverra dictum vel sit amet mi. Duis nisl mauris, aliquam + sit amet luctus eget, dapibus in enim. Sed velit augue, pretium a sem + aliquam, congue porttitor tortor. Sed tempor nisl a lorem consequat, id + maximus erat aliquet. Sed sagittis porta libero sed condimentum. Aliquam + finibus lectus nec ante congue rutrum. Curabitur quam quam, accumsan id + ultrices ultrices, tempor et tellus.

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam congue tortor eget pulvinar lobortis. - Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nam ac dolor augue. - Pellentesque mi mi, laoreet et dolor sit amet, ultrices varius risus. Nam vitae iaculis elit. - Aliquam mollis interdum libero. Sed sodales placerat egestas. Vestibulum ut arcu aliquam purus viverra dictum vel sit amet mi. - Duis nisl mauris, aliquam sit amet luctus eget, dapibus in enim. Sed velit augue, pretium a sem aliquam, congue porttitor tortor. - Sed tempor nisl a lorem consequat, id maximus erat aliquet. Sed sagittis porta libero sed condimentum. - Aliquam finibus lectus nec ante congue rutrum. Curabitur quam quam, accumsan id ultrices ultrices, tempor et tellus. + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam congue tortor + eget pulvinar lobortis. Vestibulum ante ipsum primis in faucibus orci luctus + et ultrices posuere cubilia Curae; Nam ac dolor augue. Pellentesque mi mi, + laoreet et dolor sit amet, ultrices varius risus. Nam vitae iaculis elit. + Aliquam mollis interdum libero. Sed sodales placerat egestas. Vestibulum ut + arcu aliquam purus viverra dictum vel sit amet mi. Duis nisl mauris, aliquam + sit amet luctus eget, dapibus in enim. Sed velit augue, pretium a sem + aliquam, congue porttitor tortor. Sed tempor nisl a lorem consequat, id + maximus erat aliquet. Sed sagittis porta libero sed condimentum. Aliquam + finibus lectus nec ante congue rutrum. Curabitur quam quam, accumsan id + ultrices ultrices, tempor et tellus.

One
@@ -214,7 +222,10 @@ span { 粘性定位可以被认为是相对定位和固定定位的混合。元素在跨越特定阈值前为相对定位,之后为固定定位。例如: ```css -#one { position: sticky; top: 10px; } +#one { + position: sticky; + top: 10px; +} ``` 在 viewport 视口滚动到元素 top 距离小于 10px 之前,元素为相对定位。之后,元素将固定在与顶部距离 10px 的位置,直到 viewport 视口回滚到阈值以下。 @@ -271,11 +282,14 @@ dl { } dt { - background: #B8C1C8; - border-bottom: 1px solid #989EA4; - border-top: 1px solid #717D85; - color: #FFF; - font: bold 18px/21px Helvetica, Arial, sans-serif; + background: #b8c1c8; + border-bottom: 1px solid #989ea4; + border-top: 1px solid #717d85; + color: #fff; + font: + bold 18px/21px Helvetica, + Arial, + sans-serif; margin: 0; padding: 2px 0 0 12px; position: -webkit-sticky; @@ -284,14 +298,17 @@ dt { } dd { - font: bold 20px/45px Helvetica, Arial, sans-serif; + font: + bold 20px/45px Helvetica, + Arial, + sans-serif; margin: 0; padding: 0 0 0 12px; white-space: nowrap; } dd + dd { - border-top: 1px solid #CCC + border-top: 1px solid #ccc; } ``` diff --git a/files/zh-cn/web/css/privacy_and_the__colon_visited_selector/index.md b/files/zh-cn/web/css/privacy_and_the__colon_visited_selector/index.md index c417c4f810f8fb..aacea58e1c7155 100644 --- a/files/zh-cn/web/css/privacy_and_the__colon_visited_selector/index.md +++ b/files/zh-cn/web/css/privacy_and_the__colon_visited_selector/index.md @@ -33,16 +33,16 @@ slug: Web/CSS/Privacy_and_the_:visited_selector ```css :link { - outline: 1px dotted blue; - background-color: white; - /* background-color 的默认值为 'transparent'。 + outline: 1px dotted blue; + background-color: white; + /* background-color 的默认值为 'transparent'。 你必须指定一个不同值,否则无法应用对 :visited 的修改 */ } :visited { - outline-color: orange; /* 已访问链接的轮廓为橘色 */ - color: yellow; /* 已访问链接的文本为黄色 */ - background-color: green; /* 已访问链接的背景为绿色 */ + outline-color: orange; /* 已访问链接的轮廓为橘色 */ + color: yellow; /* 已访问链接的文本为黄色 */ + background-color: green; /* 已访问链接的背景为绿色 */ } ``` diff --git a/files/zh-cn/web/css/pseudo-classes/index.md b/files/zh-cn/web/css/pseudo-classes/index.md index d868005636bdba..b1db4981ad85f2 100644 --- a/files/zh-cn/web/css/pseudo-classes/index.md +++ b/files/zh-cn/web/css/pseudo-classes/index.md @@ -5,7 +5,7 @@ slug: Web/CSS/Pseudo-classes {{CSSRef}} -[CSS](/zh-CN/docs/Web/CSS) ***伪类***是添加到选择器的关键字,用于指定所选元素的特殊状态。例如,伪类 {{CSSxRef(":hover")}} 可以用于选择一个按钮,当用户的指针悬停在按钮上时,设置此按钮的样式。 +[CSS](/zh-CN/docs/Web/CSS) **_伪类_**是添加到选择器的关键字,用于指定所选元素的特殊状态。例如,伪类 {{CSSxRef(":hover")}} 可以用于选择一个按钮,当用户的指针悬停在按钮上时,设置此按钮的样式。 ```css /* 用户的指针悬停在其上的任何按钮 */ diff --git a/files/zh-cn/web/css/quotes/index.md b/files/zh-cn/web/css/quotes/index.md index bfd1a64d67799c..2c28a63668c331 100644 --- a/files/zh-cn/web/css/quotes/index.md +++ b/files/zh-cn/web/css/quotes/index.md @@ -14,8 +14,8 @@ slug: Web/CSS/quotes quotes: none; /* values */ -quotes: "«" "»"; /* Set open-quote and close-quote to the French quotation marks */ -quotes: "«" "»" "‹" "›"; /* Set two levels of quotation marks */ +quotes: "«" "»"; /* Set open-quote and close-quote to the French quotation marks */ +quotes: "«" "»" "‹" "›"; /* Set two levels of quotation marks */ /* Global values */ quotes: inherit; @@ -71,19 +71,26 @@ q:after { ```html
Ceci est une citation française. -
-
-
- Это русская цитата -
-
-
- Dies ist ein deutsches Zitat -
-
-
- This is an English quote. -
+
+
+
+ Это русская цитата +
+
+
+ Dies ist ein deutsches Zitat +
+
+
+ This is an English quote. +
+
+
+
+
+
+
+
``` #### CSS diff --git a/files/zh-cn/web/css/ratio/index.md b/files/zh-cn/web/css/ratio/index.md index af44ee27e79ab8..39be5bb4b1cd31 100644 --- a/files/zh-cn/web/css/ratio/index.md +++ b/files/zh-cn/web/css/ratio/index.md @@ -25,8 +25,8 @@ slug: Web/CSS/ratio ( ( -| | 比 | 用法 | -| ---------------------------------------------------------- | --------------------------------------------- | ---------------------------------------- | +| | 比 | 用法 | +| ----------------------------------- | --------------------------------------------- | ---------------------------------------- | | ![Ratio4_3.png](ratio4_3.png) | `4/3` | 在 20 传统电视制式格式。 | | ![Ratio16_9.png](ratio16_9.png) | `16/9` | 现代"宽屏”电视格式。 | | ![Ratio1_1.85.png](ratio1_1.85.png) | `185/100`= `91/50` _(不允许非整数除数和除数)_ | 自 20 世纪 60 年代以来最常见的电影格式。 | diff --git a/files/zh-cn/web/css/repeat/index.md b/files/zh-cn/web/css/repeat/index.md index 5068f85d992b23..82a3b51cd26b54 100644 --- a/files/zh-cn/web/css/repeat/index.md +++ b/files/zh-cn/web/css/repeat/index.md @@ -93,21 +93,11 @@ repeat(4, 10px [col-start] 30% [col-middle] 400px [col-end]) ```html
-
- This item is 50 pixels wide. -
-
- Item with flexible width. -
-
- This item is 50 pixels wide. -
-
- Item with flexible width. -
-
- Inflexible item of 100 pixels width. -
+
This item is 50 pixels wide.
+
Item with flexible width.
+
This item is 50 pixels wide.
+
Item with flexible width.
+
Inflexible item of 100 pixels width.
``` diff --git a/files/zh-cn/web/css/resize/index.md b/files/zh-cn/web/css/resize/index.md index 16cee6910d3f76..0b2eb5fe23710b 100644 --- a/files/zh-cn/web/css/resize/index.md +++ b/files/zh-cn/web/css/resize/index.md @@ -91,7 +91,8 @@ textarea { ```html

- 此段落可在各个方向上调整尺寸,这是因为在此元素上 CSS `resize` 属性设置为 `both`。 + 此段落可在各个方向上调整尺寸,这是因为在此元素上 CSS `resize` 属性设置为 + `both`。

``` diff --git a/files/zh-cn/web/css/right/index.md b/files/zh-cn/web/css/right/index.md index 88a4e120591882..b5a537bb35b7d4 100644 --- a/files/zh-cn/web/css/right/index.md +++ b/files/zh-cn/web/css/right/index.md @@ -40,6 +40,7 @@ right: unset; ### 取值 - {{cssxref("<length>")}} + - : 可以是负的,正的 或者 null {{cssxref("<length>")}} 表示: - 对于**绝对定位的元素**,元素右外边距边界与其包含块右边界之间的偏移。 @@ -48,6 +49,7 @@ right: unset; - {{cssxref("<percentage>")}} - : 代表元素包含块的宽度的百分比 {{cssxref("<percentage>")}}。 - `auto` + - : 这个关键字表示: - 对于绝对定位元素,元素将忽略此属性而以 {{ Cssxref("left") }} 属性为准,如果此时设置 `width: auto`,将基于内容需要的宽度设置宽度;如果 `left` 也为 `auto` 的话,元素的水平位置就是它假如作为静态(即 static)元素时该在的位置。 @@ -66,7 +68,7 @@ right: unset; #example_3 { width: 100px; height: 100px; - background-color: #FFC7E4; + background-color: #ffc7e4; position: relative; top: 20px; left: 20px; @@ -75,7 +77,7 @@ right: unset; #example_4 { width: 100px; height: 100px; - background-color: #FFD7C2; + background-color: #ffd7c2; position: absolute; bottom: 10px; right: 20px; diff --git a/files/zh-cn/web/css/scroll-behavior/index.md b/files/zh-cn/web/css/scroll-behavior/index.md index 597235dfbad060..204725fd4e6718 100644 --- a/files/zh-cn/web/css/scroll-behavior/index.md +++ b/files/zh-cn/web/css/scroll-behavior/index.md @@ -62,7 +62,8 @@ a { width: 50px; text-decoration: none; } -nav, scroll-container { +nav, +scroll-container { display: block; margin: 0 auto; text-align: center; diff --git a/files/zh-cn/web/css/scroll-margin/index.md b/files/zh-cn/web/css/scroll-margin/index.md index f24656395904aa..1ad7b11aa11863 100644 --- a/files/zh-cn/web/css/scroll-margin/index.md +++ b/files/zh-cn/web/css/scroll-margin/index.md @@ -18,7 +18,7 @@ slug: Web/CSS/scroll-margin ```css /* values */ scroll-margin: 10px; -scroll-margin: 1em .5em 1em 1em; +scroll-margin: 1em 0.5em 1em 1em; /* Global values */ scroll-margin: inherit; diff --git a/files/zh-cn/web/css/scroll-snap-type/index.md b/files/zh-cn/web/css/scroll-snap-type/index.md index a5ccfb9fe382ea..99d3748f019767 100644 --- a/files/zh-cn/web/css/scroll-snap-type/index.md +++ b/files/zh-cn/web/css/scroll-snap-type/index.md @@ -68,69 +68,69 @@ scroll-snap-type: unset; ```html
-
-
X Mand. LTR
-
2
-
3
-
4
-
5
-
- -
-
X Prox. LTR
-
2
-
3
-
4
-
5
-
- -
-
Y Mand. LTR
-
2
-
3
-
4
-
5
-
- -
-
Y Prox. LTR
-
2
-
3
-
4
-
5
-
- -
-
X Mand. RTL
-
2
-
3
-
4
-
5
-
- -
-
X Prox. RTL
-
2
-
3
-
4
-
5
-
- -
-
Y Mand. RTL
-
2
-
3
-
4
-
5
-
- -
-
Y Prox. RTL
-
2
-
3
-
4
-
5
-
+
+
X Mand. LTR
+
2
+
3
+
4
+
5
+
+ +
+
X Prox. LTR
+
2
+
3
+
4
+
5
+
+ +
+
Y Mand. LTR
+
2
+
3
+
4
+
5
+
+ +
+
Y Prox. LTR
+
2
+
3
+
4
+
5
+
+ +
+
X Mand. RTL
+
2
+
3
+
4
+
5
+
+ +
+
X Prox. RTL
+
2
+
3
+
4
+
5
+
+ +
+
Y Mand. RTL
+
2
+
3
+
4
+
5
+
+ +
+
Y Prox. RTL
+
2
+
3
+
4
+
5
+
``` @@ -138,7 +138,9 @@ scroll-snap-type: unset; ```css /* setup */ -html, body, .holster { +html, +body, +.holster { height: 100%; } .holster { @@ -210,11 +212,11 @@ html, body, .holster { } /* coloration */ .container > div:nth-child(even) { - background-color: #87EA87; + background-color: #87ea87; } .container > div:nth-child(odd) { - background-color: #87CCEA; + background-color: #87ccea; } ``` diff --git a/files/zh-cn/web/css/scrollbar-color/index.md b/files/zh-cn/web/css/scrollbar-color/index.md index 5f38ec9debf499..1fd042f4b908b9 100644 --- a/files/zh-cn/web/css/scrollbar-color/index.md +++ b/files/zh-cn/web/css/scrollbar-color/index.md @@ -22,7 +22,7 @@ scrollbar-color: dark; scrollbar-color: light; /* values */ -scrollbar-color: rebeccapurple green; /* Two valid colors. +scrollbar-color: rebeccapurple green; /* Two valid colors. The first applies to the thumb of the scrollbar, the second to the track. */ /* Global values */ @@ -37,7 +37,7 @@ scrollbar-color: unset; - : 定义滚动条的颜色。 - | 值 | 描述 | + | 值 | 描述 | | ----------------- | -------------------------------------------------------------------------------------- | | `auto` | 在没有任何其他相关滚动条颜色属性的情况下,滚动条的轨道部分默认平台渲染。 | | `dark` | 显示黑色滚动条,可以是平台提供的滚动条的深色变体,也可以是带深色的自定义滚动条。 | @@ -66,7 +66,13 @@ scrollbar-color: unset; ### HTML ```html -
Veggies es bonus vobis, proinde vos postulo essum magis kohlrabi welsh onion daikon amaranth tatsoi tomatillo melon azuki bean garlic. Gumbo beet greens corn soko endive gumbo gourd. Parsley shallot courgette tatsoi pea sprouts fava bean collard greens dandelion okra wakame tomato. Dandelion cucumber earthnut pea peanut soko zucchini.
+
+ Veggies es bonus vobis, proinde vos postulo essum magis kohlrabi welsh onion + daikon amaranth tatsoi tomatillo melon azuki bean garlic. Gumbo beet greens + corn soko endive gumbo gourd. Parsley shallot courgette tatsoi pea sprouts + fava bean collard greens dandelion okra wakame tomato. Dandelion cucumber + earthnut pea peanut soko zucchini. +
``` ### 结果 diff --git a/files/zh-cn/web/css/selector_list/index.md b/files/zh-cn/web/css/selector_list/index.md index 5a4a3e395bd51b..02ccf3a5544aca 100644 --- a/files/zh-cn/web/css/selector_list/index.md +++ b/files/zh-cn/web/css/selector_list/index.md @@ -44,7 +44,12 @@ div { 此示例显示了将选择器编组进一个以逗号分隔的单行列表。 ```css -h1, h2, h3, h4, h5, h6 { +h1, +h2, +h3, +h4, +h5, +h6 { font-family: helvetica; } ``` @@ -85,7 +90,9 @@ h3 { ``` ```css -h1, h2:invalid-pseudo, h3 { +h1, +h2:invalid-pseudo, +h3 { font-family: sans-serif; } ``` diff --git a/files/zh-cn/web/css/shape-image-threshold/index.md b/files/zh-cn/web/css/shape-image-threshold/index.md index d601de60d5c7f0..a39ef2285938af 100644 --- a/files/zh-cn/web/css/shape-image-threshold/index.md +++ b/files/zh-cn/web/css/shape-image-threshold/index.md @@ -48,14 +48,14 @@ shape-image-threshold: unset;

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Vel at commodi voluptates enim, distinctio officia. Saepe optio accusamus doloribus sint - facilis itaque ab nulla, dolor molestiae assumenda cum sit placeat - adipisci, libero quae nihil porro debitis laboriosam inventore animi - impedit nostrum nesciunt quisquam expedita! Dolores consectetur iure atque - a mollitia dicta repudiandae illum exercitationem aliquam repellendus - ipsum porro modi, id nemo eligendi, architecto ratione quibusdam iusto - nisi soluta? Totam inventore ea eum sed velit et eligendi suscipit - accusamus iusto dolore, at provident eius alias maxime pariatur non - deleniti ipsum sequi rem eveniet laboriosam magni expedita? + facilis itaque ab nulla, dolor molestiae assumenda cum sit placeat adipisci, + libero quae nihil porro debitis laboriosam inventore animi impedit nostrum + nesciunt quisquam expedita! Dolores consectetur iure atque a mollitia dicta + repudiandae illum exercitationem aliquam repellendus ipsum porro modi, id nemo + eligendi, architecto ratione quibusdam iusto nisi soluta? Totam inventore ea + eum sed velit et eligendi suscipit accusamus iusto dolore, at provident eius + alias maxime pariatur non deleniti ipsum sequi rem eveniet laboriosam magni + expedita?

``` @@ -66,10 +66,8 @@ shape-image-threshold: unset; width: 150px; height: 150px; float: left; - background-image: linear-gradient(30deg, black, transparent 80%, - transparent); - shape-outside: linear-gradient(30deg, black, transparent 80%, - transparent); + background-image: linear-gradient(30deg, black, transparent 80%, transparent); + shape-outside: linear-gradient(30deg, black, transparent 80%, transparent); shape-image-threshold: 0.2; } ``` diff --git a/files/zh-cn/web/css/shape-margin/index.md b/files/zh-cn/web/css/shape-margin/index.md index e3c1a3dd5dbfd3..032e62f822e4ec 100644 --- a/files/zh-cn/web/css/shape-margin/index.md +++ b/files/zh-cn/web/css/shape-margin/index.md @@ -44,14 +44,15 @@ shape-margin: unset; ```html
-
-We are not quite sure of any one thing in biology; our knowledge of geology -is relatively very slight, and the economic laws of society are -uncertain to every one except some individual who attempts to set them -forth; but before the world was fashioned the square on the hypotenuse -was equal to the sum of the squares on the other two sides of a right -triangle, and it will be so after this world is dead; and the inhabitant -of Mars, if one exists, probably knows its truth as we know it.
+
+ We are not quite sure of any one thing in biology; our knowledge of geology is + relatively very slight, and the economic laws of society are uncertain to + every one except some individual who attempts to set them forth; but before + the world was fashioned the square on the hypotenuse was equal to the sum of + the squares on the other two sides of a right triangle, and it will be so + after this world is dead; and the inhabitant of Mars, if one exists, probably + knows its truth as we know it. + ``` #### CSS diff --git a/files/zh-cn/web/css/shape-outside/index.md b/files/zh-cn/web/css/shape-outside/index.md index f8b509578d0755..107823fc5e73b1 100644 --- a/files/zh-cn/web/css/shape-outside/index.md +++ b/files/zh-cn/web/css/shape-outside/index.md @@ -85,10 +85,9 @@ shape-outside: unset;

- Sometimes a web page's text content appears to be - funneling your attention towards a spot on the page - to drive you to follow a particular link. Sometimes - you don't notice. + Sometimes a web page's text content appears to be funneling your attention + towards a spot on the page to drive you to follow a particular link. + Sometimes you don't notice.

``` diff --git a/files/zh-cn/web/css/shorthand_properties/index.md b/files/zh-cn/web/css/shorthand_properties/index.md index 3d4097e750ad1b..d3a574d6c83380 100644 --- a/files/zh-cn/web/css/shorthand_properties/index.md +++ b/files/zh-cn/web/css/shorthand_properties/index.md @@ -89,7 +89,7 @@ background: #000 url(images/bg.gif) no-repeat top right; ```css font-style: italic; font-weight: bold; -font-size: .8em; +font-size: 0.8em; line-height: 1.2; font-family: Arial, sans-serif; ``` @@ -97,7 +97,9 @@ font-family: Arial, sans-serif; 可以简写成下面的: ```css -font: italic bold .8em/1.2 Arial, sans-serif; +font: + italic bold 0.8em/1.2 Arial, + sans-serif; ``` 这个简写声明实际上等价于以上普通属性再加上 `font-variant: normal`、`font-size-adjust: none` 和 `font-stretch: normal`。 @@ -170,4 +172,5 @@ CSS 提供了一个通用的简写属性 {{cssxref("all")}},它可以应用于 - [属性值定义语法](/zh-CN/docs/Web/CSS/Value_definition_syntax) - [可替换元素](/zh-CN/docs/Web/CSS/Replaced_element) + - 简写属性:{{cssxref("all")}}、{{cssxref("animation")}}、{{cssxref("background")}}、{{cssxref("border")}}、{{cssxref("border-block-end")}}、{{cssxref("border-block-start")}}、{{cssxref("border-bottom")}}、{{cssxref("border-color")}}、{{cssxref("border-image")}}、{{cssxref("border-inline-end")}}、{{cssxref("border-inline-start")}}、{{cssxref("border-left")}}、{{cssxref("border-radius")}}、{{cssxref("border-right")}}、{{cssxref("border-style")}}、{{cssxref("border-top")}}、{{cssxref("border-width")}}、{{cssxref("column-rule")}}、{{cssxref("columns")}}、{{cssxref("flex")}}、{{cssxref("flex-flow")}}、{{cssxref("font")}}、{{cssxref("gap")}}、{{cssxref("grid")}}、{{cssxref("grid-area")}}、{{cssxref("grid-column")}}、{{cssxref("grid-row")}}、{{cssxref("grid-template")}}、{{cssxref("list-style")}}、{{cssxref("margin")}}、{{cssxref("mask")}}、{{cssxref("offset")}}、{{cssxref("outline")}}、{{cssxref("overflow")}}、{{cssxref("padding")}}、{{cssxref("place-content")}}、{{cssxref("place-items")}}、{{cssxref("place-self")}}、{{cssxref("scroll-margin")}}、{{cssxref("scroll-padding")}}、{{cssxref("text-decoration")}}、{{cssxref("text-emphasis")}}、{{cssxref("transition")}} diff --git a/files/zh-cn/web/css/specificity/index.md b/files/zh-cn/web/css/specificity/index.md index 8f30257c63fe9b..e0fd9fb9a666b2 100644 --- a/files/zh-cn/web/css/specificity/index.md +++ b/files/zh-cn/web/css/specificity/index.md @@ -46,26 +46,36 @@ slug: Web/CSS/Specificity 1. 更好地利用 CSS 级联属性 2. 使用更具体的规则。在您选择的元素之前,增加一个或多个其他元素,使选择器变得更加具体,并获得更高的优先级。 - ```html -
- Text -
- ``` - - ```css - div#test span { color: green; } - div span { color: blue; } - span { color: red; } - ``` - - 无论 css 语句的顺序是什么样的,文本都会是绿色的(green),因为这一条规则是最有针对性、优先级最高的。(同理,无论语句顺序怎样,蓝色 blue 的规则都会覆盖红色 red 的规则) + ```html +
+ Text +
+ ``` + + ```css + div#test span { + color: green; + } + div span { + color: blue; + } + span { + color: red; + } + ``` + + 无论 css 语句的顺序是什么样的,文本都会是绿色的(green),因为这一条规则是最有针对性、优先级最高的。(同理,无论语句顺序怎样,蓝色 blue 的规则都会覆盖红色 red 的规则) 3. 对于(2)的一种特殊情况,当您无其他要指定的内容时,请复制简单的选择器以增加特异性。 - ```css - #myId#myId span { color: yellow; } - .myClass.myClass span { color: orange; } - ``` + ```css + #myId#myId span { + color: yellow; + } + .myClass.myClass span { + color: orange; + } + ``` #### 什么的情况下可以使用 `!important`: @@ -110,15 +120,23 @@ A) 很简单,只需再添加一条 带 `!important` 的 CSS 规则,再给这 一些拥有更高优先级的例子: ```css - table td { height: 50px !important; } -.myTable td { height: 50px !important; } -#myTable td { height: 50px !important; } +table td { + height: 50px !important; +} +.myTable td { + height: 50px !important; +} +#myTable td { + height: 50px !important; +} ``` B) 或者使用相同的选择器,但是置于已有的样式之后: ```css -td { height: 50px !important; } +td { + height: 50px !important; +} ``` C) 或干脆改写原来的规则,以避免使用 `!important`。 @@ -208,8 +226,14 @@ div p { 将其应用于以下的 HTML 时: ```html hidden -
-⚠️ Your browser doesn't support the :where() pseudo-class. +
+ ⚠️ Your browser doesn't support the + :where() + pseudo-class.
``` diff --git a/files/zh-cn/web/css/system-color/index.md b/files/zh-cn/web/css/system-color/index.md index 09e41435d201dc..b4f5f32badd25c 100644 --- a/files/zh-cn/web/css/system-color/index.md +++ b/files/zh-cn/web/css/system-color/index.md @@ -123,7 +123,9 @@ slug: Web/CSS/system-color .button { border: 0; padding: 10px; - box-shadow: -2px -2px 5px gray, 2px 2px 5px gray; + box-shadow: + -2px -2px 5px gray, + 2px 2px 5px gray; } @media (forced-colors: active) { diff --git a/files/zh-cn/web/css/text-align-last/index.md b/files/zh-cn/web/css/text-align-last/index.md index 5735f9f392724d..914a4fc0452600 100644 --- a/files/zh-cn/web/css/text-align-last/index.md +++ b/files/zh-cn/web/css/text-align-last/index.md @@ -57,7 +57,11 @@ text-align-last: unset; ## 示例 ```html hidden -

Integer elementum massa at nulla placerat varius. Suspendisse in libero risus, in interdum massa. Vestibulum ac leo vitae metus faucibus gravida ac in neque. Nullam est eros, suscipit sed dictum quis, accumsan a ligula.

+

+ Integer elementum massa at nulla placerat varius. Suspendisse in libero risus, + in interdum massa. Vestibulum ac leo vitae metus faucibus gravida ac in neque. + Nullam est eros, suscipit sed dictum quis, accumsan a ligula. +

``` ```css diff --git a/files/zh-cn/web/css/text-decoration-color/index.md b/files/zh-cn/web/css/text-decoration-color/index.md index ea0681bf65a8c1..622ef3184842a1 100644 --- a/files/zh-cn/web/css/text-decoration-color/index.md +++ b/files/zh-cn/web/css/text-decoration-color/index.md @@ -41,8 +41,10 @@ text-decoration-color: unset; ## 示例 ```html -

This paragraph has some erroneous text - inside it that I want to call attention to.

+

+ This paragraph has some erroneous text inside it that I want to call + attention to. +

``` ```css diff --git a/files/zh-cn/web/css/text-decoration-line/index.md b/files/zh-cn/web/css/text-decoration-line/index.md index 5ae272ca6c0f84..da0dd896411b08 100644 --- a/files/zh-cn/web/css/text-decoration-line/index.md +++ b/files/zh-cn/web/css/text-decoration-line/index.md @@ -14,8 +14,8 @@ text-decoration-line: underline; text-decoration-line: overline; text-decoration-line: line-through; text-decoration-line: blink; -text-decoration-line: underline overline; /* Two decoration lines */ -text-decoration-line: overline underline line-through; /* Multiple decoration lines */ +text-decoration-line: underline overline; /* Two decoration lines */ +text-decoration-line: overline underline line-through; /* Multiple decoration lines */ /* Global values */ text-decoration-line: inherit; diff --git a/files/zh-cn/web/css/text-decoration-style/index.md b/files/zh-cn/web/css/text-decoration-style/index.md index 007bf74a816ad6..f150e751d2a535 100644 --- a/files/zh-cn/web/css/text-decoration-style/index.md +++ b/files/zh-cn/web/css/text-decoration-style/index.md @@ -52,12 +52,12 @@ text-decoration-style: unset; ```css .example { - -moz-text-decoration-line: underline; - -moz-text-decoration-style: wavy; - -moz-text-decoration-color: red; - -webkit-text-decoration-line: underline; - -webkit-text-decoration-style: wavy; - -webkit-text-decoration-color: red; + -moz-text-decoration-line: underline; + -moz-text-decoration-style: wavy; + -moz-text-decoration-color: red; + -webkit-text-decoration-line: underline; + -webkit-text-decoration-style: wavy; + -webkit-text-decoration-color: red; } ``` diff --git a/files/zh-cn/web/css/text-decoration/index.md b/files/zh-cn/web/css/text-decoration/index.md index 63ca6f1668e3d6..32d2d595035780 100644 --- a/files/zh-cn/web/css/text-decoration/index.md +++ b/files/zh-cn/web/css/text-decoration/index.md @@ -94,7 +94,10 @@ text-decoration: unset;

此文本下方有一行线。

此文本上面有一行线。

此文本有一条线穿过它。

-

链接不会具有下划线,因为链接默认加下划线。移除锚点上的文本装饰时要小心,因为用户通常依赖下划线来表示超链接

+

+ 此链接不会具有下划线,因为链接默认加下划线。移除锚点上的文本装饰时要小心,因为用户通常依赖下划线来表示超链接 +

此文本在其上方下方都有线条。

在浏览器支持的情况下,此文本具有非常粗的紫色下划线。

diff --git a/files/zh-cn/web/css/text-indent/index.md b/files/zh-cn/web/css/text-indent/index.md index 4c73a50df656f3..4df71bf4af9998 100644 --- a/files/zh-cn/web/css/text-indent/index.md +++ b/files/zh-cn/web/css/text-indent/index.md @@ -50,8 +50,10 @@ text-indent: unset; ### HTML ```html -

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy - nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.

+

+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy + nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. +

``` ### CSS diff --git a/files/zh-cn/web/css/text-justify/index.md b/files/zh-cn/web/css/text-justify/index.md index fc46e10d5eb849..cfaad4da6e0a44 100644 --- a/files/zh-cn/web/css/text-justify/index.md +++ b/files/zh-cn/web/css/text-justify/index.md @@ -41,11 +41,36 @@ text-justify: distribute; /* 已被废除,不提倡使用 */ ## 示例 ```html hidden -

text-justify: none
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc ornare maximus vehicula. Duis nisi velit, dictum id mauris vitae, lobortis pretium quam. Quisque sed nisi pulvinar, consequat justo id, feugiat leo. Cras eu elementum dui.

-

text-justify: auto
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc ornare maximus vehicula. Duis nisi velit, dictum id mauris vitae, lobortis pretium quam. Quisque sed nisi pulvinar, consequat justo id, feugiat leo. Cras eu elementum dui.

-

text-justify: distribute
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc ornare maximus vehicula. Duis nisi velit, dictum id mauris vitae, lobortis pretium quam. Quisque sed nisi pulvinar, consequat justo id, feugiat leo. Cras eu elementum dui.

-

text-justify: inter-word
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc ornare maximus vehicula. Duis nisi velit, dictum id mauris vitae, lobortis pretium quam. Quisque sed nisi pulvinar, consequat justo id, feugiat leo. Cras eu elementum dui.

-

text-justify: inter-character
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc ornare maximus vehicula. Duis nisi velit, dictum id mauris vitae, lobortis pretium quam. Quisque sed nisi pulvinar, consequat justo id, feugiat leo. Cras eu elementum dui.

+

+ text-justify: none
Lorem ipsum dolor sit amet, consectetur + adipiscing elit. Nunc ornare maximus vehicula. Duis nisi velit, dictum id + mauris vitae, lobortis pretium quam. Quisque sed nisi pulvinar, consequat + justo id, feugiat leo. Cras eu elementum dui. +

+

+ text-justify: auto
Lorem ipsum dolor sit amet, consectetur + adipiscing elit. Nunc ornare maximus vehicula. Duis nisi velit, dictum id + mauris vitae, lobortis pretium quam. Quisque sed nisi pulvinar, consequat + justo id, feugiat leo. Cras eu elementum dui. +

+

+ text-justify: distribute
Lorem ipsum dolor sit amet, + consectetur adipiscing elit. Nunc ornare maximus vehicula. Duis nisi velit, + dictum id mauris vitae, lobortis pretium quam. Quisque sed nisi pulvinar, + consequat justo id, feugiat leo. Cras eu elementum dui. +

+

+ text-justify: inter-word
Lorem ipsum dolor sit amet, + consectetur adipiscing elit. Nunc ornare maximus vehicula. Duis nisi velit, + dictum id mauris vitae, lobortis pretium quam. Quisque sed nisi pulvinar, + consequat justo id, feugiat leo. Cras eu elementum dui. +

+

+ text-justify: inter-character
Lorem ipsum dolor sit amet, + consectetur adipiscing elit. Nunc ornare maximus vehicula. Duis nisi velit, + dictum id mauris vitae, lobortis pretium quam. Quisque sed nisi pulvinar, + consequat justo id, feugiat leo. Cras eu elementum dui. +

``` ```css diff --git a/files/zh-cn/web/css/text-overflow/index.md b/files/zh-cn/web/css/text-overflow/index.md index 2f5d03fd9780e5..513f0b1fb6d16e 100644 --- a/files/zh-cn/web/css/text-overflow/index.md +++ b/files/zh-cn/web/css/text-overflow/index.md @@ -73,21 +73,33 @@ text-overflow: unset;

Left to right text

clip
-

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. +

ellipsis
-

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. +

" [..]"
-

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. +

Right to left text

clip
-

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. +

ellipsis
-

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. +

" [..]"
-

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. +

``` @@ -142,13 +154,21 @@ body { ```html
clip clip
-

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. +

clip ellipsis
-

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. +

ellipsis ellipsis
-

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. +

ellipsis " [..]"
-

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. +

``` #### CSS diff --git a/files/zh-cn/web/css/text-rendering/index.md b/files/zh-cn/web/css/text-rendering/index.md index 1b87c5cbb40dcf..c81b0f4f336e75 100644 --- a/files/zh-cn/web/css/text-rendering/index.md +++ b/files/zh-cn/web/css/text-rendering/index.md @@ -41,6 +41,7 @@ text-rendering: unset; - `optimizeLegibility` - : 浏览器在绘制文本时将着重考虑易读性,而不是渲染速度和几何精度。它会使字间距和连字有效。**该属性值在移动设备上会造成比较明显的性能问题**,详细查看 [text-rendering](https://css-tricks.com/almanac/properties/t/text-rendering/)。 - `geometricPrecision` + - : 浏览器在绘制文本时将着重考虑几何精度,而不是渲染速度和易读性。字体的某些方面—比如字间距—不再线性缩放,所以该值可以使使用某些字体的文本看起来不错。 对于 SVG,当文本缩放时,浏览器会计算文本最终大小(取决于特定的字体大小和相应的缩放比例)并且从操作平台的字体系统中请求一个符合该计算值的字体大小。但如果你请求一个字体大小,比如 9 并且 140% 的缩放,这个最终的字体大小为 12.6,字体系统中明显不存在,所以浏览器会向下取整到 12。这导致文本缩放是阶梯式的。 @@ -55,8 +56,12 @@ text-rendering: unset; /* make sure all fonts in the HTML document display in all its glory, but avoid inadequate ligatures in class foo elements */ -body { text-rendering: optimizeLegibility; } -.foo { text-rendering: optimizeSpeed; } +body { + text-rendering: optimizeLegibility; +} +.foo { + text-rendering: optimizeSpeed; +} ``` #### Live Example diff --git a/files/zh-cn/web/css/text-shadow/index.md b/files/zh-cn/web/css/text-shadow/index.md index 35fdbb23f2113d..ba9f0dd1f741a1 100644 --- a/files/zh-cn/web/css/text-shadow/index.md +++ b/files/zh-cn/web/css/text-shadow/index.md @@ -65,14 +65,15 @@ text-shadow: unset; ```css .red-text-shadow { - text-shadow: red 0 -2px; + text-shadow: red 0 -2px; } ``` ```html

- Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo - inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. + Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium + doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore + veritatis et quasi architecto beatae vitae dicta sunt explicabo.

``` @@ -82,16 +83,25 @@ text-shadow: unset; ```css .white-with-blue-shadow { - text-shadow: 1px 1px 2px black, 0 0 1em blue, 0 0 0.2em blue; - color: white; - font: 1.5em Georgia, "Bitstream Charter", "URW Bookman L", "Century Schoolbook L", serif; + text-shadow: + 1px 1px 2px black, + 0 0 1em blue, + 0 0 0.2em blue; + color: white; + font: + 1.5em Georgia, + "Bitstream Charter", + "URW Bookman L", + "Century Schoolbook L", + serif; } ``` ```html

- Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore - veritatis et quasi architecto beatae vitae dicta sunt explicabo. + Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium + doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore + veritatis et quasi architecto beatae vitae dicta sunt explicabo.

``` diff --git a/files/zh-cn/web/css/text-transform/index.md b/files/zh-cn/web/css/text-transform/index.md index 2de6374d161918..8ca6e3b174f308 100644 --- a/files/zh-cn/web/css/text-transform/index.md +++ b/files/zh-cn/web/css/text-transform/index.md @@ -214,7 +214,7 @@ strong {

``` -这个示例展示了荷兰语双字母字符 *ij* 必须像一个单一的字母一样处理。 +这个示例展示了荷兰语双字母字符 _ij_ 必须像一个单一的字母一样处理。 {{ EmbedLiveSample('使用“capitalize”(荷兰语 ij 双字母字符)', '100%', '100px') }} @@ -267,10 +267,12 @@ strong { span { text-transform: uppercase; } -strong { float: right; } +strong { + float: right; +} ``` -这个示例展示了希腊元音除了不连读的 *eta* 之外,应该没有重音,而元音对中第一个元音的重音变成了第二个元音的重音。 +这个示例展示了希腊元音除了不连读的 _eta_ 之外,应该没有重音,而元音对中第一个元音的重音变成了第二个元音的重音。 {{ EmbedLiveSample('使用“uppercase”(希腊语元音)', '100%', '100px') }} diff --git a/files/zh-cn/web/css/touch-action/index.md b/files/zh-cn/web/css/touch-action/index.md index 3806d25ef72a69..a31b68ad88d25e 100644 --- a/files/zh-cn/web/css/touch-action/index.md +++ b/files/zh-cn/web/css/touch-action/index.md @@ -82,7 +82,7 @@ touch-action 属性可以被指定为: **触摸动作**也经常用于完全解决由支持双击缩放手势引起的点击事件的延迟。 -```html +```css html { touch-action: manipulation; } diff --git a/files/zh-cn/web/css/transform-function/index.md b/files/zh-cn/web/css/transform-function/index.md index 29864e72d00f4d..bc4995e30fe8a9 100644 --- a/files/zh-cn/web/css/transform-function/index.md +++ b/files/zh-cn/web/css/transform-function/index.md @@ -136,19 +136,19 @@ main { #### JavaScript ```js -const selectElem = document.querySelector('select'); -const example = document.querySelector('#example-element'); +const selectElem = document.querySelector("select"); +const example = document.querySelector("#example-element"); -selectElem.addEventListener('change', () => { - if (selectElem.value === 'Choose a function') { +selectElem.addEventListener("change", () => { + if (selectElem.value === "Choose a function") { return; } else { example.style.transform = `rotate3d(1, 1, 1, 30deg) ${selectElem.value}`; setTimeout(() => { - example.style.transform = 'rotate3d(1, 1, 1, 30deg)'; - }, 2000) + example.style.transform = "rotate3d(1, 1, 1, 30deg)"; + }, 2000); } -}) +}); ``` #### 结果 diff --git a/files/zh-cn/web/css/transform-function/matrix3d/index.md b/files/zh-cn/web/css/transform-function/matrix3d/index.md index 227f3a315d94c3..c4981003cfc56a 100644 --- a/files/zh-cn/web/css/transform-function/matrix3d/index.md +++ b/files/zh-cn/web/css/transform-function/matrix3d/index.md @@ -72,9 +72,9 @@ matrix3d(a1, b1, c1, d1, a2, b2, c2, d2, a3, b3, c3, d3, a4, b4, c4, d4) ```html
-Lorem ipsum dolor sit amet, consectetur adipisicing elit. -Quos quaerat sit soluta, quisquam exercitationem delectus qui unde in facere -necessitatibus aut quia porro dolorem nesciunt enim, at consequuntur aliquam esse? + Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quos quaerat sit + soluta, quisquam exercitationem delectus qui unde in facere necessitatibus aut + quia porro dolorem nesciunt enim, at consequuntur aliquam esse?
``` @@ -91,7 +91,6 @@ body { flex-flow: row wrap; justify-content: center; align-content: center; - } .foo { width: 50%; @@ -102,7 +101,7 @@ body { text-align: center; font-family: system-ui, sans-serif; font-size: 14px; - /* Setting up animation for better demonstration */ + /* Setting up animation for better demonstration */ animation: MotionScale 2s alternate linear infinite; } @@ -117,29 +116,13 @@ body { Translates every Z point by 0 Scales down by 10% */ - transform: matrix3d( - 1,0,0,0, - 0,1,0,0, - 0,0,1,0, - -50,-100,0,1.1 - ); - + transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -50, -100, 0, 1.1); } 50% { - transform: matrix3d( - 1,0,0,0, - 0,1,0,0, - 0,0,1,0, - 0,0,0,0.9 - ); + transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0.9); } to { - transform: matrix3d( - 1,0,0,0, - 0,1,0,0, - 0,0,1,0, - 50,100,0,1.1 - ) + transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 50, 100, 0, 1.1); } } ``` diff --git a/files/zh-cn/web/css/transform-function/translate/index.md b/files/zh-cn/web/css/transform-function/translate/index.md index 49feb022b9b701..3edec9a14d743f 100644 --- a/files/zh-cn/web/css/transform-function/translate/index.md +++ b/files/zh-cn/web/css/transform-function/translate/index.md @@ -118,7 +118,9 @@ div { } .moved { - transform: translate(10px); /* Equal to: translateX(10px) or translate(10px, 0) */ + transform: translate( + 10px + ); /* Equal to: translateX(10px) or translate(10px, 0) */ background-color: pink; } ``` diff --git a/files/zh-cn/web/css/transform-function/translate3d/index.md b/files/zh-cn/web/css/transform-function/translate3d/index.md index 0551584586b867..9864057a8affa3 100644 --- a/files/zh-cn/web/css/transform-function/translate3d/index.md +++ b/files/zh-cn/web/css/transform-function/translate3d/index.md @@ -80,7 +80,7 @@ p { } .transformed { - transform: perspective(500px) translate3d(10px,0px,0px); + transform: perspective(500px) translate3d(10px, 0px, 0px); /* equivalent to perspective(500px) translateX(10px)*/ background-color: blue; } @@ -110,7 +110,7 @@ p { } .transformed { - transform: perspective(500px) translate3d(10px,0px,100px); + transform: perspective(500px) translate3d(10px, 0px, 100px); background-color: blue; } ``` diff --git a/files/zh-cn/web/css/transform/index.md b/files/zh-cn/web/css/transform/index.md index 2e41faeaf9b2e4..c050e3e3ffdc6e 100644 --- a/files/zh-cn/web/css/transform/index.md +++ b/files/zh-cn/web/css/transform/index.md @@ -16,7 +16,7 @@ CSS **`transform`** 属性允许你旋转,缩放,倾斜或平移给定元素 transform: none; /* Function values */ -transform: matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0); +transform: matrix(1, 2, 3, 4, 5, 6); transform: translate(12px, 50%); transform: translateX(2em); transform: translateY(3in); @@ -27,12 +27,12 @@ transform: rotate(0.5turn); transform: skew(30deg, 20deg); transform: skewX(30deg); transform: skewY(1.07rad); -transform: matrix3d(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0); +transform: matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); transform: translate3d(12px, 50%, 3em); transform: translateZ(2px); transform: scale3d(2.5, 1.2, 0.3); transform: scaleZ(0.3); -transform: rotate3d(1, 2.0, 3.0, 10deg); +transform: rotate3d(1, 2, 3, 10deg); transform: rotateX(10deg); transform: rotateY(10deg); transform: rotateZ(10deg); diff --git a/files/zh-cn/web/css/transition-property/index.md b/files/zh-cn/web/css/transition-property/index.md index 4e2faac11a9220..3727e9823a03bb 100644 --- a/files/zh-cn/web/css/transition-property/index.md +++ b/files/zh-cn/web/css/transition-property/index.md @@ -24,7 +24,10 @@ transition-property: sliding-vertically; transition-property: test1; transition-property: test1, animation4; transition-property: all, height, all; -transition-property: all, -moz-specific, sliding; +transition-property: + all, + -moz-specific, + sliding; /* Global values */ transition-property: inherit; diff --git a/files/zh-cn/web/css/transition/index.md b/files/zh-cn/web/css/transition/index.md index 67ffb63e52c4ac..efce546677918d 100644 --- a/files/zh-cn/web/css/transition/index.md +++ b/files/zh-cn/web/css/transition/index.md @@ -28,7 +28,9 @@ transition: margin-right 4s ease-in-out; transition: margin-right 4s ease-in-out 1s; /* Apply to 2 properties */ -transition: margin-right 4s, color 1s; +transition: + margin-right 4s, + color 1s; /* Apply to all changed properties */ transition: all 0.5s ease-out; diff --git a/files/zh-cn/web/css/unicode-bidi/index.md b/files/zh-cn/web/css/unicode-bidi/index.md index a79248a31aeecb..3ed719e7c3a330 100644 --- a/files/zh-cn/web/css/unicode-bidi/index.md +++ b/files/zh-cn/web/css/unicode-bidi/index.md @@ -63,12 +63,8 @@ unicode-bidi: unset; ### HTML ```html -
- A line of text -
-
- Another line of text -
+
A line of text
+
Another line of text
``` ### 结果 diff --git a/files/zh-cn/web/css/universal_selectors/index.md b/files/zh-cn/web/css/universal_selectors/index.md index 77ad995c3cef2a..73dee65348a4c2 100644 --- a/files/zh-cn/web/css/universal_selectors/index.md +++ b/files/zh-cn/web/css/universal_selectors/index.md @@ -18,9 +18,15 @@ slug: Web/CSS/Universal_selectors ## 示例 ```css -*[lang^=en]{color:green;} -*.warning {color:red;} -*#maincontent {border: 1px solid blue;} +*[lang^="en"] { + color: green; +} +*.warning { + color: red; +} +*#maincontent { + border: 1px solid blue; +} ``` 上面的 CSS 作用于下面的 HTML: diff --git a/files/zh-cn/web/css/url/index.md b/files/zh-cn/web/css/url/index.md index 9a6780e12f7a8c..46762eea0aacba 100644 --- a/files/zh-cn/web/css/url/index.md +++ b/files/zh-cn/web/css/url/index.md @@ -41,11 +41,15 @@ URL 可以使用单引号或双引号包含,也可以直接书写。可以在 ## 示例 ```css -.topbanner { background: url("topbanner.png") #00D no-repeat fixed; } +.topbanner { + background: url("topbanner.png") #00d no-repeat fixed; +} ``` ```css -ul { list-style: square url(http://www.example.com/redball.png) } +ul { + list-style: square url(http://www.example.com/redball.png); +} ``` ## 规范 diff --git a/files/zh-cn/web/css/user-select/index.md b/files/zh-cn/web/css/user-select/index.md index fd848cf9250f82..55960ea28ae5d0 100644 --- a/files/zh-cn/web/css/user-select/index.md +++ b/files/zh-cn/web/css/user-select/index.md @@ -32,6 +32,7 @@ user-select: unset; ### 取值 - `none` + - : 元素及其子元素的文本不可选中。请注意,{{domxref("Selection")}} 对象可以包含这些元素。 - `auto` @@ -49,6 +50,7 @@ user-select: unset; - `all` - : 在一个 HTML 编辑器中,当双击子元素或者上下文时,那么包含该子元素的最顶层元素也会被选中。 - `contain` + - : 允许在元素内选择;但是,选区将被限制在该元素的边界之内。 > **备注:** CSS UI 4 将 `element` 值[重命名](https://github.com/w3c/csswg-drafts/commit/3f1d9db96fad8d9fc787d3ed66e2d5ad8cfadd05)为 `contain`。 diff --git a/files/zh-cn/web/css/using_css_custom_properties/index.md b/files/zh-cn/web/css/using_css_custom_properties/index.md index 095f1c8e28cdab..f59ca4b3149f13 100644 --- a/files/zh-cn/web/css/using_css_custom_properties/index.md +++ b/files/zh-cn/web/css/using_css_custom_properties/index.md @@ -83,7 +83,7 @@ element {
1:
2: Text 5 - more text
- +
``` @@ -184,11 +184,18 @@ element { } .three { - background-color: var(--my-var, var(--my-background, pink)); /* pink if --my-var and --my-background are not defined */ + background-color: var( + --my-var, + var(--my-background, pink) + ); /* pink if --my-var and --my-background are not defined */ } .three { - background-color: var(--my-var, --my-background, pink); /* Invalid: "--my-background, pink" */ + background-color: var( + --my-var, + --my-background, + pink + ); /* Invalid: "--my-background, pink" */ } ``` @@ -217,9 +224,15 @@ element { ### CSS ```css -:root { --text-color: 16px; } -p { color: blue; } -p { color: var(--text-color); } +:root { + --text-color: 16px; +} +p { + color: blue; +} +p { + color: var(--text-color); +} ``` 毫不意外,浏览器将 `--text-color` 的值替换给了 `var(--text-color)`,但是 `16px` 并不是 {{cssxref("color")}} 的合法属性值。代换之后,该属性不会产生任何作用。浏览器会执行如下两个步骤: diff --git a/files/zh-cn/web/css/var/index.md b/files/zh-cn/web/css/var/index.md index bd2bc151c5b843..8f60a34719b491 100644 --- a/files/zh-cn/web/css/var/index.md +++ b/files/zh-cn/web/css/var/index.md @@ -48,10 +48,7 @@ body { /* 在 component 的样式中: */ .component .header { /* header-color 没有被设置, 将使用回退值 blue */ - color: var( - --header-color, - blue - ); + color: var(--header-color, blue); } .component .text { diff --git a/files/zh-cn/web/css/vertical-align/index.md b/files/zh-cn/web/css/vertical-align/index.md index a4111caf35fadc..0c75bc5d5e0830 100644 --- a/files/zh-cn/web/css/vertical-align/index.md +++ b/files/zh-cn/web/css/vertical-align/index.md @@ -100,18 +100,39 @@ vertical-align: unset; ### HTML ```html -
An link image with a default alignment.
-
An link image with a text-top alignment.
-
An link image with a text-bottom alignment.
-
An link image with a middle alignment.
+
+ An link image with + a default alignment. +
+
+ An + link + image with a text-top alignment. +
+
+ An + link + image with a text-bottom alignment. +
+
+ An + link + image with a middle alignment. +
``` ### CSS ```css -img.top { vertical-align: text-top; } -img.bottom { vertical-align: text-bottom; } -img.middle { vertical-align: middle; } +img.top { + vertical-align: text-top; +} +img.bottom { + vertical-align: text-bottom; +} +img.middle { + vertical-align: middle; +} ``` ### 结果 diff --git a/files/zh-cn/web/css/viewport_concepts/index.md b/files/zh-cn/web/css/viewport_concepts/index.md index 3d4e3ee13c4e2c..ab1cfa3e628e5c 100644 --- a/files/zh-cn/web/css/viewport_concepts/index.md +++ b/files/zh-cn/web/css/viewport_concepts/index.md @@ -24,15 +24,15 @@ slug: Web/CSS/Viewport_concepts 视口的宽度并不总是窗口的宽度。如果你测试 Chrome 或 Firefox 浏览器中 window 和 document 的宽度和高度,你会得到如下值: ```js -document.documentElement.clientWidth /* 1200 */ -window.innerWidth /* 1200 */ -window.outerWidth /* 1200 */ +document.documentElement.clientWidth; /* 1200 */ +window.innerWidth; /* 1200 */ +window.outerWidth; /* 1200 */ ``` ```js -document.documentElement.clientHeight /* 800 */ -window.innerHeight /* 800 */ -window.outerHeight /* 900 */ +document.documentElement.clientHeight; /* 800 */ +window.innerHeight; /* 800 */ +window.outerHeight; /* 900 */ ``` 下面是一些帮助你查询视口大小和其他类似的长度属性的 DOM 属性: @@ -48,15 +48,15 @@ window.outerHeight /* 900 */ 当缩放时,Firefox 和 Chrome 对 `innerWidth` 和 `clientWidth` 给出了新的 CSS 像素大小。浏览器对 `outerWidth` 和 `outerHeight` 的返回值有差异。Firefox 返回了缩放后的 CSS 像素值,Chrome 返回了默认的像素值: ```js -document.documentElement.clientWidth /* 800 */ -window.innerWidth /* 800 */ -window.outerWidth /* 800 in Firefox, 1200 in chrome */ +document.documentElement.clientWidth; /* 800 */ +window.innerWidth; /* 800 */ +window.outerWidth; /* 800 in Firefox, 1200 in chrome */ ``` ```js -document.documentElement.clientHeight /* 533 */ -window.innerHeight /* 533 */ -window.outerHeight /* 596 in Firefox, 900 in chrome */ +document.documentElement.clientHeight; /* 533 */ +window.innerHeight; /* 533 */ +window.outerHeight; /* 596 in Firefox, 900 in chrome */ ``` 原始的视口大小是 1200 x 800 像素。缩放后变成了 800 x 533。这是布局视口。该网页有固定的头部和尾部,带有下列样式,它们将会固定在相对布局视口的顶部和底部。 @@ -90,7 +90,7 @@ Web 浏览器包含两个视口,**布局视口**和**视觉视口**。视觉 #### ` + diff --git a/files/fr/web/javascript/reference/errors/read-only/index.md b/files/fr/web/javascript/reference/errors/read-only/index.md index feafe9dbc36fe3..29f50f9c03f568 100644 --- a/files/fr/web/javascript/reference/errors/read-only/index.md +++ b/files/fr/web/javascript/reference/errors/read-only/index.md @@ -34,23 +34,23 @@ Les propriétés en lecture seule ne sont pas fréquemment utilisées mais on pe ```js example-bad "use strict"; -var obj = Object.freeze({name: "Elsa", score: 157}); -obj.score = 0; // TypeError +var obj = Object.freeze({ name: "Elsa", score: 157 }); +obj.score = 0; // TypeError -"use strict"; -Object.defineProperty(this, "NB_POUMONS", {value: 2, writable: false}); -NB_POUMONS = 3; // TypeError +("use strict"); +Object.defineProperty(this, "NB_POUMONS", { value: 2, writable: false }); +NB_POUMONS = 3; // TypeError -"use strict"; +("use strict"); var frozenArray = Object.freeze([0, 1, 2]); -frozenArray[0]++; // TypeError +frozenArray[0]++; // TypeError ``` Quelques propriétés natives JavaScript sont également en lecture seule. Par exemple, on obtient cette erreur lorsqu'on souhaite redéfinir une constante mathématique. ```js example-bad "use strict"; -Math.PI = 4; // TypeError +Math.PI = 4; // TypeError ``` La variable globale `undefined` est également en lecture seule. On ne peut donc pas faire disparaître la fameuse erreur "_undefined is not a function_" avec ce code : @@ -65,13 +65,13 @@ undefined = function () {}; ```js example-good "use strict"; -var obj = Object.freeze({name: "Score", points: 157}); -obj = {name: obj.name, points: 0}; +var obj = Object.freeze({ name: "Score", points: 157 }); +obj = { name: obj.name, points: 0 }; // En changeant d'objet, ça fonctionne -"use strict"; -var NB_POUMONS = 2; // `var` fonctionne -NB_POUMONS = 3; // ok +("use strict"); +var NB_POUMONS = 2; // `var` fonctionne +NB_POUMONS = 3; // ok ``` ## Voir aussi diff --git a/files/fr/web/javascript/reference/errors/reduce_of_empty_array_with_no_initial_value/index.md b/files/fr/web/javascript/reference/errors/reduce_of_empty_array_with_no_initial_value/index.md index 6c3f221ff8f039..831ea8483c9d6f 100644 --- a/files/fr/web/javascript/reference/errors/reduce_of_empty_array_with_no_initial_value/index.md +++ b/files/fr/web/javascript/reference/errors/reduce_of_empty_array_with_no_initial_value/index.md @@ -1,5 +1,5 @@ --- -title: 'TypeError: Reduce of empty array with no initial value' +title: "TypeError: Reduce of empty array with no initial value" slug: Web/JavaScript/Reference/Errors/Reduce_of_empty_array_with_no_initial_value translation_of: Web/JavaScript/Reference/Errors/Reduce_of_empty_array_with_no_initial_value --- @@ -33,15 +33,19 @@ Ce problème se produit lorsqu'on combine une méthode de filtrage ({{jsxref("Ar ```js example-bad var ints = [0, -1, -2, -3, -4, -5]; -ints.filter(x => x > 0) // cet appel retire tous les éléments - .reduce((x, y) => x + y) // aucun ne peut alors être utilisé comme valeur initiale +ints + .filter((x) => x > 0) // cet appel retire tous les éléments + .reduce((x, y) => x + y); // aucun ne peut alors être utilisé comme valeur initiale ``` Cela peut également se produire si on utilise un sélecteur avec une coquille ou que la liste contient un nombre d'élément inattendu: ```js example-bad var names = document.getElementsByClassName("names"); -var name_list = Array.prototype.reduce.call(names, (acc, name) => acc + ", " + name); +var name_list = Array.prototype.reduce.call( + names, + (acc, name) => acc + ", " + name, +); ``` ### Exemples valides @@ -52,8 +56,9 @@ On peut fournir une valeur initiale qui soit l'élément neutre de la réduction ```js example-good var ints = [0, -1, -2, -3, -4, -5]; -ints.filter(x => x > 0) // removes all elements - .reduce((x, y) => x + y, 0) // the initial value is the neutral element of the addition +ints + .filter((x) => x > 0) // removes all elements + .reduce((x, y) => x + y, 0); // the initial value is the neutral element of the addition ``` On peut également gérer le cas où le tableau est vide, avant d'appeler `reduce` ou dans le _callback_ après avoir ajouté une valeur initiale. @@ -63,14 +68,22 @@ var names = document.getElementsByClassName("names"); var nameList1 = ""; if (names1.length >= 1) - nameList1 = Array.prototype.reduce.call(names, (acc, name) => acc + ", " + name); + nameList1 = Array.prototype.reduce.call( + names, + (acc, name) => acc + ", " + name, + ); // nameList1 == "" lorsque names est vide -var nameList2 = Array.prototype.reduce.call(names, (acc, name) => { - if (acc == "") // la valeur initiale - return name; - return acc + ", " + name; -}, ""); +var nameList2 = Array.prototype.reduce.call( + names, + (acc, name) => { + if (acc == "") + // la valeur initiale + return name; + return acc + ", " + name; + }, + "", +); // nameList2 == "" lorsque names est vide ``` diff --git a/files/fr/web/javascript/reference/errors/resulting_string_too_large/index.md b/files/fr/web/javascript/reference/errors/resulting_string_too_large/index.md index 74aa7541d7f388..3c05b125b9b7f2 100644 --- a/files/fr/web/javascript/reference/errors/resulting_string_too_large/index.md +++ b/files/fr/web/javascript/reference/errors/resulting_string_too_large/index.md @@ -1,5 +1,5 @@ --- -title: 'RangeError: repeat count must be less than infinity' +title: "RangeError: repeat count must be less than infinity" slug: Web/JavaScript/Reference/Errors/Resulting_string_too_large translation_of: Web/JavaScript/Reference/Errors/Resulting_string_too_large --- @@ -29,17 +29,17 @@ La chaîne de caractères crée par cette méthode ne doit pas dépasser la tail ### Exemples invalides ```js example-bad -'abc'.repeat(Infinity); // RangeError -'a'.repeat(2**28); // RangeError +"abc".repeat(Infinity); // RangeError +"a".repeat(2 ** 28); // RangeError ``` ### Exemples valides ```js example-good -'abc'.repeat(0); // '' -'abc'.repeat(1); // 'abc' -'abc'.repeat(2); // 'abcabc' -'abc'.repeat(3.5); // 'abcabcabc' (count will be converted to integer) +"abc".repeat(0); // '' +"abc".repeat(1); // 'abc' +"abc".repeat(2); // 'abcabc' +"abc".repeat(3.5); // 'abcabcabc' (count will be converted to integer) ``` ## Voir aussi diff --git a/files/fr/web/javascript/reference/errors/stmt_after_return/index.md b/files/fr/web/javascript/reference/errors/stmt_after_return/index.md index 4deafa13b6ca36..28a1d11340c1cc 100644 --- a/files/fr/web/javascript/reference/errors/stmt_after_return/index.md +++ b/files/fr/web/javascript/reference/errors/stmt_after_return/index.md @@ -1,5 +1,5 @@ --- -title: 'Warning: unreachable code after return statement' +title: "Warning: unreachable code after return statement" slug: Web/JavaScript/Reference/Errors/Stmt_after_return translation_of: Web/JavaScript/Reference/Errors/Stmt_after_return --- @@ -42,13 +42,13 @@ Les avertissements ne seront pas affichés pour les `return` sans point-virgule function f() { var x = 3; x += 4; - return x; // return permet de finir la fonction sur le champ - x -= 3; // Cette ligne ne sera jamais lue donc exécutée + return x; // return permet de finir la fonction sur le champ + x -= 3; // Cette ligne ne sera jamais lue donc exécutée } function f() { - return // Cette instruction est traitée `return;` - 3 + 4; // La fonction termine et cette ligne n'est jamais traitée + return; // Cette instruction est traitée `return;` + 3 + 4; // La fonction termine et cette ligne n'est jamais traitée } ``` @@ -59,13 +59,13 @@ function f() { var x = 3; x += 4; x -= 3; - return x; // OK : return est après - // toutes les autres instructions + return x; // OK : return est après + // toutes les autres instructions } function f() { - return 3 + 4 // OK : un return sans point-virgule - // avec une expression sur la même ligne + return 3 + 4; // OK : un return sans point-virgule + // avec une expression sur la même ligne } ``` diff --git a/files/fr/web/javascript/reference/errors/strict_non_simple_params/index.md b/files/fr/web/javascript/reference/errors/strict_non_simple_params/index.md index 901f43ead02a07..fd1f1b845b800a 100644 --- a/files/fr/web/javascript/reference/errors/strict_non_simple_params/index.md +++ b/files/fr/web/javascript/reference/errors/strict_non_simple_params/index.md @@ -73,7 +73,7 @@ var somme = function somme([a, b]) { On peut convertir le fragment de code précédent avec l'expression suivante : ```js example-good -var somme = (function() { +var somme = (function () { "use strict"; return function somme([a, b]) { return a + b; diff --git a/files/fr/web/javascript/reference/errors/too_much_recursion/index.md b/files/fr/web/javascript/reference/errors/too_much_recursion/index.md index 7a30970f7a7452..c864c85a98716f 100644 --- a/files/fr/web/javascript/reference/errors/too_much_recursion/index.md +++ b/files/fr/web/javascript/reference/errors/too_much_recursion/index.md @@ -1,5 +1,5 @@ --- -title: 'InternalError: too much recursion' +title: "InternalError: too much recursion" slug: Web/JavaScript/Reference/Errors/Too_much_recursion translation_of: Web/JavaScript/Reference/Errors/Too_much_recursion --- @@ -30,8 +30,10 @@ Cette fonction récursive est exécutée 10 fois comme l'indique la condition de ```js function loop(x) { - if (x >= 10) // "x >= 10" is the exit condition + if (x >= 10) { + // "x >= 10" is the exit condition return; + } // do stuff loop(x + 1); // the recursive call } @@ -42,8 +44,9 @@ Si la condition d'arrêt est beaucoup trop grande, cela ne fonctionnera pas : ```js example-bad function loop(x) { - if (x >= 1000000000000) + if (x >= 1000000000000) { return; + } // do stuff loop(x + 1); } From 18e37f401870f090f25b6a6fc1aece0ffdad0ac1 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 01:41:11 -0700 Subject: [PATCH 07/30] fr: Format /web/javascript using Prettier (part 2) (#14640) --- .prettierignore | 1 + .../errors/unexpected_token/index.md | 19 +- .../reference/errors/unexpected_type/index.md | 7 +- .../unnamed_function_statement/index.md | 12 +- .../index.md | 16 +- .../unterminated_string_literal/index.md | 12 +- .../functions/arguments/@@iterator/index.md | 4 +- .../functions/arguments/callee/index.md | 55 +-- .../reference/functions/arguments/index.md | 17 +- .../functions/arguments/length/index.md | 18 +- .../functions/arrow_functions/index.md | 89 ++-- .../functions/default_parameters/index.md | 72 ++-- .../reference/functions/get/index.md | 29 +- .../javascript/reference/functions/index.md | 395 +++++++++--------- .../functions/method_definitions/index.md | 56 +-- .../functions/rest_parameters/index.md | 14 +- .../reference/functions/set/index.md | 22 +- .../aggregateerror/aggregateerror/index.md | 14 +- .../global_objects/aggregateerror/index.md | 20 +- .../global_objects/array/@@iterator/index.md | 8 +- .../global_objects/array/@@species/index.md | 6 +- .../array/@@unscopables/index.md | 4 +- .../global_objects/array/array/index.md | 10 +- .../global_objects/array/at/index.md | 18 +- .../global_objects/array/concat/index.md | 2 +- .../global_objects/array/copywithin/index.md | 133 +++--- .../global_objects/array/entries/index.md | 4 +- .../global_objects/array/every/index.md | 26 +- .../global_objects/array/fill/index.md | 50 +-- .../global_objects/array/filter/index.md | 63 +-- .../global_objects/array/find/index.md | 32 +- .../global_objects/array/findindex/index.md | 16 +- .../global_objects/array/findlast/index.md | 16 +- .../array/findlastindex/index.md | 4 +- .../global_objects/array/flat/index.md | 6 +- .../global_objects/array/flatmap/index.md | 12 +- .../global_objects/array/foreach/index.md | 32 +- .../global_objects/array/from/index.md | 19 +- .../global_objects/array/group/index.md | 12 +- .../global_objects/array/grouptomap/index.md | 16 +- .../global_objects/array/includes/index.md | 36 +- .../reference/global_objects/array/index.md | 81 ++-- .../global_objects/array/indexof/index.md | 35 +- .../global_objects/array/isarray/index.md | 22 +- .../global_objects/array/join/index.md | 14 +- .../global_objects/array/keys/index.md | 6 +- .../global_objects/array/lastindexof/index.md | 28 +- .../global_objects/array/length/index.md | 10 +- .../global_objects/array/map/index.md | 31 +- .../global_objects/array/of/index.md | 18 +- .../global_objects/array/pop/index.md | 14 +- .../global_objects/array/push/index.md | 22 +- .../global_objects/array/reduce/index.md | 87 ++-- .../global_objects/array/reduceright/index.md | 50 ++- .../global_objects/array/reverse/index.md | 6 +- .../global_objects/array/shift/index.md | 4 +- .../global_objects/array/slice/index.md | 6 +- .../global_objects/array/some/index.md | 6 +- .../global_objects/array/sort/index.md | 75 ++-- .../global_objects/array/splice/index.md | 2 +- .../array/tolocalestring/index.md | 24 +- .../global_objects/array/tostring/index.md | 2 +- .../global_objects/array/unshift/index.md | 2 +- .../global_objects/array/values/index.md | 8 +- .../arraybuffer/@@species/index.md | 6 +- .../arraybuffer/arraybuffer/index.md | 2 +- .../arraybuffer/bytelength/index.md | 2 +- .../arraybuffer/isview/index.md | 16 +- .../global_objects/arraybuffer/slice/index.md | 2 +- .../global_objects/asyncfunction/index.md | 24 +- .../global_objects/atomics/add/index.md | 4 +- .../global_objects/atomics/and/index.md | 4 +- .../atomics/compareexchange/index.md | 4 +- .../global_objects/atomics/exchange/index.md | 6 +- .../atomics/islockfree/index.md | 4 +- .../global_objects/atomics/load/index.md | 2 +- .../global_objects/atomics/notify/index.md | 2 +- .../global_objects/atomics/or/index.md | 4 +- .../global_objects/atomics/store/index.md | 10 +- .../global_objects/atomics/sub/index.md | 4 +- .../global_objects/atomics/waitasync/index.md | 6 +- .../global_objects/atomics/xor/index.md | 4 +- .../reference/global_objects/bigint/index.md | 58 +-- .../bigint/tolocalestring/index.md | 20 +- .../global_objects/bigint/tostring/index.md | 14 +- .../global_objects/bigint/valueof/index.md | 2 +- .../bigint64array/bigint64array/index.md | 6 +- .../global_objects/bigint64array/index.md | 6 +- .../biguint64array/biguint64array/index.md | 6 +- .../global_objects/biguint64array/index.md | 6 +- .../global_objects/boolean/boolean/index.md | 12 +- .../reference/global_objects/boolean/index.md | 24 +- .../global_objects/boolean/tostring/index.md | 2 +- .../global_objects/boolean/valueof/index.md | 4 +- .../global_objects/dataview/buffer/index.md | 2 +- .../dataview/bytelength/index.md | 2 +- .../dataview/byteoffset/index.md | 2 +- .../global_objects/dataview/dataview/index.md | 6 +- .../global_objects/dataview/getint8/index.md | 2 +- .../global_objects/dataview/getuint8/index.md | 2 +- 100 files changed, 1189 insertions(+), 1043 deletions(-) diff --git a/.prettierignore b/.prettierignore index 656b66a2d9a702..673b43dfe86422 100644 --- a/.prettierignore +++ b/.prettierignore @@ -24,6 +24,7 @@ build/ /files/fr/web/css/justify-content/index.md /files/fr/web/css/place-items/index.md /files/fr/web/css/place-self/index.md +/files/fr/web/javascript/reference/global_objects/array/includes/index.md /files/pt-br/learn/server-side/django/forms/index.md /files/ru/learn/server-side/django/forms/index.md /files/ru/learn/server-side/django/introduction/index.md diff --git a/files/fr/web/javascript/reference/errors/unexpected_token/index.md b/files/fr/web/javascript/reference/errors/unexpected_token/index.md index 2741d80673f526..ff00ef8b52382b 100644 --- a/files/fr/web/javascript/reference/errors/unexpected_token/index.md +++ b/files/fr/web/javascript/reference/errors/unexpected_token/index.md @@ -1,5 +1,5 @@ --- -title: 'SyntaxError: Unexpected token' +title: "SyntaxError: Unexpected token" slug: Web/JavaScript/Reference/Errors/Unexpected_token translation_of: Web/JavaScript/Reference/Errors/Unexpected_token --- @@ -66,12 +66,19 @@ Si on compte les parenthèses ouvrantes et fermantes, c'est correct mais on peut Pour corriger ce problème, il suffit d'ajouter une paire de parenthèses englobante : ```js example-good -function round(n, upperBound, lowerBound){ - if((n > upperBound) || (n < lowerBound)){ - throw 'Number ' + String(n) + ' is more than ' + String(upperBound) + ' or less than ' + String(lowerBound); - }else if(n < ((upperBound + lowerBound)/2)){ +function round(n, upperBound, lowerBound) { + if (n > upperBound || n < lowerBound) { + throw ( + "Number " + + String(n) + + " is more than " + + String(upperBound) + + " or less than " + + String(lowerBound) + ); + } else if (n < (upperBound + lowerBound) / 2) { return lowerBound; - }else{ + } else { return upperBound; } } diff --git a/files/fr/web/javascript/reference/errors/unexpected_type/index.md b/files/fr/web/javascript/reference/errors/unexpected_type/index.md index cbaf71456f6d8a..9164195d72b4c7 100644 --- a/files/fr/web/javascript/reference/errors/unexpected_type/index.md +++ b/files/fr/web/javascript/reference/errors/unexpected_type/index.md @@ -47,13 +47,12 @@ toto.substring(1); // TypeError: toto is undefined var toto = null; toto.substring(1); // TypeError: toto is null - // Certaines méthodes nécessitent une valeur // d'un type spécifique -var toto = {} +var toto = {}; Symbol.keyFor(toto); // TypeError: toto is not a symbol -var toto = "truc" +var toto = "truc"; Object.create(toto); // TypeError: "toto" is not an object or null ``` @@ -62,7 +61,7 @@ Object.create(toto); // TypeError: "toto" is not an object or null Pour résoudre ce problème et écarter les cas où la valeur vaut `undefined`, on peut par exemple utiliser l'opérateur [`typeof`](/fr/docs/Web/JavaScript/Reference/Opérateurs/L_opérateur_typeof). ```js -if (typeof toto !== 'undefined') { +if (typeof toto !== "undefined") { // Désormais, on sait que toto est bien // défini et on peut poursuivre. } diff --git a/files/fr/web/javascript/reference/errors/unnamed_function_statement/index.md b/files/fr/web/javascript/reference/errors/unnamed_function_statement/index.md index 28d715f271b318..496189571b6110 100644 --- a/files/fr/web/javascript/reference/errors/unnamed_function_statement/index.md +++ b/files/fr/web/javascript/reference/errors/unnamed_function_statement/index.md @@ -1,5 +1,5 @@ --- -title: 'SyntaxError: function statement requires a name' +title: "SyntaxError: function statement requires a name" slug: Web/JavaScript/Reference/Errors/Unnamed_function_statement translation_of: Web/JavaScript/Reference/Errors/Unnamed_function_statement --- @@ -38,17 +38,15 @@ function () { On peut utiliser [une expression de fonction](/fr/docs/Web/JavaScript/Reference/Opérateurs/L_opérateur_function) à la place : ```js example-good -var salutations = function() { - return 'Coucou monde :)'; +var salutations = function () { + return "Coucou monde :)"; }; ``` Si la fonction devait être appelé immédiatement, il suffit d'ajouter des parenthèses autour : ```js example-good -(function () { - -})(); +(function () {})(); ``` ### Fonctions étiquetées @@ -82,7 +80,7 @@ Si vous souhaitez construire une méthode d'un objet, il faudra d'abord créer l var greeter = { german: function () { return "Moin"; - } + }, }; ``` diff --git a/files/fr/web/javascript/reference/errors/unparenthesized_unary_expr_lhs_exponentiation/index.md b/files/fr/web/javascript/reference/errors/unparenthesized_unary_expr_lhs_exponentiation/index.md index e18cc310abec49..904907825bc711 100644 --- a/files/fr/web/javascript/reference/errors/unparenthesized_unary_expr_lhs_exponentiation/index.md +++ b/files/fr/web/javascript/reference/errors/unparenthesized_unary_expr_lhs_exponentiation/index.md @@ -31,18 +31,18 @@ Cela provient vraisemblablement d'une écriture comme celle-ci : Ici, l'expression est ambigüe et on ne sait pas si elle devrait être évaluée comme `(-a) ** b` ou comme `-(a ** b)`. En mathématiques, l'écriture -x2 signifie `-(x ** 2)`, et c'est ainsi que de nombreux langages de programmation, comme Python, Haskell, et PHP, gèrent cette évaluation. Mais si la précédence de l'opérateur unaire moins l'emporte sur `**`, cela casse la symétrie avec `a ** -b`, qui s'évalue sans ambigüité comme `a ** (-b)`. Aussi, le langage interdit cette syntaxe et impose d'utiliser des parenthèses d'un côté ou de l'autre pour résoudre l'ambigüité. -```js example-good -(-a) ** b --(a ** b) +```js-nolint example-good +(-a) ** b; +-(a ** b); ``` D'autres opérateurs unaires ne peuvent pas être utilisés sur l'opérande gauche non plus. ```js example-bad -await a ** b -!a ** b -+a ** b -~a ** b +await a ** b; +!a ** b; ++a ** b; +~a ** b; ``` ## Exemples @@ -60,7 +60,7 @@ Toutefois, le fragment `-1 ** n` est illégal en JavaScript. À la place, on uti ```js example-good function taylorSin(x) { - return (n) => (-1) ** n * x ** (2 * n + 1) / factorial(2 * n + 1); + return (n) => ((-1) ** n * x ** (2 * n + 1)) / factorial(2 * n + 1); } ``` diff --git a/files/fr/web/javascript/reference/errors/unterminated_string_literal/index.md b/files/fr/web/javascript/reference/errors/unterminated_string_literal/index.md index 791061d5882490..9fc638d9dba689 100644 --- a/files/fr/web/javascript/reference/errors/unterminated_string_literal/index.md +++ b/files/fr/web/javascript/reference/errors/unterminated_string_literal/index.md @@ -1,5 +1,5 @@ --- -title: 'SyntaxError: unterminated string literal' +title: "SyntaxError: unterminated string literal" slug: Web/JavaScript/Reference/Errors/Unterminated_string_literal translation_of: Web/JavaScript/Reference/Errors/Unterminated_string_literal --- @@ -47,15 +47,17 @@ Pour écrire une chaîne sur plusieurs lignes, on pourra utiliser : Voici la première variante avec l'opérateur de concaténation : ```js example-good -var longString = "This is a very long string which needs " + - "to wrap across multiple lines because " + - "otherwise my code is unreadable."; +var longString = + "This is a very long string which needs " + + "to wrap across multiple lines because " + + "otherwise my code is unreadable."; ``` Sinon, on peut utiliser une barre oblique inversée à la fin de chaque ligne pour indiquer qu'elle continue sur la ligne suivante. Attention, il faudra qu'il n'y ait aucun espace ou autre caractère après la barre oblique (il peut bien entendu y avoir un saut de ligne) : ```js example-good -var longString = "This is a very long string which needs \ +var longString = + "This is a very long string which needs \ to wrap across multiple lines because \ otherwise my code is unreadable."; ``` diff --git a/files/fr/web/javascript/reference/functions/arguments/@@iterator/index.md b/files/fr/web/javascript/reference/functions/arguments/@@iterator/index.md index ffc5055ba994e1..0eddbdadba358f 100644 --- a/files/fr/web/javascript/reference/functions/arguments/@@iterator/index.md +++ b/files/fr/web/javascript/reference/functions/arguments/@@iterator/index.md @@ -11,7 +11,7 @@ La valeur initiale de la propriété **`@@iterator`** est le même objet que la ## Syntaxe ```js -arguments[Symbol.iterator]() +arguments[Symbol.iterator](); ``` ## Exemples @@ -27,7 +27,7 @@ function f() { console.log(letter); } } -f('w', 'y', 'k', 'o', 'p'); +f("w", "y", "k", "o", "p"); ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/functions/arguments/callee/index.md b/files/fr/web/javascript/reference/functions/arguments/callee/index.md index 5195417a1e79b9..693418a64a26ee 100644 --- a/files/fr/web/javascript/reference/functions/arguments/callee/index.md +++ b/files/fr/web/javascript/reference/functions/arguments/callee/index.md @@ -23,26 +23,26 @@ Aux débuts de JavaScript, il n'était pas possible d'utiliser des expressions d Cette syntaxe produisait le résultat escompté : ```js -function factorielle (n) { - return !(n > 1) ? 1 : factorielle(n - 1) * n; +function factorielle(n) { + return !(n > 1) ? 1 : factorielle(n - 1) * n; } -[1,2,3,4,5].map(factorielle); +[1, 2, 3, 4, 5].map(factorielle); ``` mais : ```js -[1,2,3,4,5].map(function (n) { - return !(n > 1) ? 1 : /* que met-on ici ? */ (n - 1) * n; +[1, 2, 3, 4, 5].map(function (n) { + return !(n > 1) ? 1 : /* que met-on ici ? */ (n - 1) * n; }); ``` ne fonctionnait pas. Pour que cela puisse fonctionner, on ajouta `arguments.callee` : ```js -[1,2,3,4,5].map(function (n) { - return !(n > 1) ? 1 : arguments.callee(n - 1) * n; +[1, 2, 3, 4, 5].map(function (n) { + return !(n > 1) ? 1 : arguments.callee(n - 1) * n; }); ``` @@ -52,13 +52,15 @@ Cependant, ce fut une mauvaise solution (avec `caller` également) car elle rend var global = this; var fonctionTruc = function (recursed) { - if (!recursed) { return arguments.callee(true); } - if (this !== global) { - console.log("this est : " + this); - } else { - console.log("this est la variable globale"); - } -} + if (!recursed) { + return arguments.callee(true); + } + if (this !== global) { + console.log("this est : " + this); + } else { + console.log("this est la variable globale"); + } +}; fonctionTruc(); ``` @@ -66,8 +68,8 @@ fonctionTruc(); ECMAScript 3 a introduit les expressions de fonctions nommées pour résoudre le problème. On peut désormais utiliser : ```js -[1,2,3,4,5].map(function factorielle (n) { - return !(n > 1) ? 1 : factorielle(n - 1)*n; +[1, 2, 3, 4, 5].map(function factorielle(n) { + return !(n > 1) ? 1 : factorielle(n - 1) * n; }); ``` @@ -80,7 +82,9 @@ Cette méthode possède plusieurs avantages : Une autre fonctionnalité qui a été déprécié est : `arguments.callee.caller`, ou plus précisément `Function.caller`. Pourquoi cela ? Parce que ça permet d'avoir accès à tout moment à la fonction appelante la plus loin dans la pile d'appels. Or, comme évoqué ci-avant, cela a un effet de bord considérable : ça rend beaucoup plus complexes voire impossibles certaines optimisations. Ainsi, on ne peut pas garantir qu'une fonction `f` n'appellera pas une autre fonction inconnue, ce qui signifie qu'on ne peut pas utiliser l'extension inline. En résumé, cela signifie que n'importe quel site d'appel de fonction (_call site_) qui aurait pu être développé inline très simplement devra subir de nombreux tests : ```js -function f (a, b, c, d, e) { return a ? b * c : d * e; } +function f(a, b, c, d, e) { + return a ? b * c : d * e; +} ``` Si l'interpréteur JavaScript ne peut pas garantir que l'ensemble des arguments fournis ici sont des nombres à l'instant de l'appel de la fonction, il devra insérer des vérifications pour chaque argument avant le code inline, sinon il ne pourra pas développer la fonction inline. On notera que, dans ce cas, un interpréteur intelligent devrait pouvoir réarranger les vérifications à faire afin qu'elles soient optimales et de se débarrasser des valeurs inutiles. Malgré tout, une telle optimisation ne sera pas possible dans d'autres cas, ce qui signifie que le développement inline n'est pas possible. @@ -95,11 +99,10 @@ L'exemple qui suit illustre une fonction qui définit et renvoie une fonction fa ```js function créer() { - return function(n) { - if (n <= 1) - return 1; - return n * arguments.callee(n - 1); - }; + return function (n) { + if (n <= 1) return 1; + return n * arguments.callee(n - 1); + }; } var résultat = create()(5); // renvoie 120 (5 * 4 * 3 * 2 * 1) @@ -110,10 +113,10 @@ var résultat = create()(5); // renvoie 120 (5 * 4 * 3 * 2 * 1) Malgré tout, dans un cas comme le suivant, il n'existe pas d'équivalent pour `arguments.callee`, c'est pourquoi sa déprécation pourrait être un bug (voir [bug Firefox 725398](https://bugzil.la/725398)): ```js -function créerPersonne (sIdentité) { - var oPersonne = new Function("alert(arguments.callee.identité);"); - oPersonne.identité = sIdentité; - return oPersonne; +function créerPersonne(sIdentité) { + var oPersonne = new Function("alert(arguments.callee.identité);"); + oPersonne.identité = sIdentité; + return oPersonne; } var jean = créerPersonne("Jean Biche"); diff --git a/files/fr/web/javascript/reference/functions/arguments/index.md b/files/fr/web/javascript/reference/functions/arguments/index.md index d5e23d44b96995..7a61c937869ac9 100644 --- a/files/fr/web/javascript/reference/functions/arguments/index.md +++ b/files/fr/web/javascript/reference/functions/arguments/index.md @@ -19,7 +19,7 @@ L'objet **`arguments`** est un objet, **semblable** à un tableau, correspondant ## Syntaxe ```js -arguments +arguments; ``` ## Description @@ -29,15 +29,15 @@ L'objet `arguments` est une variable locale (intrinsèque et inhérente aux fonc Vous pouvez accéder aux arguments d'une fonction à l'intérieur de celle-ci en utilisant l'objet `arguments`. Cet objet contient une entrée pour chaque argument passé à la fonction, l'indice de la première entrée commençant à 0. Par exemple, si une fonction est appelée avec trois arguments, on accède à ceux-ci comme suit : ```js -arguments[0] -arguments[1] -arguments[2] +arguments[0]; +arguments[1]; +arguments[2]; ``` Les arguments peuvent aussi être modifiés : ```js -arguments[1] = 'nouvelle valeur'; +arguments[1] = "nouvelle valeur"; ``` ### Type de l'objet `arguments` et liens avec `Array` @@ -64,7 +64,8 @@ var args = [...arguments]; > **Attention :** Il est déconseillé d'utiliser `slice` sur les arguments car cela peut empêcher certaines optimisations des moteurs JavaScript. Pour ce scénario, on peut par exemple construire un nouveau tableau en parcourant l'objet arguments (à ce sujet, voir [cette page](https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments) sur les contraintes d'optimisations liées à V8). Pour cet exemple, on pourra utiliser `Array.apply` : > > ```js -> var args = (arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments)); +> var args = +> arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments); > ``` L'objet `arguments` est disponible uniquement dans le corps d'une fonction. Tenter d'accéder à l'objet `arguments` en dehors de la déclaration d'une fonction renvoie une erreur. @@ -160,7 +161,7 @@ toto(1, 2, 3); // [1, 2, 3] Toutefois, pour les fonctions utilisées en mode non-strict, un **objet `arguments`** n'est fourni à l'intérieur de la fonction uniquement si celle-ci n'utilise pas de [paramètres du reste](/fr/docs/Web/JavaScript/Reference/Fonctions/paramètres_du_reste), pas de [paramètres par défaut](/fr/docs/Web/JavaScript/Reference/Fonctions/Valeurs_par_défaut_des_arguments) ou de [paramètre décomposé](/fr/docs/Web/JavaScript/Reference/Opérateurs/Affecter_par_décomposition). Par exemple, dans la fonction suivante, qui utilise un paramètre par défaut, ce sera 10 qui sera renvoyé (et non 100) : ```js -function truc(a=1) { +function truc(a = 1) { arguments[0] = 100; return a; } @@ -183,7 +184,7 @@ En fait, lorsqu'il n'y a aucun paramètre du reste, paramètre par défaut ou au function func(a, b) { arguments[0] = 99; arguments[1] = 99; - console.log(a + " " +b); + console.log(a + " " + b); } func(1, 2); // 99 99 diff --git a/files/fr/web/javascript/reference/functions/arguments/length/index.md b/files/fr/web/javascript/reference/functions/arguments/length/index.md index 86da01aba54abb..400ad51f08acb3 100644 --- a/files/fr/web/javascript/reference/functions/arguments/length/index.md +++ b/files/fr/web/javascript/reference/functions/arguments/length/index.md @@ -11,7 +11,7 @@ La propriété **`arguments.length`** contient le nombre d'arguments passés à ## Syntaxe ```js -arguments.length +arguments.length; ``` ## Description @@ -26,18 +26,18 @@ Dans cet exemple, on définit une fonction qui permet d'additionner plusieurs no ```js function somme(x /*, y, z, ...*/) { - x = Number(x); - for (var i = 1; i < arguments.length; i++) { - x += Number(arguments[i]); - } - return x; + x = Number(x); + for (var i = 1; i < arguments.length; i++) { + x += Number(arguments[i]); + } + return x; } ``` ```js -résultat = somme(3, 4, 5); // renvoie 12 -résultat = somme(3, 4); // renvoie 7 -résultat = somme(103, 104, 105); // renvoie 312 +résultat = somme(3, 4, 5); // renvoie 12 +résultat = somme(3, 4); // renvoie 7 +résultat = somme(103, 104, 105); // renvoie 312 ``` > **Note :** `arguments.length` ne doit pas être confondu avec {{jsxref("Function.length")}}. diff --git a/files/fr/web/javascript/reference/functions/arrow_functions/index.md b/files/fr/web/javascript/reference/functions/arrow_functions/index.md index 1d536600a7c174..17486a231a98e6 100644 --- a/files/fr/web/javascript/reference/functions/arrow_functions/index.md +++ b/files/fr/web/javascript/reference/functions/arrow_functions/index.md @@ -65,15 +65,17 @@ var a = [ "We're up all night 'til the sun", "We're up all night to get some", "We're up all night for good fun", - "We're up all night to get lucky" + "We're up all night to get lucky", ]; // Sans la syntaxe des fonctions fléchées -var a2 = a.map(function (s) { return s.length }); +var a2 = a.map(function (s) { + return s.length; +}); // [31, 30, 31, 31] // Avec, on a quelque chose de plus concis -var a3 = a.map( s => s.length); +var a3 = a.map((s) => s.length); // [31, 30, 31, 31] ``` @@ -88,11 +90,11 @@ Jusqu'a l'apparition des fonctions fléchées, chaque nouvelle fonction définis Cela a pu entraîner des confusions lorsqu'on utilisait un style de programmation orientée objet. ```js -function Personne () { +function Personne() { // Le constructeur Personne() définit `this` comme lui-même. this.age = 0; - setInterval(function grandir () { + setInterval(function grandir() { // En mode non strict, la fonction grandir() définit `this` // comme l'objet global et pas comme le `this` defini // par le constructeur Personne(). @@ -106,11 +108,11 @@ var p = new Personne(); Avec ECMAScript 3/5, ce problème a pu être résolu en affectant la valeur de `this` à une autre variable : ```js -function Personne () { +function Personne() { var that = this; that.age = 0; - setInterval(function grandir () { + setInterval(function grandir() { // La fonction callback se réfère à la variable `that` // qui est le contexte souhaité that.age++; @@ -123,7 +125,7 @@ Autrement, on aurait pu utiliser une [fonction de liaison](/fr/docs/Web/JavaScri Les fonctions fléchées ne créent pas de nouveau contexte, elles utilisent la valeur `this` de leur contexte. Aussi, si le mot-clé `this` est utilisé dans le corps de la fonction, le moteur recherchera la référence à cette valeur dans une portée parente. Le code qui suit fonctionne ainsi de la façon attendue car le `this` utilisé dans `setInterval` est le `this` de la portée de `Personne` : ```js -function Personne () { +function Personne() { this.age = 0; setInterval(() => { @@ -140,7 +142,10 @@ var p = new Personne(); Ici `this` provient du contexte englobant, les règles du [mode strict](/fr/docs/Web/JavaScript/Reference/Fonctions_et_portee_des_fonctions/Strict_mode) sont donc ignorées pour ce qui concerne `this`. ```js -var f = () => {'use strict'; return this}; +var f = () => { + "use strict"; + return this; +}; f() === window; // ou l'objet global ``` @@ -154,18 +159,18 @@ Le reste des règles du mode strict sont appliquées normalement. var ajouter = { base: 1, - add : function (a) { - var f = v => v + this.base; + add: function (a) { + var f = (v) => v + this.base; return f(a); }, addViaCall: function (a) { - var f = v => v + this.base; + var f = (v) => v + this.base; var b = { - base: 2 + base: 2, }; return f.call(b, a); - } + }, }; console.log(ajouter.add(1)); @@ -185,7 +190,7 @@ var arr = () => arguments[0]; arr(); // 1 -function toto () { +function toto() { var f = (i) => arguments[0] + i; // lien implicite avec arguments de toto return f(2); @@ -197,7 +202,7 @@ toto(3); // 5 Les fonctions fléchées n'ont donc pas leur propre objet `arguments`, mais dans la plupart des cas, [les paramètres du reste](/fr/docs/Web/JavaScript/Reference/Fonctions/paramètres_du_reste) représentent une bonne alternative : ```js -function toto () { +function toto() { var f = (...args) => args[0]; return f(2); } @@ -210,14 +215,14 @@ toto(1); // 2 Comme indiqué précédemment, les fonctions fléchées sont mieux indiquées pour les fonctions qui ne sont pas des méthodes. Prenons un exemple pour illustrer ce point ```js -'use strict'; +"use strict"; var objet = { i: 10, b: () => console.log(this.i, this), - c: function() { + c: function () { console.log(this.i, this); - } -} + }, +}; objet.b(); // affiche undefined, Window (ou l'objet global de l'environnement) @@ -255,10 +260,12 @@ Les fonctions fléchées peuvent avoir une syntaxe concise ou utiliser un bloc d ```js // méthode concise, retour implicite -var fonction = x => x * x; +var fonction = (x) => x * x; // bloc classique, retour explicite -var fonction = (x, y) => { return x + y; } +var fonction = (x, y) => { + return x + y; +}; ``` ## Renvoyer des littéraux objets @@ -312,49 +319,51 @@ fonctionRappel = fonctionRappel || (() => {}); // Une fonction fléchée vide renvoie undefined let vide = () => {}; -(() => "tototruc")() +(() => "tototruc")(); // exemple d'une fonction immédiatement // invoquée (IIFE en anglais) qui renvoie // "tototruc" -var simple = a => a > 15 ? 15 : a; +var simple = (a) => (a > 15 ? 15 : a); simple(16); // 15 simple(10); // 10 var complexe = (a, b) => { - if (a > b) { - return a; - } else { - return b; - } -} + if (a > b) { + return a; + } else { + return b; + } +}; var arr = [5, 6, 13, 0, 1, 18, 23]; var sum = arr.reduce((a, b) => a + b); // 66 -var even = arr.filter(v => v % 2 == 0); +var even = arr.filter((v) => v % 2 == 0); // [6, 0, 18] -var double = arr.map(v => v * 2); +var double = arr.map((v) => v * 2); // [10, 12, 26, 0, 2, 36, 46] // On peut aussi construire des chaînes // de promesses plus concises -promise.then(a => { +promise + .then((a) => { // ... -}).then(b => { + }) + .then((b) => { // ... -}); + }); // Cela permet de visualiser les // fonctions sans paramètres -setTimeout( () => { - console.log("Et voilà"); - setTimeout( () => { - console.log("ensuite…"); - }, 1); +setTimeout(() => { + console.log("Et voilà"); + setTimeout(() => { + console.log("ensuite…"); + }, 1); }, 1); ``` diff --git a/files/fr/web/javascript/reference/functions/default_parameters/index.md b/files/fr/web/javascript/reference/functions/default_parameters/index.md index 09d3825cc3bce6..1a144d88561608 100644 --- a/files/fr/web/javascript/reference/functions/default_parameters/index.md +++ b/files/fr/web/javascript/reference/functions/default_parameters/index.md @@ -26,14 +26,14 @@ Auparavant, pour définir une valeur par défaut pour un paramètre, il fallait ```js function multiplier(a, b) { - var b = (typeof b !== 'undefined') ? b : 1; + var b = typeof b !== "undefined" ? b : 1; return a * b; } multiplier(5, 2); // 10 multiplier(5, 1); // 5 -multiplier(5); // 5 +multiplier(5); // 5 ``` Grâce aux paramètres par défaut qui existent depuis ECMAScript 2015 (ES6), on peut se passer de cette vérification et alléger le code de la fonction : @@ -60,10 +60,10 @@ function test(num = 1) { console.log(typeof num); } -test(); // number (num vaut 1) -test(undefined); // number (num vaut 1 également) -test(""); // string (num vaut "") -test(null); // object (num vaut null) +test(); // number (num vaut 1) +test(undefined); // number (num vaut 1 également) +test(""); // string (num vaut "") +test(null); // object (num vaut null) ``` ### Évaluation à l'appel @@ -83,11 +83,13 @@ append(2); //[2], et non [1, 2] Cela est également valable pour les fonctions et les variables ```js -function appelQqc(truc = qqc()) { return truc } +function appelQqc(truc = qqc()) { + return truc; +} appelQqc(); //lève une ReferenceError -let qqc = () => "machin" +let qqc = () => "machin"; appelQqc(); // "machin" ``` @@ -97,14 +99,14 @@ appelQqc(); // "machin" Les paramètres déjà rencontrés dans la définition peuvent être utilisés comme paramètres par défaut dans la suite de la définition : ```js -function salutation(nom, salut, message = salut + ' ' + nom){ - return [nom, salut, message]; +function salutation(nom, salut, message = salut + " " + nom) { + return [nom, salut, message]; } -salutation('David', 'Coucou'); +salutation("David", "Coucou"); // ["David", "Coucou", "Coucou David"] -salutation('David', 'Coucou', 'Bon anniversaire !'); +salutation("David", "Coucou", "Bon anniversaire !"); // ["David", "Coucou", "Bon anniversaire !"] ``` @@ -112,39 +114,45 @@ On peut utiliser cette fonctionnalité afin de gérer beaucoup de cas aux limite ```js function go() { - return ":P" + return ":P"; } -function avecDéfaut(a, b = 5, c = b, d = go(), e = this, - f = arguments, g = this.value) { - return [a,b,c,d,e,f,g]; +function avecDéfaut( + a, + b = 5, + c = b, + d = go(), + e = this, + f = arguments, + g = this.value, +) { + return [a, b, c, d, e, f, g]; } -function sansDéfaut(a, b, c, d, e, f, g){ - switch(arguments.length){ +function sansDéfaut(a, b, c, d, e, f, g) { + switch (arguments.length) { case 0: - a + a; case 1: - b = 5 + b = 5; case 2: - c = b + c = b; case 3: d = go(); case 4: - e = this + e = this; case 5: - f = arguments + f = arguments; case 6: g = this.value; default: } - return [a,b,c,d,e,f,g]; + return [a, b, c, d, e, f, g]; } -avecDéfaut.call({value:"=^_^="}); +avecDéfaut.call({ value: "=^_^=" }); // [undefined, 5, 5, ":P", {value:"=^_^="}, arguments, "=^_^="] - -sansDéfaut.call({value:"=^_^="}); +sansDéfaut.call({ value: "=^_^=" }); // [undefined, 5, 5, ":P", {value:"=^_^="}, arguments, "=^_^="] ``` @@ -155,7 +163,9 @@ sansDéfaut.call({value:"=^_^="}); ```js // Ne fonctionnera pas, entraîne une ReferenceError. function f(a = go()) { - function go(){return ":P"} + function go() { + return ":P"; + } } ``` @@ -164,11 +174,11 @@ function f(a = go()) { Avant Gecko 26, le code suivant aurait entraîné une exception {{jsxref("SyntaxError")}}. Cela a été corrigé avec le [bug Firefox 777060](https://bugzil.la/777060). Les paramètres sont toujours ordonnés de gauche à droite et les valeurs par défaut sont surchargées s'ils viennent avant les autres paramètres : ```js -function f(x=1, y) { +function f(x = 1, y) { return [x, y]; } -f(); // [1, undefined] +f(); // [1, undefined] f(2); // [2, undefined] ``` @@ -177,7 +187,7 @@ f(2); // [2, undefined] Il est possible d'utiliser les valeurs par défaut avec [la syntaxe de décomposition](/fr/docs/Web/JavaScript/Reference/Opérateurs/Affecter_par_décomposition) : ```js -function f([x, y] = [1, 2], {z: z} = {z: 3}) { +function f([x, y] = [1, 2], { z: z } = { z: 3 }) { return x + y + z; } diff --git a/files/fr/web/javascript/reference/functions/get/index.md b/files/fr/web/javascript/reference/functions/get/index.md index 4b7d8b1166a8d8..af5defb7b49fe1 100644 --- a/files/fr/web/javascript/reference/functions/get/index.md +++ b/files/fr/web/javascript/reference/functions/get/index.md @@ -47,13 +47,12 @@ var o = { get dernier() { if (this.journal.length > 0) { return this.journal[this.journal.length - 1]; - } - else { + } else { return null; } }, - journal: ["toto","actu"] -} + journal: ["toto", "actu"], +}; console.log(o.dernier); // "actu" ``` @@ -70,11 +69,15 @@ delete o.dernier; Afin d'ajouter un accesseur à un objet qui existe déjà, on peut utiliser la méthode {{jsxref("Object.defineProperty()")}}. ```js -var o = { a:0 } +var o = { a: 0 }; -Object.defineProperty(o, "b", { get: function () { return this.a + 1; } }); +Object.defineProperty(o, "b", { + get: function () { + return this.a + 1; + }, +}); -console.log(o.b) // Utilise l'accesseur qui génère a + 1 (qui correspond à 1) +console.log(o.b); // Utilise l'accesseur qui génère a + 1 (qui correspond à 1) ``` ### Utiliser un nom de propriété calculé @@ -83,7 +86,9 @@ console.log(o.b) // Utilise l'accesseur qui génère a + 1 (qui correspond à 1) var expr = "toto"; var obj = { - get [expr]() { return "truc"; } + get [expr]() { + return "truc"; + }, }; console.log(obj.toto); // "truc" @@ -121,16 +126,18 @@ Lorsqu'on utilise `get`, la propriété sera définie sur le prototype de l'obje ```js class Exemple { get coucou() { - return 'monde'; + return "monde"; } } const obj = new Exemple(); console.log(obj.coucou); // "monde" -console.log(Object.getOwnPropertyDescriptor(obj, 'coucou')); +console.log(Object.getOwnPropertyDescriptor(obj, "coucou")); // undefined -console.log(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(obj), 'coucou')); +console.log( + Object.getOwnPropertyDescriptor(Object.getPrototypeOf(obj), "coucou"), +); // { configurable: true, enumerable: false, get: function get coucou() { return 'monde'; }, set: undefined } ``` diff --git a/files/fr/web/javascript/reference/functions/index.md b/files/fr/web/javascript/reference/functions/index.md index c4fd8e270be9e9..3731b00d778dfd 100644 --- a/files/fr/web/javascript/reference/functions/index.md +++ b/files/fr/web/javascript/reference/functions/index.md @@ -21,34 +21,33 @@ Afin de renvoyer une valeur, la fonction doit comporter une instruction {{jsxref Les paramètres donnés lors de l'appel d'une fonction sont appelés les _arguments_ de la fonction. Les arguments sont passés _par valeur_ (_by value_ en anglais). Si la fonction modifie la valeur d'un argument, ce changement ne se répercute pas en dehors de la fonction. Il existe cependant les _références_ d'objets qui sont aussi des valeurs mais qui possèdent la particularité suivante : si la fonction modifie les propriété de l'objet de la référence, ce(s) changement(s) seront perceptibles en dehors de la fonction. Prenons l'exemple suivant : ```js - /* Déclaration de la fonction 'maFonction' */ - function maFonction(monObjet) - { - monObjet.marque = "Toyota"; - } - - /* - * Déclaration de la variable 'mavoiture'; - * création et initialisation d'un nouvel objet; - * assigner une référence à 'mavoiture' - */ - var mavoiture = { - marque: "Honda", - modele: "Accord", - annee: 1998 - }; - - /* Affiche 'Honda' */ - console.log(mavoiture.marque); - - /* Passer la référence de l'objet à la fonction */ - maFonction(mavoiture); - - /* - * Affiche 'Toyota' pour valeur de la propriété 'marque' - * de l'objet. C'est ce que la fonction a changé. - */ - console.log(mavoiture.marque); +/* Déclaration de la fonction 'maFonction' */ +function maFonction(monObjet) { + monObjet.marque = "Toyota"; +} + +/* + * Déclaration de la variable 'mavoiture'; + * création et initialisation d'un nouvel objet; + * assigner une référence à 'mavoiture' + */ +var mavoiture = { + marque: "Honda", + modele: "Accord", + annee: 1998, +}; + +/* Affiche 'Honda' */ +console.log(mavoiture.marque); + +/* Passer la référence de l'objet à la fonction */ +maFonction(mavoiture); + +/* + * Affiche 'Toyota' pour valeur de la propriété 'marque' + * de l'objet. C'est ce que la fonction a changé. + */ +console.log(mavoiture.marque); ``` Le mot-clé [`this`](/fr/docs/Web/JavaScript/Reference/Opérateurs/L_opérateur_this) ne fait pas référence à la fonction en cours d'exécution. Il faut donc faire référence aux objets `Function` par leurs noms, et ce même au sein du corps de la fonction. @@ -94,17 +93,17 @@ function [nom]([param] [, param] [..., param]) { Voici un exemple d'expression de fonction **anonyme** (il n'y a pas de nom utilisé) : ```js -var maFonction = function() { +var maFonction = function () { /* instructions */ -} +}; ``` Il est également possible de fournir un nom lors de la définition afin de créer une expression de fonction **nommée** : ```js -var maFonction = function fonctionNommée(){ +var maFonction = function fonctionNommée() { /* instructions */ -} +}; ``` L'un des bénéfices d'utiliser une expression de fonction nommée est que son nom sera utilisé dans la pile d'appel lors qu'on aura une erreur. Avec le nom de la fonction, il sera plus facile de repérer l'origine de l'erreur. @@ -114,8 +113,8 @@ Comme on peut le voir, ces deux derniers exemples ne commencent pas avec le mot- Lorsque les fonctions sont utilisées une unique fois, on peut utiliser une [« expression de fonction immédiatement invoquée » (ou plus généralement appelée _IIFE_ pour _Immediately Invokable Function Expression_ en anglais)](/fr/docs/Glossaire/IIFE). ```js -(function() { - /* instruction */ +(function () { + /* instruction */ })(); ``` @@ -179,7 +178,7 @@ param => expression Comme tous les autres objets, les objets {{jsxref("Function")}} peuvent être créés grâce à l'opérateur `new` : ```js -new Function (arg1, arg2, ... argN, corpsDeLaFonction) +new Function(arg1, arg2, ...argN, corpsDeLaFonction); ``` - `arg1, arg2, ... argN` @@ -198,7 +197,7 @@ L'invocation du constructeur `Function` en tant que fonction (sans utiliser l'op Comme pour tous les autres objets, les objets {{jsxref("GeneratorFunction")}} peuvent être créés grâce à l'opérateur `new` : ```js -new GeneratorFunction (arg1, arg2, ... argN, corpsFonction) +new GeneratorFunction(arg1, arg2, ...argN, corpsFonction); ``` - `arg1, arg2, ... argN` @@ -237,7 +236,7 @@ Avec l'exemple suivant : ```js var truc = function toto() { - // instructions + // instructions }; ``` @@ -253,8 +252,8 @@ Une fonction qui s'appelle elle-même est appelée une fonction récursive. D'un var x = 0; // "x < 10" est la condition de la boucle while (x < 10) { - // faire des choses - x++; + // faire des choses + x++; } ``` @@ -262,12 +261,11 @@ peut être convertie en une fonction récursive et un appel à cette fonction : ```js function boucle(x) { - // "x >= 10" est la condition de sortie - // (et équivaut à "!(x < 10)") - if (x >= 10) - return; - // faire des choses - boucle(x + 1); // l'appel récursif + // "x >= 10" est la condition de sortie + // (et équivaut à "!(x < 10)") + if (x >= 10) return; + // faire des choses + boucle(x + 1); // l'appel récursif } boucle(0); ``` @@ -276,12 +274,13 @@ Cependant, certains algorithmes ne peuvent pas être traduits sous forme de bouc ```js function parcoursArbre(noeud) { - if (noeud == null) // - return; - // faire quelque chose avec le noeud - for (var i = 0; i < noeud.childNodes.length; i++) { - parcoursArbre(noeud.childNodes[i]); - } + if (noeud == null) + // + return; + // faire quelque chose avec le noeud + for (var i = 0; i < noeud.childNodes.length; i++) { + parcoursArbre(noeud.childNodes[i]); + } } ``` @@ -293,18 +292,17 @@ La comportement de la récursion en tant que pile peut être observée avec cet ```js function truc(i) { - if (i < 0) - return; - console.log('début :' + i); - toto(i - 1); - console.log('fin :' + i); + if (i < 0) return; + console.log("début :" + i); + toto(i - 1); + console.log("fin :" + i); } truc(3); ``` Elle produira le résultat suivant : -```js +```plain début :3 début :2 début :1 @@ -334,25 +332,25 @@ Pour résumer : L'exemple suivant, montre le cas de fonctions imbriquées : ```js -function ajouteCarres(a,b) { - function carre(x) { - return x * x; - } - return carre(a) + carre(b); +function ajouteCarres(a, b) { + function carre(x) { + return x * x; + } + return carre(a) + carre(b); } -var a = ajouteCarres(2,3); // renvoie 13 -var b = ajouteCarres(3,4); // renvoie 25 -var c = ajouteCarres(4,5); // renvoie 41 +var a = ajouteCarres(2, 3); // renvoie 13 +var b = ajouteCarres(3, 4); // renvoie 25 +var c = ajouteCarres(4, 5); // renvoie 41 ``` Étant donné que la fonction interne est une fermeture, il est possible d'appeler la fonction externe et de définir des arguments pour la fonction externe mais aussi pour la fonction interne : ```js function externe(x) { - function interne(y) { - return x + y; - } - return interne; + function interne(y) { + return x + y; + } + return interne; } var fn_interne = externe(3); var resultat = fn_interne(5); // renvoie 8 @@ -374,13 +372,13 @@ On peut l'observer avec l'exemple suivant : ```js function A(x) { - function B(y) { - function C(z) { - console.log(x + y + z); - } - C(3); - } - B(2); + function B(y) { + function C(z) { + console.log(x + y + z); + } + C(3); + } + B(2); } A(1); // crée un message d'alerte avec 6 (= 1 + 2 + 3) ``` @@ -389,7 +387,7 @@ Dans cet exemple, C accède à la variable y de B et à la variable x de A. Cela 1. `B` est une fermeture qui contient `A`, autrement dit `B` peut accéder aux arguments et aux variables de `A` 2. `C` est une fermeture qui contient `B` -3. Étant donné que la fermeture de `B` contient `A` et que celle de `C` contient `B`, `C` peut accéder à la fois aux arguments et variables de `B` _et_ `A`. Autrement dit, `C` *enchaîne les portées de* `B` et `A` dans cet ordre. +3. Étant donné que la fermeture de `B` contient `A` et que celle de `C` contient `B`, `C` peut accéder à la fois aux arguments et variables de `B` _et_ `A`. Autrement dit, `C` _enchaîne les portées de_ `B` et `A` dans cet ordre. La réciproque n'est pas vraie. `A` ne peut avoir accès à `C`, parce que `A` ne peut accéder ni aux variables ni aux arguments de `B`, or `C` est une variable de `B. C` est donc privé et seulement pour `B`. @@ -399,11 +397,11 @@ Lorsque deux arguments ou variables appartenant aux portées d'une fermeture ont ```js function externe() { - var x = 10; - function interne(x) { - return x; - } - return interne; + var x = 10; + function interne(x) { + return x; + } + return interne; } resultat = externe()(20); // renvoie 20 et non pas 10 ``` @@ -428,7 +426,7 @@ Avec ECMAScript 2015, il est possible de définir des méthodes de façon plus c ```js var obj = { toto() {}, - truc() {} + truc() {}, }; ``` @@ -438,33 +436,33 @@ Comparons les exemples suivants : 1. une fonction définie grâce au constructeur `Function` assignée à la variable `multiplier` - ```js - var multiplier = new Function("x", "y", "return x * y;"); - ``` + ```js + var multiplier = new Function("x", "y", "return x * y;"); + ``` 2. une déclaration de fonction d'une fonction appelée `multiplier` - ```js - function multiplier(x, y) { - return x * y; - } - ``` + ```js + function multiplier(x, y) { + return x * y; + } + ``` 3. une expression de fonction d'une fonction anonyme assignée à la variable `multiplier` - ```js - var multiplier = function(x, y) { - return x * y; - }; - ``` + ```js + var multiplier = function (x, y) { + return x * y; + }; + ``` 4. une expression de fonction d'une fonction nommée `fonction_nom` assignée à la variable `multiplier` - ```js - var multiplier = function function_nom(x, y) { - return x * y; - }; - ``` + ```js + var multiplier = function function_nom(x, y) { + return x * y; + }; + ``` Tous ces exemples effectuent à peu près la même chose, mais différent sur quelques points : @@ -473,7 +471,7 @@ Tous ces exemples effectuent à peu près la même chose, mais différent sur qu - le nom de la fonction ne peut être changé alors que la variable à laquelle la fonction a été assignée peut être réassignée. - le nom de la fonction ne peut-être utilisé qu'à l'intérieur du corps de la fonction. Toute tentative d'utilisation en dehors du corps de la fonction entraînera une erreur (ou `undefined` si le nom de la fonction a été déclaré auparavant avec une instruction `var`). Ainsi : - ```js + ````js var y = function x() {}; console.log(x); // renvoie une erreur ``` @@ -482,55 +480,58 @@ Tous ces exemples effectuent à peu près la même chose, mais différent sur qu La variable à laquelle est assignée la fonction est seulement limitée par rapport à la portée. La portée au sein de laquelle la fonction est déclarée est donc garantie d'être dans la portée de la variable. + ```` + - Comme le montre le quatrième exemple, le nom de la fonction peut être différent du nom de la variable à laquelle a été assignée la fonction. Les deux noms n'ont aucune relation entre eux. - Une déclaration de fonction peut aussi créer une variable avec le même nom que la fonction. Ainsi, contrairement une expression de fonction, une déclaration de fonction permet d'accéder à la fonction grâce à son nom au sein de la portée dans laquelle elle a été définie : ```js - function x() {} - console.log(x); // affichera la fonction x sérialisée en une chaîne de caractères - ``` + function x() {} + console.log(x); // affichera la fonction x sérialisée en une chaîne de caractères + ``` L'exemple qui suit montre que les noms de fonctions ne sont par liées aux variables auxquelles sont assignées les fonctions. Si une variable de fonction est assignée à une autre valeur, elle aura toujours le même nom de fonction : ```js - function toto() {} - console.log(toto); // message affichant la chaine de caractères "toto" - var truc = toto; - console.log(truc); // message affichant la chaine de caractères "toto" - ``` + function toto() {} + console.log(toto); // message affichant la chaine de caractères "toto" + var truc = toto; + console.log(truc); // message affichant la chaine de caractères "toto" + ``` - Une fonction définie grâce à « `new Function »` n'aura pas de nom de fonction. Cependant, le moteur JavaScript [SpiderMonkey](/fr/docs/SpiderMonkey), la forme sérialisée de la fonction apparaît comme si la fonction avait le nom « anonymous ». Le code `console.log(new Function())` produira : ```js - function anonymous() { - } - ``` + function anonymous() {} + ``` La fonction n'ayant pas de nom effectif, `anonymous` n'est pas une variable à laquelle on pourra accéder au sein de la fonction. Par exemple, le code qui suit produira une erreur : ```js - var toto = new Function("console.log(anonymous);"); - toto(); - ``` + var toto = new Function("console.log(anonymous);"); + toto(); + ``` - À la différence des fonctions définies par les expressions de fonction ou par le constructeur `Function`, une fonction définie par une déclaration de fonction pourra être utilisée avant la déclaration. Ainsi : ```js - toto(); // affichera TOTO ! - function toto() { - console.log('TOTO !'); - } - ``` + toto(); // affichera TOTO ! + function toto() { + console.log("TOTO !"); + } + ``` - Une fonction définie par une expression de fonction hérite de la portée courante. La fonction forme donc une fermeture. En revanche, les fonctions définies par le constructeur `Function` n'héritent que de la portée globale (portée héritée par toutes les fonctions). - Les fonctions définies par les expressions et les déclarations de fonctions ne sont analysées (parsées) qu'une seule fois. Celles définies grâce au constructeur `Function` ne le sont pas. Cela signifie que la chaîne de caractère représentant le corps de la fonction doit être analysée à chaque fois qu'elle est évaluée. Bien qu'une expression de fonction crée obligatoirement une fermeture, le corps de la fonction n'est pas parsé à nouveau. Les expressions de fonctions sont donc plus rapides que « `new Function(...)` ». Il faut donc éviter le constructeur `Function` autant que possible. Il faut cependant noter que les expressions et les déclarations imbriquées au sein d'une chaîne de caractère pour un constructeur `Function` ne sont analysées qu'une seule fois. On aura l'exemple suivant : ```js - var toto = (new Function("var truc = \'TOTO !\';\nreturn(function() {\n\tconsole.log(truc);\n});"))(); - toto(); //La partie « function() {\n\tconsole.log(truc);\n} » de la chaîne de caractères n'est pas analysée à nouveau. - ``` + var toto = new Function( + "var truc = 'TOTO !';\nreturn(function() {\n\tconsole.log(truc);\n});", + )(); + toto(); //La partie « function() {\n\tconsole.log(truc);\n} » de la chaîne de caractères n'est pas analysée à nouveau. + ``` Une déclaration de fonction peut très facilement (et souvent involontairement) être transformée en une expression de fonction. Une déclaration de fonction cesse d'en être une lorsque : @@ -538,33 +539,36 @@ Une déclaration de fonction peut très facilement (et souvent involontairement) - ou elle n'est plus un « élément source » de la fonction ou du script. Un « élément source » est une instruction non-imbriquée du script ou d'un corps de fonction. ```js - var x = 0; // élément source - if (x === 0) { // élément source - x = 10; // pas un élément source - function titi() {} // pas un élément source - } - function toto() { // élément source - var y = 20; // élément source - function truc() {} // élément source - while (y === 10) { // élément source - function machin() {} // pas un élément source - y++; // pas un élément source - } + var x = 0; // élément source + if (x === 0) { + // élément source + x = 10; // pas un élément source + function titi() {} // pas un élément source + } + function toto() { + // élément source + var y = 20; // élément source + function truc() {} // élément source + while (y === 10) { + // élément source + function machin() {} // pas un élément source + y++; // pas un élément source } - ``` + } + ``` ### Exemples ```js - // déclaration de fonction - function toto() {} +// déclaration de fonction +function toto() {} - // expression de fonction - (function truc() {}) +// expression de fonction +(function truc() {}); - // expression de fonction - var x = function bonjour() {} - ``` +// expression de fonction +var x = function bonjour() {}; +``` ```js if (x) { @@ -593,9 +597,9 @@ Dans le script qui suit, la fonction `zero` n'est jamais définie et ne peut don ```js if (0) { - function zero() { - console.log("C'est zero."); - } + function zero() { + console.log("C'est zero."); + } } ``` @@ -607,9 +611,9 @@ Bien que cette fonction ressemble à une déclaration de fonction, il s'agit en > > ```js > if (0) { -> var zero = function() { -> console.log("C'est zero"); -> } +> var zero = function () { +> console.log("C'est zero"); +> }; > } > ``` @@ -624,8 +628,8 @@ Note : Les événements font partie de la logique DOM et non de celle de JavaScr L'exemple suivant assigne une fonction au gestionnaire de l'événement « focus ». ```js -window.onfocus = function() { - document.body.style.backgroundColor = 'white'; +window.onfocus = function () { + document.body.style.backgroundColor = "white"; }; ``` @@ -639,32 +643,32 @@ Il est alors possible d'utiliser cette variable pour assigner une fonction à un 1. écrire dans les propriétés de l'évément DOM HTML - ```js - document.form1.colorButton.onclick = setBGColor; - ``` + ```js + document.form1.colorButton.onclick = setBGColor; + ``` 2. l'attribut de l'événement HTML - ```html - - ``` + ```html + + ``` - Un gestionnaire d'événement défini de cette manière sera une fonction, nommée selon l'attribut, encadré du code spécifique nécessaire. C'est pourquoi les parenthèses sont ici nécessaires (`setBGColor()` et non pas `setBGColor`). Cela est équivalent à : + Un gestionnaire d'événement défini de cette manière sera une fonction, nommée selon l'attribut, encadré du code spécifique nécessaire. C'est pourquoi les parenthèses sont ici nécessaires (`setBGColor()` et non pas `setBGColor`). Cela est équivalent à : - ```js - document.form1.colorButton.onclick = function onclick(event) { - setBGColor(); - }; - ``` + ```js + document.form1.colorButton.onclick = function onclick(event) { + setBGColor(); + }; + ``` - Il faut noter la façon dont l'objet événement est passé à la fonction en tant que paramètre `event`. Cela permet au code d'utiliser l'objet `Event` : + Il faut noter la façon dont l'objet événement est passé à la fonction en tant que paramètre `event`. Cela permet au code d'utiliser l'objet `Event` : - ```html - - ``` + ```html + + ``` Tout comme les autres propriétés faisant référence à une fonction, le gestionnaire d'événement peut agir come une méthode et `this` ferait alors référence à l'élément contenant le gestionnaire d'événement. Dans l'exemple suivant, la fonction à laquelle `onfocus` fait référence est appelée avec `this` qui a la valeur `window`. @@ -672,7 +676,7 @@ Tout comme les autres propriétés faisant référence à une fonction, le gesti window.onfocus(); ``` -Une erreur faite souvent lorsque l'on commence à utiliser JavaScript est d'ajouter des parenthèses et/ou des paramètres à la fin de la variable. Cela revient à appeler le gestionnaire d'événement lorsqu'on l'assigne. Le fait d'ajouter ces parenthèses assignera la valeur de retour du gestionnaire d'événement. Cette valeur sera souvent` undefined `dans ces cas alors que l'on aurait souhaité obtenir le gestionnaire d'événement. +Une erreur faite souvent lorsque l'on commence à utiliser JavaScript est d'ajouter des parenthèses et/ou des paramètres à la fin de la variable. Cela revient à appeler le gestionnaire d'événement lorsqu'on l'assigne. Le fait d'ajouter ces parenthèses assignera la valeur de retour du gestionnaire d'événement. Cette valeur sera souvent`undefined`dans ces cas alors que l'on aurait souhaité obtenir le gestionnaire d'événement. ```js document.form1.button1.onclick = setBGColor(); @@ -681,8 +685,8 @@ document.form1.button1.onclick = setBGColor(); Afin de passer des paramètres à un gestionnaire d'événements, le gestionnaire doit être enveloppé dans une autre fonction, comme dans l'exemple suivant : ```js -document.form1.button1.onclick = function() { - setBGColor('une valeur'); +document.form1.button1.onclick = function () { + setBGColor("une valeur"); }; ``` @@ -691,7 +695,7 @@ document.form1.button1.onclick = function() { En [mode strict](/fr/docs/Web/JavaScript/Reference/Strict_mode), à partir d'ES2015 (ES6), la portée des fonctions définies dans un bloc est limitée à ce bloc. Avant ES2015, il était interdit d'utiliser les fonctions de bloc en mode strict.. ```js -'use strict'; +"use strict"; function f() { return 1; @@ -716,9 +720,10 @@ Dans du code non-strict, les déclarations de fonctions placées dans des blocs ```js if (onDevraitDéfinirZéro) { - function zéro() { // DANGER: risque de compatibilité - console.log("Voici zéro."); - } + function zéro() { + // DANGER: risque de compatibilité + console.log("Voici zéro."); + } } ``` @@ -731,9 +736,9 @@ Une méthode plus sûre est d'utiliser des expressions de fonction : ```js var zéro; if (0) { - zéro = function() { - console.log("Voici zéro."); - }; + zéro = function () { + console.log("Voici zéro."); + }; } ``` @@ -746,12 +751,12 @@ La fonction qui suit renvoie une chaîne de caractères contenant la représenta ```js // Cette fonction renvoie une chaîne de caractères complétée par un préfixe composé de zéros function padZeros(num, totalLen) { - var numStr = num.toString(); // On initialise la valeur à renvoyer en chaîne de caractères - var numZeros = totalLen - numStr.length; // On calcule le nombre de zéros - for (var i = 1; i <= numZeros; i++) { - numStr = "0" + numStr; - } - return numStr; + var numStr = num.toString(); // On initialise la valeur à renvoyer en chaîne de caractères + var numZeros = totalLen - numStr.length; // On calcule le nombre de zéros + for (var i = 1; i <= numZeros; i++) { + numStr = "0" + numStr; + } + return numStr; } ``` @@ -759,9 +764,9 @@ Les instructions qui suivent utilisent cette fonction ```js var resultat; -resultat = padZeros(42,4); // renvoie "0042" -resultat = padZeros(42,2); // renvoie "42" -resultat = padZeros(5,4); // renvoie "0005" +resultat = padZeros(42, 4); // renvoie "0042" +resultat = padZeros(42, 2); // renvoie "42" +resultat = padZeros(5, 4); // renvoie "0005" ``` ### Déterminer si une fonction existe @@ -769,11 +774,11 @@ resultat = padZeros(5,4); // renvoie "0005" Il est possible de déterminer si oui ou non une fonction existe en utilisant l'opérateur `typeof`. Dans l'exemple qui suit, on teste pour savoir si l'objet `window` possède une propriété appelé `noFunc` qui serait une fonction. Si c'est le cas, elle sera utilisée, sinon on fera autre chose. ```js - if ('function' === typeof window.noFunc) { - // utilisation de noFunc() - } else { - // faire autre chose - } +if ("function" === typeof window.noFunc) { + // utilisation de noFunc() +} else { + // faire autre chose +} ``` Il est à noter que, dans le test `if`, on utilise une référence à `noFunc` - il n'y a pas de parenthèses après le nom de la fonction, la fonction n'est donc pas appelée. diff --git a/files/fr/web/javascript/reference/functions/method_definitions/index.md b/files/fr/web/javascript/reference/functions/method_definitions/index.md index 658fc4798f81b4..8699239bc9f18b 100644 --- a/files/fr/web/javascript/reference/functions/method_definitions/index.md +++ b/files/fr/web/javascript/reference/functions/method_definitions/index.md @@ -39,12 +39,12 @@ Le code suivant : ```js var obj = { - toto: function() { + toto: function () { /* du code */ }, - truc: function() { + truc: function () { /* du code */ - } + }, }; ``` @@ -57,7 +57,7 @@ var obj = { }, truc() { /* du code */ - } + }, }; ``` @@ -71,20 +71,18 @@ var obj = { ```js // Notation utilisant une propriété nommée (avant-ES2015) var obj2 = { - g: function*() { + g: function* () { var index = 0; - while(true) - yield index++; - } + while (true) yield index++; + }, }; // La même définition, en utilisant la notation raccourcie var obj2 = { - * g() { + *g() { var index = 0; - while(true) - yield index++; - } + while (true) yield index++; + }, }; var it = obj2.g(); @@ -101,7 +99,7 @@ console.log(it.next().value); // 1 var obj3 = { f: async function () { await une_promesse; - } + }, }; // Ici, on obtient le même résultat @@ -109,7 +107,7 @@ var obj3 = { var obj3 = { async f() { await une_promesse; - } + }, }; ``` @@ -123,17 +121,17 @@ var obj4 = { yield 1; yield 2; yield 3; - } + }, }; // Le code équivalent avec la // notation raccourcie var obj4 = { - async* f() { + async *f() { yield 1; yield 2; yield 3; - } + }, }; ``` @@ -145,12 +143,12 @@ Les définitions de méthodes ne sont pas des constructeurs et si on tente de le var obj = { méthode() {}, }; -new obj.méthode; // TypeError: obj.méthode is not a constructor +new obj.méthode(); // TypeError: obj.méthode is not a constructor var obj = { - * g() {} + *g() {}, }; -new obj.g; // TypeError: obj.g is not a constructuer (changé avec ES2016) +new obj.g(); // TypeError: obj.g is not a constructuer (changé avec ES2016) ``` ## Exemples @@ -159,8 +157,10 @@ new obj.g; // TypeError: obj.g is not a constructuer (changé avec ES2016) ```js var obj = { - a : "toto", - b(){ return this.a; } + a: "toto", + b() { + return this.a; + }, }; console.log(obj.b()); // "toto" ``` @@ -171,9 +171,15 @@ Cette notation raccourcie peut également être utilisée avec des noms de propr ```js var bar = { - toto0 : function (){return 0;}, - toto1(){return 1;}, - ["toto" + 2](){return 2;}, + toto0: function () { + return 0; + }, + toto1() { + return 1; + }, + ["toto" + 2]() { + return 2; + }, }; console.log(bar.toto0()); // 0 diff --git a/files/fr/web/javascript/reference/functions/rest_parameters/index.md b/files/fr/web/javascript/reference/functions/rest_parameters/index.md index 162d6b219ad680..2f4cfe052ada9e 100644 --- a/files/fr/web/javascript/reference/functions/rest_parameters/index.md +++ b/files/fr/web/javascript/reference/functions/rest_parameters/index.md @@ -50,7 +50,7 @@ Ces paramètres ont été introduits afin de réduire le code passe-partout souv ```js // Avant les paramètres du reste, on observait souvent ce style de code : -function f(a, b){ +function f(a, b) { var args = Array.prototype.slice.call(arguments, f.length); // ou encore var args = [].slice.call(arguments); @@ -79,8 +79,8 @@ function f(...[a, b, c]) { return a + b + c; } -f(1); // NaN (b et c valent undefined) -f(1, 2, 3); // 6 +f(1); // NaN (b et c valent undefined) +f(1, 2, 3); // 6 f(1, 2, 3, 4); // 6, le dernier paramètre n'est pas décomposé ``` @@ -88,7 +88,7 @@ Vous pouvez également accéder aux éléments des paramètres du reste : ```js function fun1(...lesArguments) { - console.log("valeur", lesArguments[0][0]); + console.log("valeur", lesArguments[0][0]); } fun1([5, 2], [5, 4]); // 5 @@ -137,7 +137,7 @@ function fun1(...lesArguments) { console.log(lesArguments.length); } -fun1(); // 0 +fun1(); // 0 fun1(5); // 1 fun1(5, 6, 7); // 3 ``` @@ -163,7 +163,7 @@ function trierParamRest(...lesArguments) { return argumentsTriés; } -console.log(trierParamRest(5,3,7,1)); // shows 1,3,5,7 +console.log(trierParamRest(5, 3, 7, 1)); // shows 1,3,5,7 function trierArguments() { var argumentsTriés = arguments.sort(); @@ -171,7 +171,7 @@ function trierArguments() { } // renvoie une exception TypeError: arguments.sort n'est pas une function -console.log(trierArguments(5,3,7,1)); +console.log(trierArguments(5, 3, 7, 1)); ``` Pour utiliser les méthodes propres aux instances d'`Array` sur l'objet `arguments`, il est nécessaire de le convertir. diff --git a/files/fr/web/javascript/reference/functions/set/index.md b/files/fr/web/javascript/reference/functions/set/index.md index 14b646b3b6ebd8..da9dbf4968e9f9 100644 --- a/files/fr/web/javascript/reference/functions/set/index.md +++ b/files/fr/web/javascript/reference/functions/set/index.md @@ -47,11 +47,11 @@ Dans l'exemple qui suit, on définit une pseudo-propriété `courant` pour un ob ```js var o = { - set courant (str) { + set courant(str) { this.log[this.log.length] = str; }, - log: [] -} + log: [], +}; ``` On notera que `courant` n'est pas défini. Toute tentative pour y accéder renverra `undefined`. @@ -69,12 +69,16 @@ delete o.courant; On peut également ajouter un mutateur sur un objet d'ores et déjà créé. Pour cela, on utilisera la méthode {{jsxref("Object.defineProperty()")}}. ```js -var o = { a:0 }; +var o = { a: 0 }; -Object.defineProperty(o, "b", { set: function (x) { this.a = x / 2; } }); +Object.defineProperty(o, "b", { + set: function (x) { + this.a = x / 2; + }, +}); o.b = 10; // On utilise le setter, qui affecte 10 / 2 (5) à 'a' -console.log(o.a) // 5 +console.log(o.a); // 5 ``` ### Utiliser un nom de propriété calculé @@ -84,11 +88,13 @@ var expr = "toto"; var obj = { bidule: "truc", - set [expr](v) { this.bidule = v; } + set [expr](v) { + this.bidule = v; + }, }; console.log(obj.bidule); // "truc" -obj.toto = "bidule"; // le mutateur est utilisé +obj.toto = "bidule"; // le mutateur est utilisé console.log(obj.bidule); // "bidule" ``` diff --git a/files/fr/web/javascript/reference/global_objects/aggregateerror/aggregateerror/index.md b/files/fr/web/javascript/reference/global_objects/aggregateerror/aggregateerror/index.md index 100a4773b84a5d..271807cb988e78 100644 --- a/files/fr/web/javascript/reference/global_objects/aggregateerror/aggregateerror/index.md +++ b/files/fr/web/javascript/reference/global_objects/aggregateerror/aggregateerror/index.md @@ -11,8 +11,8 @@ Le **constructeur `AggregateError()`** permet de créer une erreur qui agrège p ## Syntaxe ```js -new AggregateError(erreurs) -new AggregateError(erreurs, message) +new AggregateError(erreurs); +new AggregateError(erreurs, message); ``` ### Paramètres @@ -28,14 +28,12 @@ new AggregateError(erreurs, message) ```js try { - throw new AggregateError([ - new Error('une erreur'), - ], 'Coucou'); + throw new AggregateError([new Error("une erreur")], "Coucou"); } catch (e) { console.log(e instanceof AggregateError); // true - console.log(e.message); // "Coucou" - console.log(e.name); // "AggregateError" - console.log(e.errors); // [ Error: "une erreur" ] + console.log(e.message); // "Coucou" + console.log(e.name); // "AggregateError" + console.log(e.errors); // [ Error: "une erreur" ] } ``` diff --git a/files/fr/web/javascript/reference/global_objects/aggregateerror/index.md b/files/fr/web/javascript/reference/global_objects/aggregateerror/index.md index d8c79d889bc1f9..3a6e690b726bcd 100644 --- a/files/fr/web/javascript/reference/global_objects/aggregateerror/index.md +++ b/files/fr/web/javascript/reference/global_objects/aggregateerror/index.md @@ -25,13 +25,11 @@ Un objet **`AggregateError`** représente une erreur lorsque plusieurs erreurs d ### Intercepter une erreur `AggregateError` ```js -Promise.any([ - Promise.reject(new Error("une erreur")), -]).catch(e => { +Promise.any([Promise.reject(new Error("une erreur"))]).catch((e) => { console.log(e instanceof AggregateError); // true - console.log(e.message); // "All Promises rejected" - console.log(e.name); // "AggregateError" - console.log(e.errors); // [ Error: "une erreur" ] + console.log(e.message); // "All Promises rejected" + console.log(e.name); // "AggregateError" + console.log(e.errors); // [ Error: "une erreur" ] }); ``` @@ -39,14 +37,12 @@ Promise.any([ ```js try { - throw new AggregateError([ - new Error("une erreur"), - ], 'Coucou'); + throw new AggregateError([new Error("une erreur")], "Coucou"); } catch (e) { console.log(e instanceof AggregateError); // true - console.log(e.message); // "Coucou" - console.log(e.name); // "AggregateError" - console.log(e.errors); // [ Error: "une erreur" ] + console.log(e.message); // "Coucou" + console.log(e.name); // "AggregateError" + console.log(e.errors); // [ Error: "une erreur" ] } ``` diff --git a/files/fr/web/javascript/reference/global_objects/array/@@iterator/index.md b/files/fr/web/javascript/reference/global_objects/array/@@iterator/index.md index a12e4bfe0373ef..22f7740b05cd36 100644 --- a/files/fr/web/javascript/reference/global_objects/array/@@iterator/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/@@iterator/index.md @@ -11,7 +11,7 @@ La valeur initiale de la propriété **`@@iterator`** correspond à la valeur in ## Syntaxe ```js -arr[Symbol.iterator]() +arr[Symbol.iterator](); ``` ### Valeur de retour @@ -23,8 +23,8 @@ La première valeur fournie par {{jsxref("Array.prototype.values()","values()")} ### Parcourir un tableau avec une boucle `for...of` ```js -var arr = ['w', 'y', 'k', 'o', 'p']; -var eArr = arr[Symbol.iterator](); +var arr = ["w", "y", "k", "o", "p"]; +var eArr = arr[Symbol.iterator](); // il est nécessaire que l'environnement supporte // les boucles for..of et les variables // utilisées avec let ou const ou var @@ -36,7 +36,7 @@ for (let letter of eArr) { ### Parcourir un tableau avec `next` ```js -var arr = ['w', 'y', 'k', 'o', 'p']; +var arr = ["w", "y", "k", "o", "p"]; var eArr = arr[Symbol.iterator](); console.log(eArr.next().value); // w console.log(eArr.next().value); // y diff --git a/files/fr/web/javascript/reference/global_objects/array/@@species/index.md b/files/fr/web/javascript/reference/global_objects/array/@@species/index.md index e25346bfdb908f..c8b1fd9676c59c 100644 --- a/files/fr/web/javascript/reference/global_objects/array/@@species/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/@@species/index.md @@ -11,7 +11,7 @@ La propriété d'accesseur **`Array[@@species]`** renvoie le constructeur `Array ## Syntaxe ```js -Array[Symbol.species] +Array[Symbol.species]; ``` ### Valeur de retour @@ -36,7 +36,9 @@ Pour un objet dérivé, la valeur de `species` pour une classe `MonArray` sera l class MonArray extends Array { // On surcharge le symbole species // pour renvoyer le constructeur Array parent - static get [Symbol.species]() { return Array; } + static get [Symbol.species]() { + return Array; + } } ``` diff --git a/files/fr/web/javascript/reference/global_objects/array/@@unscopables/index.md b/files/fr/web/javascript/reference/global_objects/array/@@unscopables/index.md index 495024626fd01d..c485183954025f 100644 --- a/files/fr/web/javascript/reference/global_objects/array/@@unscopables/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/@@unscopables/index.md @@ -11,7 +11,7 @@ La propriété symbol **`@@unscopable`** contient les noms des propriétés qui ## Syntaxe ```js -arr[Symbol.unscopables] +arr[Symbol.unscopables]; ``` ## Description @@ -29,7 +29,7 @@ Le code qui suit fonctionne bien pour ES5 et les versions antérieures. En revan ```js var keys = []; -with(Array.prototype) { +with (Array.prototype) { keys.push("something"); } diff --git a/files/fr/web/javascript/reference/global_objects/array/array/index.md b/files/fr/web/javascript/reference/global_objects/array/array/index.md index 9a0a9af22d1a49..6cdcf84770a206 100644 --- a/files/fr/web/javascript/reference/global_objects/array/array/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/array/index.md @@ -31,10 +31,10 @@ new Array(longueurTableau) Les tableaux peuvent être créés avec une notation [littérale](/fr/docs/Web/JavaScript/Reference/Grammaire_lexicale#Littéraux_de_tableaux) : ```js -let fruits = ['Pomme', 'Banane']; +let fruits = ["Pomme", "Banane"]; console.log(fruits.length); // 2 -console.log(fruits[0]); // "Pomme" +console.log(fruits[0]); // "Pomme" ``` ### Utilisation du constructeur avec un seul paramètre @@ -45,7 +45,7 @@ On peut créer des tableaux grâce au constructeur avec un seul paramètre numé let fruits = new Array(2); console.log(fruits.length); // 2 -console.log(fruits[0]); // undefined +console.log(fruits[0]); // undefined ``` ### Utilisation du constructeur avec plusieurs paramètres @@ -53,10 +53,10 @@ console.log(fruits[0]); // undefined Si on utilise plus d'un argument, un nouveau tableau ({{jsxref("Array")}}) sera construit avec les éléments passés en arguments. ```js -let fruits = new Array('Pomme', 'Banane'); +let fruits = new Array("Pomme", "Banane"); console.log(fruits.length); // 2 -console.log(fruits[0]); // "Pomme" +console.log(fruits[0]); // "Pomme" ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/array/at/index.md b/files/fr/web/javascript/reference/global_objects/array/at/index.md index e4d4661d1e75c8..be3a49fd2c0bf0 100644 --- a/files/fr/web/javascript/reference/global_objects/array/at/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/at/index.md @@ -15,7 +15,7 @@ L'accès aux éléments d'un tableau en utilisant les crochets ne permet que d'u ## Syntaxe ```js -at(indice) +at(indice); ``` ### Paramètres @@ -35,9 +35,9 @@ L'exemple qui suit fournit une fonction qui renvoie le dernier élément trouvé ```js // Le tableau avec des éléments -const corbeille = ['pomme', 'banane', 'poire']; +const corbeille = ["pomme", "banane", "poire"]; -// Une fonction qui renvoie le dernier +// Une fonction qui renvoie le dernier // élément d'un tableau function dernierElem(arr) { return arr.at(-1); @@ -51,7 +51,7 @@ console.log(item1); // On ajoute un élément au tableau // 'corbeille' -corbeille.push('orange'); +corbeille.push("orange"); const item2 = dernierElem(corbeille); console.log(item2); // Affiche 'orange' dans la console @@ -63,22 +63,22 @@ On compare ici différentes façons d'accéder à l'avant-dernier élément d'un ```js // Un tableau de valeurs -const couleurs = ['rouge', 'vert', 'bleu']; +const couleurs = ["rouge", "vert", "bleu"]; // En utilisant la propriété length -const avecLength = couleurs[couleurs.length-2]; -console.log(avecLength); +const avecLength = couleurs[couleurs.length - 2]; +console.log(avecLength); // Affiche 'vert' dans la console // En utilisant la méthode slice() // qui renvoie un tableau const avecSlice = couleurs.slice(-2, -1); -console.log(avecSlice[0]); +console.log(avecSlice[0]); // Affiche 'vert' dans la console // En utilisant la méthode at() const avecAt = couleurs.at(-2); -console.log(avecAt); +console.log(avecAt); // Affiche 'vert' dans la console ``` diff --git a/files/fr/web/javascript/reference/global_objects/array/concat/index.md b/files/fr/web/javascript/reference/global_objects/array/concat/index.md index fc40840c6a2058..e9e26590f29e0e 100644 --- a/files/fr/web/javascript/reference/global_objects/array/concat/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/concat/index.md @@ -75,7 +75,7 @@ console.table(nums); Le code qui suit ajoute trois valeurs à un tableau : ```js -const alpha = ['a', 'b', 'c']; +const alpha = ["a", "b", "c"]; const alphanumerique = alpha.concat(1, [2, 3]); diff --git a/files/fr/web/javascript/reference/global_objects/array/copywithin/index.md b/files/fr/web/javascript/reference/global_objects/array/copywithin/index.md index 8bd832d2294da4..2018ca4b719005 100644 --- a/files/fr/web/javascript/reference/global_objects/array/copywithin/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/copywithin/index.md @@ -13,9 +13,9 @@ La méthode **`copyWithin()`** effectue une copie superficielle (_shallow copy_) ## Syntaxe ```js -arr.copyWithin(cible) -arr.copyWithin(cible, début) -arr.copyWithin(cible, début, fin) +arr.copyWithin(cible); +arr.copyWithin(cible, début); +arr.copyWithin(cible, début, fin); ``` ### Paramètres @@ -58,7 +58,7 @@ De plus, `copyWithin()` est une méthode qui modifie l'objet courant. Elle ne mo [1, 2, 3, 4, 5].copyWithin(-2, -3, -1); // [1, 2, 3, 3, 4] -[].copyWithin.call({length: 5, 3: 1}, 0, 3); +[].copyWithin.call({ length: 5, 3: 1 }, 0, 3); // {0: 1, 3: 1, length: 5} // Les tableaux typés ES2015 sont des sous-classes d'Array @@ -78,70 +78,73 @@ Cette méthode a été ajoutée à la spécification ECMAScript 6 et peut ne pas ```js if (!Array.prototype.copyWithin) { - Object.defineProperty(Array.prototype, 'copyWithin', { - value: function(target, start/*, end*/) { - // Steps 1-2. - if (this == null) { - throw new TypeError('this is null or not defined'); - } - - var O = Object(this); - - // Steps 3-5. - var len = O.length >>> 0; - - // Steps 6-8. - var relativeTarget = target >> 0; - - var to = relativeTarget < 0 ? - Math.max(len + relativeTarget, 0) : - Math.min(relativeTarget, len); - - // Steps 9-11. - var relativeStart = start >> 0; - - var from = relativeStart < 0 ? - Math.max(len + relativeStart, 0) : - Math.min(relativeStart, len); - - // Steps 12-14. - var end = arguments[2]; - var relativeEnd = end === undefined ? len : end >> 0; - - var final = relativeEnd < 0 ? - Math.max(len + relativeEnd, 0) : - Math.min(relativeEnd, len); - - // Step 15. - var count = Math.min(final - from, len - to); - - // Steps 16-17. - var direction = 1; - - if (from < to && to < (from + count)) { - direction = -1; - from += count - 1; - to += count - 1; - } - - // Step 18. - while (count > 0) { - if (from in O) { - O[to] = O[from]; - } else { - delete O[to]; + Object.defineProperty(Array.prototype, "copyWithin", { + value: function (target, start /*, end*/) { + // Steps 1-2. + if (this == null) { + throw new TypeError("this is null or not defined"); } - from += direction; - to += direction; - count--; - } + var O = Object(this); - // Step 19. - return O; - }, - configurable: true, - writable: true + // Steps 3-5. + var len = O.length >>> 0; + + // Steps 6-8. + var relativeTarget = target >> 0; + + var to = + relativeTarget < 0 + ? Math.max(len + relativeTarget, 0) + : Math.min(relativeTarget, len); + + // Steps 9-11. + var relativeStart = start >> 0; + + var from = + relativeStart < 0 + ? Math.max(len + relativeStart, 0) + : Math.min(relativeStart, len); + + // Steps 12-14. + var end = arguments[2]; + var relativeEnd = end === undefined ? len : end >> 0; + + var final = + relativeEnd < 0 + ? Math.max(len + relativeEnd, 0) + : Math.min(relativeEnd, len); + + // Step 15. + var count = Math.min(final - from, len - to); + + // Steps 16-17. + var direction = 1; + + if (from < to && to < from + count) { + direction = -1; + from += count - 1; + to += count - 1; + } + + // Step 18. + while (count > 0) { + if (from in O) { + O[to] = O[from]; + } else { + delete O[to]; + } + + from += direction; + to += direction; + count--; + } + + // Step 19. + return O; + }, + configurable: true, + writable: true, }); } ``` diff --git a/files/fr/web/javascript/reference/global_objects/array/entries/index.md b/files/fr/web/javascript/reference/global_objects/array/entries/index.md index fb524bc1fd5657..968eac043aed1e 100644 --- a/files/fr/web/javascript/reference/global_objects/array/entries/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/entries/index.md @@ -13,7 +13,7 @@ La méthode **`entries()`** renvoie un nouvel objet de type **`Array Iterator`** ## Syntaxe ```js -arr.entries() +arr.entries(); ``` ### Valeur de retour @@ -39,7 +39,7 @@ for (const [index, element] of arr.entries()) { On peut avoir le même résultat en utilisant une boucle [for...of](/fr/docs/Web/JavaScript/Reference/Instructions/for...of) : ```js -var arr = ['a', 'b', 'c']; +var arr = ["a", "b", "c"]; var eArr = arr.entries(); for (let e of eArr) { diff --git a/files/fr/web/javascript/reference/global_objects/array/every/index.md b/files/fr/web/javascript/reference/global_objects/array/every/index.md index bb44d8a1c0b998..2dcb4af83fe53e 100644 --- a/files/fr/web/javascript/reference/global_objects/array/every/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/every/index.md @@ -62,7 +62,7 @@ Dans l'exemple suivant, on teste si tous les éléments du tableau sont supérie function estAssezGrand(element, index, array) { return element >= 10; } -[12, 5, 8, 130, 44].every(estAssezGrand); // false +[12, 5, 8, 130, 44].every(estAssezGrand); // false [12, 54, 18, 130, 44].every(estAssezGrand); // true ``` @@ -71,10 +71,16 @@ function estAssezGrand(element, index, array) { {{jsxref("Fonctions/Fonctions_fléchées","Les fonctions fléchées","","1")}} permettent d'utiliser une syntaxe plus concise pour effectuer le même test. ```js -[12, 5, 8, 130, 44].every(elem => elem >= 10); // false -[12, 54, 18, 130, 44].every(elem => elem >= 10); // true -[{a:1, b:2}, {a:1, b:3}].every(elem => elem.a === 1); // true -[{a:2, b:2}, {a:1, b:3}].every(elem => elem.a === 1); // false +[12, 5, 8, 130, 44].every((elem) => elem >= 10); // false +[12, 54, 18, 130, 44].every((elem) => elem >= 10); // true +[ + { a: 1, b: 2 }, + { a: 1, b: 3 }, +].every((elem) => elem.a === 1); // true +[ + { a: 2, b: 2 }, + { a: 1, b: 3 }, +].every((elem) => elem.a === 1); // false ``` ## Prothèse d'émulation (_polyfill_) @@ -83,12 +89,12 @@ function estAssezGrand(element, index, array) { ```js if (!Array.prototype.every) { - Array.prototype.every = function(callbackfn, thisArg) { - 'use strict'; + Array.prototype.every = function (callbackfn, thisArg) { + "use strict"; var T, k; if (this == null) { - throw new TypeError('this vaut null ou n est pas défini'); + throw new TypeError("this vaut null ou n est pas défini"); } // 1. Soit O le résultat de l'appel à ToObject auquel on a @@ -102,7 +108,7 @@ if (!Array.prototype.every) { // 4. Si IsCallable(callbackfn) est faux, on lève une exception // TypeError. - if (typeof callbackfn !== 'function') { + if (typeof callbackfn !== "function") { throw new TypeError(); } @@ -116,7 +122,6 @@ if (!Array.prototype.every) { // 7. On répète tant que k < len while (k < len) { - var kValue; // a. Soit Pk la valeur de ToString(k). @@ -126,7 +131,6 @@ if (!Array.prototype.every) { // Cette étape peut être combinée avec l'étape c // c. Si kPresent vaut true, alors if (k in O) { - // i. Soit kValue le résultat de l'appel de la méthode // interne Get de O avec l'argument Pk. kValue = O[k]; diff --git a/files/fr/web/javascript/reference/global_objects/array/fill/index.md b/files/fr/web/javascript/reference/global_objects/array/fill/index.md index 0ee7654fabe55f..732963d1202a29 100644 --- a/files/fr/web/javascript/reference/global_objects/array/fill/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/fill/index.md @@ -13,9 +13,9 @@ La méthode **`fill()`** remplit tous les éléments d'un tableau entre deux ind ## Syntaxe ```js -arr.fill(valeur) -arr.fill(valeur, début) -arr.fill(valeur, début, fin) +arr.fill(valeur); +arr.fill(valeur, début); +arr.fill(valeur, début, fin); ``` ### Paramètres @@ -46,15 +46,15 @@ La méthode `fill()` est une méthode de modification, elle changera l'objet `th ## Exemples ```js -[1, 2, 3].fill(4); // [4, 4, 4] -[1, 2, 3].fill(4, 1); // [1, 4, 4] -[1, 2, 3].fill(4, 1, 2); // [1, 4, 3] -[1, 2, 3].fill(4, 1, 1); // [1, 2, 3] -[1, 2, 3].fill(4, -3, -2); // [4, 2, 3] -[1, 2, 3].fill(4, 3, 3); // [1, 2, 3] -[1, 2, 3].fill(4, NaN, NaN); // [1, 2, 3] -Array(3).fill(4); // [4, 4, 4] -[].fill.call({length: 3}, 4); // {0: 4, 1: 4, 2: 4, length: 3} +[1, 2, 3].fill(4); // [4, 4, 4] +[1, 2, 3].fill(4, 1); // [1, 4, 4] +[1, 2, 3].fill(4, 1, 2); // [1, 4, 3] +[1, 2, 3].fill(4, 1, 1); // [1, 2, 3] +[1, 2, 3].fill(4, -3, -2); // [4, 2, 3] +[1, 2, 3].fill(4, 3, 3); // [1, 2, 3] +[1, 2, 3].fill(4, NaN, NaN); // [1, 2, 3] +Array(3).fill(4); // [4, 4, 4] +[].fill.call({ length: 3 }, 4); // {0: 4, 1: 4, 2: 4, length: 3} // Les objets sont copiés via une référence var arr = Array(3).fill({}); // [{}, {}, {}]; @@ -65,12 +65,11 @@ arr[0].yop = "yop"; // [{yop: "yop"}, {yop: "yop"}, {yop: "yop"}] ```js if (!Array.prototype.fill) { - Object.defineProperty(Array.prototype, 'fill', { - value: function(value) { - + Object.defineProperty(Array.prototype, "fill", { + value: function (value) { // Steps 1-2. if (this == null) { - throw new TypeError('this is null or not defined'); + throw new TypeError("this is null or not defined"); } var O = Object(this); @@ -83,19 +82,20 @@ if (!Array.prototype.fill) { var relativeStart = start >> 0; // Step 8. - var k = relativeStart < 0 ? - Math.max(len + relativeStart, 0) : - Math.min(relativeStart, len); + var k = + relativeStart < 0 + ? Math.max(len + relativeStart, 0) + : Math.min(relativeStart, len); // Steps 9-10. var end = arguments[2]; - var relativeEnd = end === undefined ? - len : end >> 0; + var relativeEnd = end === undefined ? len : end >> 0; // Step 11. - var final = relativeEnd < 0 ? - Math.max(len + relativeEnd, 0) : - Math.min(relativeEnd, len); + var final = + relativeEnd < 0 + ? Math.max(len + relativeEnd, 0) + : Math.min(relativeEnd, len); // Step 12. while (k < final) { @@ -105,7 +105,7 @@ if (!Array.prototype.fill) { // Step 13. return O; - } + }, }); } ``` diff --git a/files/fr/web/javascript/reference/global_objects/array/filter/index.md b/files/fr/web/javascript/reference/global_objects/array/filter/index.md index 24d22f6195b2bf..1102c560606cc4 100644 --- a/files/fr/web/javascript/reference/global_objects/array/filter/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/filter/index.md @@ -80,17 +80,17 @@ var arr = [ { id: 0 }, { id: 3 }, { id: 12.2 }, - { }, + {}, { id: null }, { id: NaN }, - { id: 'undefined' } + { id: "undefined" }, ]; var elementsInvalides = 0; function filtrerParID(obj) { // Si c'est un nombre - if (obj.id !== undefined && typeof(obj.id) === 'number' && !isNaN(obj.id)) { + if (obj.id !== undefined && typeof obj.id === "number" && !isNaN(obj.id)) { return true; } else { elementsInvalides++; @@ -100,11 +100,11 @@ function filtrerParID(obj) { var arrByID = arr.filter(filtrerParID); -console.log('Tableau filtré\n', arrByID); +console.log("Tableau filtré\n", arrByID); // Le tableau filtré est : // [{ id: 15 }, { id: -1 }, { id: 0 }, { id: 3 }, { id: 12.2 }] -console.log('Nombre d\'éléments invalides = ', elementsInvalides); +console.log("Nombre d'éléments invalides = ", elementsInvalides); // Nombre d'éléments invalides 4 ``` @@ -113,16 +113,16 @@ console.log('Nombre d\'éléments invalides = ', elementsInvalides); Dans l'exemple qui suit, on utilise `filter()` pour filtrer le contenu d'un tableau selon un critère donné. ```js -var fruits = ['pomme', 'banane', 'raisin', 'mangue']; +var fruits = ["pomme", "banane", "raisin", "mangue"]; function filtreTexte(arr, requete) { return arr.filter(function (el) { return el.toLowerCase().indexOf(requete.toLowerCase()) !== -1; - }) + }); } -console.log(filtreTexte(fruits, 'an')); // ['banane', 'mangue']; -console.log(filtreTexte(fruits, 'm')); // ['pomme', 'mangue']; +console.log(filtreTexte(fruits, "an")); // ['banane', 'mangue']; +console.log(filtreTexte(fruits, "m")); // ['pomme', 'mangue']; ``` ### Implémentation avec la syntaxe ECMAScript 2015 (ES6) @@ -130,14 +130,16 @@ console.log(filtreTexte(fruits, 'm')); // ['pomme', 'mangue']; L'exemple suivant utilise [les fonctions fléchées](/fr/docs/Web/JavaScript/Reference/Fonctions/Fonctions_fléchées), et le mot clé [`const`](/fr/docs/Web/JavaScript/Reference/Instructions/const) disponible en ES6. ```js -const fruits = ['pomme', 'banane', 'raisin', 'mangue']; +const fruits = ["pomme", "banane", "raisin", "mangue"]; const filtreTexte = (arr, requete) => { - return arr.filter(el => el.toLowerCase().indexOf(requete.toLowerCase()) !== -1); -} + return arr.filter( + (el) => el.toLowerCase().indexOf(requete.toLowerCase()) !== -1, + ); +}; -console.log(filtreTexte(fruits, 'an')); // ['banane', 'mangue']; -console.log(filtreTexte(fruits, 'm')); // ['pomme', 'mangue']; +console.log(filtreTexte(fruits, "an")); // ['banane', 'mangue']; +console.log(filtreTexte(fruits, "m")); // ['pomme', 'mangue']; ``` ## Prothèse d'émulation (_polyfill_) @@ -145,30 +147,31 @@ console.log(filtreTexte(fruits, 'm')); // ['pomme', 'mangue']; `Array.prototype.filter()` a été ajoutée avec la cinquième édition du standard ECMA-262 — ainsi elle pourrait ne pas être présente dans toutes les implémentations du standard. Ce problème peut être contourné en ajoutant le code suivant au début des scripts et permettra d'utiliser `filter` au sein d'implémentations qui n'en bénéficient pas nativement. Cet algorithme est strictement celui spécifié par la cinquième édition d'ECMA-262, en considérant que `callbackfn.call` est évaluée avec la valeur d'origine de {{jsxref("Function.prototype.call")}} et que {{jsxref("Array.prototype.push")}} a sa valeur d'origine. ```js -if (!Array.prototype.filter){ - Array.prototype.filter = function(func, thisArg) { - 'use strict'; - if ( ! ((typeof func === 'Function' || typeof func === 'function') && this) ) - throw new TypeError(); +if (!Array.prototype.filter) { + Array.prototype.filter = function (func, thisArg) { + "use strict"; + if (!((typeof func === "Function" || typeof func === "function") && this)) + throw new TypeError(); var len = this.length >>> 0, - res = new Array(len), // preallocate array - t = this, c = 0, i = -1; - if (thisArg === undefined){ - while (++i !== len){ + res = new Array(len), // preallocate array + t = this, + c = 0, + i = -1; + if (thisArg === undefined) { + while (++i !== len) { // checks to see if the key was set - if (i in this){ - if (func(t[i], i, t)){ + if (i in this) { + if (func(t[i], i, t)) { res[c++] = t[i]; } } } - } - else{ - while (++i !== len){ + } else { + while (++i !== len) { // checks to see if the key was set - if (i in this){ - if (func.call(thisArg, t[i], i, t)){ + if (i in this) { + if (func.call(thisArg, t[i], i, t)) { res[c++] = t[i]; } } diff --git a/files/fr/web/javascript/reference/global_objects/array/find/index.md b/files/fr/web/javascript/reference/global_objects/array/find/index.md index 05bf1f519d7285..a01581749516b2 100644 --- a/files/fr/web/javascript/reference/global_objects/array/find/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/find/index.md @@ -56,13 +56,13 @@ L'intervalle des éléments inspectés par `find` est défini avant la première ```js const inventaire = [ - {nom: 'pommes', quantité: 2}, - {nom: 'bananes', quantité: 0}, - {nom: 'cerises', quantité: 5} + { nom: "pommes", quantité: 2 }, + { nom: "bananes", quantité: 0 }, + { nom: "cerises", quantité: 5 }, ]; function estCerises(fruit) { - return fruit.nom === 'cerises'; + return fruit.nom === "cerises"; } console.log(inventaire.find(estCerises)); @@ -73,12 +73,12 @@ console.log(inventaire.find(estCerises)); ```js const inventaire = [ - {nom: 'pommes', quantité: 2}, - {nom: 'bananes', quantité: 0}, - {nom: 'cerises', quantité: 5} - ]; + { nom: "pommes", quantité: 2 }, + { nom: "bananes", quantité: 0 }, + { nom: "cerises", quantité: 5 }, +]; -const resultat = inventaire.find( fruit => fruit.nom === 'cerises'); +const resultat = inventaire.find((fruit) => fruit.nom === "cerises"); console.log(resultat); // { nom: 'cerises', quantité: 5} ``` @@ -89,15 +89,15 @@ Dans l'exemple suivant, on cherche un nombre premier parmi les éléments d'un t ```js function estPremier(element, index, array) { - let début = 2; - while (début <= Math.sqrt(element)) { - if (element % début ++ < 1) return false; - } - return (element > 1); + let début = 2; + while (début <= Math.sqrt(element)) { + if (element % début++ < 1) return false; + } + return element > 1; } -console.log( [4, 6, 8, 12].find(estPremier) ); // undefined, rien trouvé -console.log( [4, 5, 8, 12].find(estPremier) ); // 5 +console.log([4, 6, 8, 12].find(estPremier)); // undefined, rien trouvé +console.log([4, 5, 8, 12].find(estPremier)); // 5 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/array/findindex/index.md b/files/fr/web/javascript/reference/global_objects/array/findindex/index.md index 9647741be408ef..0b6b592798a88d 100644 --- a/files/fr/web/javascript/reference/global_objects/array/findindex/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/findindex/index.md @@ -80,9 +80,9 @@ Dans cet exemple, on utilise [une fonction fléchée](/fr/docs/Web/JavaScript/Re ```js const fruits = ["pomme", "banane", "melon", "fraise", "raisin"]; -const index = fruits.findIndex(fruit => fruit === "fraise"); +const index = fruits.findIndex((fruit) => fruit === "fraise"); console.log(index); // 3 -console.log(fruits[index]); // fraise +console.log(fruits[index]); // fraise ``` ## Prothèse d'émulation (_polyfill_) @@ -90,9 +90,9 @@ console.log(fruits[index]); // fraise ```js // https://tc39.github.io/ecma262/#sec-array.prototype.findindex if (!Array.prototype.findIndex) { - Object.defineProperty(Array.prototype, 'findIndex', { - value: function(predicate) { - // 1. Let O be ? ToObject(this value). + Object.defineProperty(Array.prototype, "findIndex", { + value: function (predicate) { + // 1. Let O be ? ToObject(this value). if (this == null) { throw new TypeError('"this" is null or not defined'); } @@ -103,8 +103,8 @@ if (!Array.prototype.findIndex) { var len = o.length >>> 0; // 3. If IsCallable(predicate) is false, throw a TypeError exception. - if (typeof predicate !== 'function') { - throw new TypeError('predicate must be a function'); + if (typeof predicate !== "function") { + throw new TypeError("predicate must be a function"); } // 4. If thisArg was supplied, let T be thisArg; else let T be undefined. @@ -131,7 +131,7 @@ if (!Array.prototype.findIndex) { return -1; }, configurable: true, - writable: true + writable: true, }); } ``` diff --git a/files/fr/web/javascript/reference/global_objects/array/findlast/index.md b/files/fr/web/javascript/reference/global_objects/array/findlast/index.md index 85abc0733c83f3..a6252f0e85f8db 100644 --- a/files/fr/web/javascript/reference/global_objects/array/findlast/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/findlast/index.md @@ -88,10 +88,10 @@ Dans cet exemple, on illustre comment créer un test manipulant les propriétés ```js const inventaire = [ - { nom: 'pommes', quantite: 2 }, - { nom: 'bananes', quantite: 0 }, - { nom: 'poissons', quantite: 1 }, - { nom: 'cerises', quantite: 5 } + { nom: "pommes", quantite: 2 }, + { nom: "bananes", quantite: 0 }, + { nom: "poissons", quantite: 1 }, + { nom: "cerises", quantite: 5 }, ]; // Renvoie true si le stock est faible @@ -109,10 +109,10 @@ L'exemple précédent peut être écrit à l'aide d'une fonction fléchée et [u ```js const inventaire = [ - { nom: 'pommes', quantite: 2 }, - { nom: 'bananes', quantite: 0 }, - { nom: 'poissons', quantite: 1 }, - { nom: 'cerises', quantite: 5 }, + { nom: "pommes", quantite: 2 }, + { nom: "bananes", quantite: 0 }, + { nom: "poissons", quantite: 1 }, + { nom: "cerises", quantite: 5 }, ]; const resultat = inventaire.findLast(({ quantite }) => quantite < 2); diff --git a/files/fr/web/javascript/reference/global_objects/array/findlastindex/index.md b/files/fr/web/javascript/reference/global_objects/array/findlastindex/index.md index 1ae1dec7be5db5..f7ad39c341c07b 100644 --- a/files/fr/web/javascript/reference/global_objects/array/findlastindex/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/findlastindex/index.md @@ -119,7 +119,9 @@ const semblableTableau = { 2: 4, }; console.log( - Array.prototype.findLastIndex.call(semblableTableau, (x) => Number.isInteger(x)), + Array.prototype.findLastIndex.call(semblableTableau, (x) => + Number.isInteger(x), + ), ); // 2 ``` diff --git a/files/fr/web/javascript/reference/global_objects/array/flat/index.md b/files/fr/web/javascript/reference/global_objects/array/flat/index.md index e9b45a23c2a40d..18b24cf6b0c22b 100644 --- a/files/fr/web/javascript/reference/global_objects/array/flat/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/flat/index.md @@ -15,8 +15,8 @@ La méthode **`flat()`** permet de créer un nouveau tableau contenant les élé ## Syntaxe ```js -flat() -flat(profondeur) +flat(); +flat(profondeur); ``` ### Paramètres @@ -74,7 +74,7 @@ arr.reduce((acc, val) => acc.concat(val), []); // [1, 2, 3, 4] // avec la décomposition et les compositions fléchées, on peut écrire : -const aplati = arr => [].concat(...arr); +const aplati = (arr) => [].concat(...arr); ``` ### `reduce()` + `concat()` + `isArray()` + récursivité diff --git a/files/fr/web/javascript/reference/global_objects/array/flatmap/index.md b/files/fr/web/javascript/reference/global_objects/array/flatmap/index.md index 87f8ac81db9fe6..5ce1e844b06aad 100644 --- a/files/fr/web/javascript/reference/global_objects/array/flatmap/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/flatmap/index.md @@ -47,14 +47,14 @@ Pour la fonction de rappel, voir {{jsxref("Array.prototype.map()")}}. La méthod ```js var arr1 = [1, 2, 3, 4]; -arr1.map(x => [x * 2]); +arr1.map((x) => [x * 2]); // [[2], [4], [6], [8]] -arr1.flatMap(x => [x * 2]); +arr1.flatMap((x) => [x * 2]); // [2, 4, 6, 8] // seul un niveau est aplati -arr1.flatMap(x => [[x * 2]]); +arr1.flatMap((x) => [[x * 2]]); // [[2], [4], [6], [8]] ``` @@ -63,10 +63,10 @@ On peut utiliser un autre exemple où on génère une liste de mots à partir d' ```js let tableau1 = ["Coucou comment", "", "ça va ?"]; -tableau1.map(x => x.split(" ")); +tableau1.map((x) => x.split(" ")); // [["Coucou", "comment"], [""], ["ça", "va", "?"]] -tableau1.flatMap(x => x.split(" ")); +tableau1.flatMap((x) => x.split(" ")); // ["Coucou", "comment", "", "ça", "va", "?"] ``` @@ -83,7 +83,7 @@ On notera que la longueur de la liste obtenue avec `flatMap` est différente de ```js var arr = [1, 2, 3, 4]; -arr.flatMap(x => [x, x * 2]); +arr.flatMap((x) => [x, x * 2]); // est équivalent à arr.reduce((acc, x) => acc.concat([x, x * 2]), []); // [1, 2, 2, 4, 3, 6, 4, 8] diff --git a/files/fr/web/javascript/reference/global_objects/array/foreach/index.md b/files/fr/web/javascript/reference/global_objects/array/foreach/index.md index daf8f10bd21f87..e77d67b8f99371 100644 --- a/files/fr/web/javascript/reference/global_objects/array/foreach/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/foreach/index.md @@ -86,10 +86,10 @@ for (var i = 0; i < items.length; i++) { Et voici un fragment de code équivalent qui utilise `forEach` : ```js -var items = ["item1", "item2", "item3"] +var items = ["item1", "item2", "item3"]; var copie = []; -items.forEach(function(item){ +items.forEach(function (item) { copie.push(item); }); ``` @@ -102,7 +102,7 @@ Le code suivant affiche une ligne pour chaque élément du tableau : ```js function logArrayElements(element, index, array) { - console.log("a[" + index + "] = " + element); + console.log("a[" + index + "] = " + element); } [2, 5, , 9].forEach(logArrayElements); // logs: @@ -121,18 +121,18 @@ function Compteur() { this.compte = 0; } -Compteur.prototype.ajouter = function(tableau) { - tableau.forEach(function(element) { +Compteur.prototype.ajouter = function (tableau) { + tableau.forEach(function (element) { this.somme += element; ++this.compte; - }, this); - // ^---- On a ajouté l'argument this ici. + }, this); + // ^---- On a ajouté l'argument this ici. }; var obj = new Compteur(); obj.ajouter([2, 5, 9]); console.log(obj.compte); // 3 -console.log(obj.somme); // 16 +console.log(obj.somme); // 16 ``` > **Note :** Le paramètre pour `this` est passé à la méthode `forEach()`, à chaque appel du callback, celui-ci sera utilisé comme valeur pour `this`. @@ -148,30 +148,30 @@ var SEUIL_MAX = 12; var v = [5, 2, 16, 4, 3, 18, 20]; var res; -res = v.every(function(element, index, array) { - console.log('élément :', element); +res = v.every(function (element, index, array) { + console.log("élément :", element); if (element >= SEUIL_MAX) { return false; } return true; }); -console.log('res:', res); +console.log("res:", res); // affiche : // élément : 5 // élément : 2 // élément : 16 // res : false -res = v.some(function(element, index, array) { - console.log('élément:', element); +res = v.some(function (element, index, array) { + console.log("élément:", element); if (element >= SEUIL_MAX) { return true; } return false; }); -console.log('res:', res); +console.log("res:", res); // affiche : // élément : 5 // élément : 2 @@ -188,7 +188,7 @@ function copie(obj) { var copie = Object.create(Object.getPrototypeOf(obj)); var propNames = Object.getOwnPropertyNames(obj); - propNames.forEach(function(nom) { + propNames.forEach(function (nom) { var desc = Object.getOwnPropertyDescriptor(obj, nom); Object.defineProperty(copie, nom, desc); }); @@ -206,7 +206,7 @@ Dans l'exemple qui suit, on utilise un tableau qui contient quatre élément : ` ```js var mots = ["un", "deux", "trois", "quatre"]; -mots.forEach(function(mot) { +mots.forEach(function (mot) { console.log(mot); if (mot === "deux") { mots.shift(); diff --git a/files/fr/web/javascript/reference/global_objects/array/from/index.md b/files/fr/web/javascript/reference/global_objects/array/from/index.md index 80258f70c224f1..dbcdbb11b3d2d5 100644 --- a/files/fr/web/javascript/reference/global_objects/array/from/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/from/index.md @@ -53,20 +53,25 @@ function f() { f(1, 2, 3); // [1, 2, 3] - // Ça fonctionne avec tous les objets itérables... // Set const s = new Set(["toto", "truc", "truc", "bidule"]); Array.from(s); // ["toto", "truc", "bidule"] - // Map -const m = new Map([[1, 2], [2, 4], [4, 8]]); +const m = new Map([ + [1, 2], + [2, 4], + [4, 8], +]); Array.from(m); // [[1, 2], [2, 4], [4, 8]] -const mapper = new Map([["1", "a"], ["2", "b"]]); +const mapper = new Map([ + ["1", "a"], + ["2", "b"], +]); Array.from(mapper.values()); // ["a", "b"] @@ -77,15 +82,13 @@ Array.from(mapper.keys()); Array.from("toto"); // ["t", "o", "t", "o"] - // En utilisant une fonction fléchée pour remplacer map // et manipuler des éléments -Array.from([1, 2, 3], x => x + x); +Array.from([1, 2, 3], (x) => x + x); // [2, 4, 6] - // Pour générer une séquence de nombres -Array.from({length: 5}, (v, k) => k); +Array.from({ length: 5 }, (v, k) => k); // [0, 1, 2, 3, 4] ``` diff --git a/files/fr/web/javascript/reference/global_objects/array/group/index.md b/files/fr/web/javascript/reference/global_objects/array/group/index.md index 9dff68b190d6c8..645eaf12ab823a 100644 --- a/files/fr/web/javascript/reference/global_objects/array/group/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/group/index.md @@ -98,11 +98,11 @@ On définit un tableau contenant des objets qui représentent un inventaire alim ```js const inventaire = [ - { nom: 'asperge', type: 'legume', quantite: 5 }, - { nom: 'banane', type: 'fruit', quantite: 0 }, - { nom: 'agneau', type: 'viande', quantite: 23 }, - { nom: 'cerise', type: 'fruit', quantite: 5 }, - { nom: 'poisson', type: 'viande', quantite: 22 } + { nom: "asperge", type: "legume", quantite: 5 }, + { nom: "banane", type: "fruit", quantite: 0 }, + { nom: "agneau", type: "viande", quantite: 23 }, + { nom: "cerise", type: "fruit", quantite: 5 }, + { nom: "poisson", type: "viande", quantite: 22 }, ]; ``` @@ -134,7 +134,7 @@ On peut aussi créer des groupes selon un critère utilisant plusieurs propriét ```js function maFonctionDeRappel({ quantite }) { - return quantite > 5 ? 'ok' : 'restock'; + return quantite > 5 ? "ok" : "restock"; } const resultat2 = inventaire.group(maFonctionDeRappel); diff --git a/files/fr/web/javascript/reference/global_objects/array/grouptomap/index.md b/files/fr/web/javascript/reference/global_objects/array/grouptomap/index.md index 289a1456364cca..de017f6b634a6f 100644 --- a/files/fr/web/javascript/reference/global_objects/array/grouptomap/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/grouptomap/index.md @@ -102,11 +102,11 @@ On définit un tableau contenant des objets qui représentent un inventaire alim ```js const inventaire = [ - { nom: 'asperge', type: 'legume', quantite: 9 }, - { nom: 'banane', type: 'fruit', quantite: 5 }, - { nom: 'agneau', type: 'viande', quantite: 23 }, - { nom: 'cerise', type: 'fruit', quantite: 12 }, - { nom: 'poisson', type: 'viande', quantite: 22 } + { nom: "asperge", type: "legume", quantite: 9 }, + { nom: "banane", type: "fruit", quantite: 5 }, + { nom: "agneau", type: "viande", quantite: 23 }, + { nom: "cerise", type: "fruit", quantite: 12 }, + { nom: "poisson", type: "viande", quantite: 22 }, ]; ``` @@ -116,7 +116,9 @@ L'objet `resultat` est une `Map` et il faut donc appeler la méthode `get()` ave ```js const restock = { restock: true }; const suffisant = { restock: false }; -const resultat = inventaire.groupToMap(({ quantite }) => quantite < 6 ? restock : suffisant); +const resultat = inventaire.groupToMap(({ quantite }) => + quantite < 6 ? restock : suffisant, +); console.log(resultat.get(restock)); // résultat attendu : Array [Object { nom: "banane", type: "fruit", quantite: 5 }] ``` @@ -127,7 +129,7 @@ La clé d'un objet `Map` peut être modifiée et continuer d'être utilisée. To ```js // La clé peut être modifiée et continuer d'être utilisée -restock['rapide'] = true; +restock["rapide"] = true; console.log(resultat.get(restock)); // résultat attendu : Array [Object { nom: "banane", type: "fruit", quantite: 5 }] diff --git a/files/fr/web/javascript/reference/global_objects/array/includes/index.md b/files/fr/web/javascript/reference/global_objects/array/includes/index.md index 26f773764af8f3..51c6cfb93119da 100644 --- a/files/fr/web/javascript/reference/global_objects/array/includes/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/includes/index.md @@ -15,8 +15,8 @@ La méthode **`includes()`** permet de déterminer si un tableau contient une va ## Syntaxe ```js -array.includes(élémentRecherché) -array.includes(élémentRecherché, indiceDépart) +array.includes(élémentRecherché); +array.includes(élémentRecherché, indiceDépart); ``` ### Paramètres @@ -35,14 +35,14 @@ Un {{jsxref("Boolean","booléen","",1)}} qui vaut `true` si `élémentRecherché ## Exemples ```js -[1, 2, 3].includes(2); // true -[1, 2, 3].includes(4); // false -[1, 2, 3].includes(3, 3); // false +[1, 2, 3].includes(2); // true +[1, 2, 3].includes(4); // false +[1, 2, 3].includes(3, 3); // false [1, 2, 3].includes(3, -1); // true [1, 2, NaN].includes(NaN); // true -['a', 'b', 'c'].includes('c', 5); // false -['a', 'b', 'c'].includes('c', -100); // true +["a", "b", "c"].includes("c", 5); // false +["a", "b", "c"].includes("c", -100); // true ``` ### `indiceDépart` supérieur ou égal à la longueur du tableau @@ -50,10 +50,10 @@ Un {{jsxref("Boolean","booléen","",1)}} qui vaut `true` si `élémentRecherché SI `indiceDépart` est supérieur ou égal à la longueur du tableau, la méthode retourne `false`. Le tableau n'est pas parcouru. ```js -var arr = ['a', 'b', 'c']; +var arr = ["a", "b", "c"]; -arr.includes('c', 3); // false -arr.includes('c', 100); // false +arr.includes("c", 3); // false +arr.includes("c", 100); // false ``` ### `indiceDépart` strictement négatif @@ -65,11 +65,11 @@ Si `indiceDépart` est strictement négatif, l'indice de départ effectif est la // indiceDépart vaut -2 // L'indice de départ effectif vaut is 3 + (-2) = 1 -var arr = ['a', 'b', 'c']; +var arr = ["a", "b", "c"]; -arr.includes('a', -2); // false -arr.includes('b', -2); // true -arr.includes('c', -100); // true +arr.includes("a", -2); // false +arr.includes("b", -2); // true +arr.includes("c", -100); // true ``` ### Utilisation d'`includes()` comme méthode générique @@ -77,12 +77,12 @@ arr.includes('c', -100); // true `includes()` est une méthode générique : l'objet sur lequel elle est appelée ne doit pas nécessairement être un tableau. On peut l'utiliser sur des objets semblables à des tableaux (ex. [`arguments`](/fr/docs/Web/JavaScript/Reference/Fonctions/arguments) ou des chaînes de caractères) : ```js -function argumentsContientA(){ - return [].includes.call(arguments, 'a'); +function argumentsContientA() { + return [].includes.call(arguments, "a"); } -console.log(argumentsContientA('a','b','c')); // true -console.log(argumentsContientA('d','e','f')); // false +console.log(argumentsContientA("a", "b", "c")); // true +console.log(argumentsContientA("d", "e", "f")); // false ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/array/index.md b/files/fr/web/javascript/reference/global_objects/array/index.md index ab108d481b452a..7d132db5438cac 100644 --- a/files/fr/web/javascript/reference/global_objects/array/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/index.md @@ -19,7 +19,7 @@ Les tableaux ne peuvent pas utiliser de chaînes de caractères comme indices po **Créer un tableau** ```js -let fruits = ['Apple', 'Banana']; +let fruits = ["Apple", "Banana"]; console.log(fruits.length); // 2 @@ -38,7 +38,7 @@ let last = fruits[fruits.length - 1]; **Boucler sur un tableau** ```js -fruits.forEach(function(item, index, array) { +fruits.forEach(function (item, index, array) { console.log(item, index); }); // Apple 0 @@ -48,7 +48,7 @@ fruits.forEach(function(item, index, array) { **Ajouter à la fin du tableau** ```js -let newLength = fruits.push('Orange'); +let newLength = fruits.push("Orange"); // ["Apple", "Banana", "Orange"] ``` @@ -69,17 +69,17 @@ let first = fruits.shift(); // supprime Apple (au début) **Ajouter au début du tableau** ```js -let newLength = fruits.unshift('Strawberry') // ajoute au début +let newLength = fruits.unshift("Strawberry"); // ajoute au début // ["Strawberry", "Banana"]; ``` **Trouver l'index d'un élément dans le tableau** ```js -fruits.push('Mango'); +fruits.push("Mango"); // ["Strawberry", "Banana", "Mango"] -let pos = fruits.indexOf('Banana'); +let pos = fruits.indexOf("Banana"); // 1 ``` @@ -94,11 +94,12 @@ let removedItem = fruits.splice(pos, 1); // supprime 1 élément à la position **Supprimer des éléments à partir d'un index** ```js -let vegetables = ['Cabbage', 'Turnip', 'Radish', 'Carrot']; +let vegetables = ["Cabbage", "Turnip", "Radish", "Carrot"]; console.log(vegetables); // ["Cabbage", "Turnip", "Radish", "Carrot"] -let pos = 1, n = 2; +let pos = 1, + n = 2; let removedItems = vegetables.splice(pos, n); // n définit le nombre d'éléments à supprimer, @@ -124,9 +125,9 @@ Les tableaux sont indexés à partir de zéro: le premier élément d'un tableau ```js let arr = ["le premier élément", "le deuxième élément", "le dernier élément"]; -console.log(arr[0]); // affiche "le premier élément" -console.log(arr[1]); // affiche "le deuxième élément" -console.log(arr[arr.length - 1]);// affiche "le dernier élément" +console.log(arr[0]); // affiche "le premier élément" +console.log(arr[1]); // affiche "le deuxième élément" +console.log(arr[arr.length - 1]); // affiche "le dernier élément" ``` Les éléments d'un tableau sont des propriétés d'objets de la même manière que `toString` est une propriété. Cependant, essayer d'accéder à un élément du tableau comme suit renverra une erreur, car le nom de la propriété utilisé est invalide : @@ -146,24 +147,24 @@ console.log(années[0]); // fonctionne correctement ```js renderer.3d.setTexture(model, "personnage.png"); // erreur de syntaxe -renderer["3d"].setTexture(model, "personnage.png");// fonctionne correctement +renderer["3d"].setTexture(model, "personnage.png");// fonctionne correctement ``` Dans cet exemple, on utilise des doubles quotes autour de `3d`. On peut aussi utiliser les doubles quotes pour accéder aux éléments d'un tableau (ex. : `années["2"]` au lieu de `années[2]`), mais ce n'est pas obligatoire. Dans l'instruction `années[2]`, le nombre sera converti en une chaîne de caractères par le moteur JavaScript. Pour cette raison, si on utilise les noms de propriété "2" et "02", on fera référence à deux propriétés différentes, et le fragment de code suivant renvoie donc `true`: ```js -console.log(années["2"] != années["02"]); +console.log(années["2"] != années["02"]); ``` De manière similaire, les propriétés nommées avec des mots-clés réservés ne peuvent être consultées qu'en utilisant la syntaxe avec crochets : ```js let promise = { - 'var' : 'text', - 'array': [1, 2, 3, 4] + var: "text", + array: [1, 2, 3, 4], }; -console.log(promise['var']); +console.log(promise["var"]); ``` ### Relation entre `length` et les propriétés numériques @@ -181,9 +182,9 @@ Lorsqu'on définit une nouvelle propriété numérique pour un tableau, que l'in ```js fruits[5] = "mangue"; -console.log(fruits[5]); // "mangue" +console.log(fruits[5]); // "mangue" console.log(Object.keys(fruits)); // ['0', '1', '2', '5'] -console.log(fruits.length); // 6 +console.log(fruits.length); // 6 ``` On peut également modifier la propriété directement (cela n'ajoutera pas de nouveaux éléments) : @@ -191,7 +192,7 @@ On peut également modifier la propriété directement (cela n'ajoutera pas de n ```js fruits.length = 10; console.log(Object.keys(fruits)); // ['0', '1', '2', '5'] -console.log(fruits.length); // 10 +console.log(fruits.length); // 10 ``` En revanche, si on diminue la valeur de [`length`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/length), cela supprimera des éléments : @@ -370,11 +371,11 @@ Dans l'exemple suivant, on crée un tableau `tableauMsg`, d'une longueur nulle. ```js let tableauMsg = []; -tableauMsg[0] = 'Coucou'; -tableauMsg[99] = 'monde'; +tableauMsg[0] = "Coucou"; +tableauMsg[99] = "monde"; if (tableauMsg.length === 100) { - console.log('La longueur du tableau vaut 100.'); + console.log("La longueur du tableau vaut 100."); } ``` @@ -384,21 +385,22 @@ Dans l'exemple qui suit, on crée un plateau d'échec grâce à un tableau en de ```js let plateau = [ - ['T','C','F','R','K','F','C','T'], - ['P','P','P','P','P','P','P','P'], - [' ',' ',' ',' ',' ',' ',' ',' '], - [' ',' ',' ',' ',' ',' ',' ',' '], - [' ',' ',' ',' ',' ',' ',' ',' '], - [' ',' ',' ',' ',' ',' ',' ',' '], - ['p','p','p','p','p','p','p','p'], - ['t','c','f','k','r','f','c','t'] ]; - -console.log(plateau.join('\n') + '\n\n'); + ["T", "C", "F", "R", "K", "F", "C", "T"], + ["P", "P", "P", "P", "P", "P", "P", "P"], + [" ", " ", " ", " ", " ", " ", " ", " "], + [" ", " ", " ", " ", " ", " ", " ", " "], + [" ", " ", " ", " ", " ", " ", " ", " "], + [" ", " ", " ", " ", " ", " ", " ", " "], + ["p", "p", "p", "p", "p", "p", "p", "p"], + ["t", "c", "f", "k", "r", "f", "c", "t"], +]; + +console.log(plateau.join("\n") + "\n\n"); // On déplace le pion de deux cases en avant 2 plateau[4][4] = plateau[6][4]; -plateau[6][4] = ' '; -console.log(plateau.join('\n')); +plateau[6][4] = " "; +console.log(plateau.join("\n")); ``` Voici le résultat affiché : @@ -427,13 +429,10 @@ t,c,f,k,r,f,c,t ```js values = []; -for (let x = 0; x < 10; x++){ - values.push([ - 2 ** x, - 2 * x ** 2 - ]) -}; -console.table(values) +for (let x = 0; x < 10; x++) { + values.push([2 ** x, 2 * x ** 2]); +} +console.table(values); ``` Résulte en diff --git a/files/fr/web/javascript/reference/global_objects/array/indexof/index.md b/files/fr/web/javascript/reference/global_objects/array/indexof/index.md index 171340a8ce88b3..8bc531a86736d0 100644 --- a/files/fr/web/javascript/reference/global_objects/array/indexof/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/indexof/index.md @@ -15,8 +15,8 @@ La méthode **`indexOf()`** renvoie le premier indice pour lequel on trouve un ## Syntaxe ```js -arr.indexOf(élémentRecherché) -arr.indexOf(élémentRecherché, indiceDébut) +arr.indexOf(élémentRecherché); +arr.indexOf(élémentRecherché, indiceDébut); ``` ### Paramètres @@ -42,9 +42,9 @@ Dans l'exemple qui suit, on peut utiliser `indexOf` afin de trouver l'emplacemen ```js var tableau = [2, 9, 9]; -tableau.indexOf(2); // 0 -tableau.indexOf(7); // -1 -tableau.indexOf(9, 2); // 2 +tableau.indexOf(2); // 0 +tableau.indexOf(7); // -1 +tableau.indexOf(9, 2); // 2 tableau.indexOf(2, -1); // -1 tableau.indexOf(2, -3); // 0 ``` @@ -55,8 +55,8 @@ Dans l'exemple qui suit, on utilise `indexOf()` afin de trouver tous les indices ```js var indices = []; -var tableau = ['a', 'b', 'a', 'c', 'a', 'd']; -var élément = 'a'; +var tableau = ["a", "b", "a", "c", "a", "d"]; +var élément = "a"; var idx = tableau.indexOf(élément); while (idx != -1) { indices.push(idx); @@ -70,19 +70,19 @@ console.log(indices); ```js function mettreAJourLegumes(tabLégumes, légume) { - if (tabLégumes.indexOf(légume) === -1) { - tabLégumes.push(légume); - console.log('Le nouveau tableau est : ' + tabLégumes); - } else if (tabLégumes.indexOf(légume) > -1) { - console.log(légume + ' existe déjà dans le tableau.'); - } + if (tabLégumes.indexOf(légume) === -1) { + tabLégumes.push(légume); + console.log("Le nouveau tableau est : " + tabLégumes); + } else if (tabLégumes.indexOf(légume) > -1) { + console.log(légume + " existe déjà dans le tableau."); + } } -var tabLégumes = ['pomme de terre', 'tomate', 'poivron']; +var tabLégumes = ["pomme de terre", "tomate", "poivron"]; -mettreAJourLegumes(tabLégumes, 'épinard'); +mettreAJourLegumes(tabLégumes, "épinard"); // Le nouveau tableau est : pomme de terre,tomate,poivron,épinard -mettreAJourLegumes(tabLégumes, 'épinard'); +mettreAJourLegumes(tabLégumes, "épinard"); // épinard existe déjà dans le tableau. ``` @@ -94,8 +94,7 @@ mettreAJourLegumes(tabLégumes, 'épinard'); // Production steps of ECMA-262, Edition 5, 15.4.4.14 // Référence : http://es5.github.io/#x15.4.4.14 if (!Array.prototype.indexOf) { - Array.prototype.indexOf = function(searchElement, fromIndex) { - + Array.prototype.indexOf = function (searchElement, fromIndex) { var k; // 1. Soit O le résultat de l'appel à ToObject avec diff --git a/files/fr/web/javascript/reference/global_objects/array/isarray/index.md b/files/fr/web/javascript/reference/global_objects/array/isarray/index.md index e0698eb015c005..79e82054c21380 100644 --- a/files/fr/web/javascript/reference/global_objects/array/isarray/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/isarray/index.md @@ -9,16 +9,16 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/isArray La méthode **`Array.isArray()`** permet de déterminer si l'objet passé en argument est un objet {{jsxref("Array")}}, elle renvoie `true` si le paramètre passé à la fonction est de type `Array` et `false` dans le cas contraire. ```js -Array.isArray([1, 2, 3]); // true -Array.isArray({toto: 123}); // false -Array.isArray("tototruc"); // false -Array.isArray(undefined); // false +Array.isArray([1, 2, 3]); // true +Array.isArray({ toto: 123 }); // false +Array.isArray("tototruc"); // false +Array.isArray(undefined); // false ``` ## Syntaxe ```js -Array.isArray(value) +Array.isArray(value); ``` ### Paramètres @@ -43,10 +43,10 @@ Voir aussi : « [Determining with absolute accuracy whether or not a JavaScript Array.isArray([]); Array.isArray([1]); Array.isArray(new Array()); -Array.isArray(new Array('a', 'b', 'c')); +Array.isArray(new Array("a", "b", "c")); Array.isArray(new Array(3)); // Une petite anecdote: Array.prototype lui même est un Array -Array.isArray( Array.prototype ); +Array.isArray(Array.prototype); // Tous les appels suivant renvoient false Array.isArray(); @@ -58,7 +58,7 @@ Array.isArray("Array"); Array.isArray(true); Array.isArray(false); Array.isArray(new Uint8Array(32)); -Array.isArray({ __proto__ : Array.prototype }); +Array.isArray({ __proto__: Array.prototype }); ``` ## Prothèse d'émulation (_polyfill_) @@ -66,9 +66,9 @@ Array.isArray({ __proto__ : Array.prototype }); Exécuter ce code avant tout les autres aboutira à la création de la méthode `Array.isArray()`si elle n'est pas nativement prise en charge par le navigateur. ```js -if(!Array.isArray) { - Array.isArray = function(arg) { - return Object.prototype.toString.call(arg) === '[object Array]'; +if (!Array.isArray) { + Array.isArray = function (arg) { + return Object.prototype.toString.call(arg) === "[object Array]"; }; } ``` diff --git a/files/fr/web/javascript/reference/global_objects/array/join/index.md b/files/fr/web/javascript/reference/global_objects/array/join/index.md index 157e41714d8055..e0a1864fc413d6 100644 --- a/files/fr/web/javascript/reference/global_objects/array/join/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/join/index.md @@ -13,8 +13,8 @@ La méthode **`join()`** crée et renvoie une nouvelle chaîne de caractères en ## Syntaxe ```js -arr.join() -arr.join(séparateur) +arr.join(); +arr.join(séparateur); ``` ### Paramètres @@ -37,11 +37,11 @@ Les différents éléments du tableau sont convertis en une chaîne de caractèr L'exemple suivant crée un tableau, `a`, avec trois éléments, puis joint le tableau à trois reprises : en utilisant le séparateur par défaut, une virgule et un espace, puis un plus, puis avec la chaîne vide. ```js -var a = new Array("Vent","Pluie","Feu"); -a.join(); // "Vent,Pluie,Feu" -a.join(", "); // "Vent, Pluie, Feu" +var a = new Array("Vent", "Pluie", "Feu"); +a.join(); // "Vent,Pluie,Feu" +a.join(", "); // "Vent, Pluie, Feu" a.join(" + "); // "Vent + Pluie + Feu" -a.join(""); // "VentPluieFeu" +a.join(""); // "VentPluieFeu" ``` ### Fusionner un objet semblable à un tableau @@ -53,7 +53,7 @@ function f(a, b, c) { var s = Array.prototype.join.call(arguments); console.log(s); } -f(1, 'a', true); // '1,a,true' +f(1, "a", true); // '1,a,true' ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/array/keys/index.md b/files/fr/web/javascript/reference/global_objects/array/keys/index.md index 393cbb267eb3b7..2d815b661e2975 100644 --- a/files/fr/web/javascript/reference/global_objects/array/keys/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/keys/index.md @@ -13,7 +13,7 @@ La méthode **`keys()`** renvoie un nouvel objet **`Array Iterator`** qui contie ## Syntaxe ```js -arr.keys() +arr.keys(); ``` ### Valeur de retour @@ -25,7 +25,7 @@ Un nouvel objet itérateur pour {{jsxref("Array")}}. ### Utilisation simple ```js -var arr = ["a","b","c"]; +var arr = ["a", "b", "c"]; var itérateur = arr.keys(); console.log(itérateur.next()); // { value: 0, done: false } @@ -41,7 +41,7 @@ var arr = ["a", , "c"]; var clésCreuses = Object.keys(arr); var clésDenses = [...arr.keys()]; console.log(clésCreuses); // ["0", "2"] -console.log(clésDenses); // [0, 1, 2] +console.log(clésDenses); // [0, 1, 2] ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/array/lastindexof/index.md b/files/fr/web/javascript/reference/global_objects/array/lastindexof/index.md index 9fadbd737ea5d7..7af7fd4736ab8c 100644 --- a/files/fr/web/javascript/reference/global_objects/array/lastindexof/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/lastindexof/index.md @@ -13,8 +13,8 @@ La méthode **`lastIndexOf()`** permet de renvoyer le dernier indice pour lequel ## Syntaxe ```js -arr.lastIndexOf(élémentRecherché) -arr.lastIndexOf(élémentRecherché, indexDébut) +arr.lastIndexOf(élémentRecherché); +arr.lastIndexOf(élémentRecherché, indexDébut); ``` ### Paramètres @@ -40,10 +40,10 @@ Dans l'exemple suivant, on utilise `lastIndexOf` afin de situer une valeur dans ```js var tableau = [2, 5, 9, 2]; -tableau.lastIndexOf(2); // 3 -tableau.lastIndexOf(7); // -1 -tableau.lastIndexOf(2, 3); // 3 -tableau.lastIndexOf(2, 2); // 0 +tableau.lastIndexOf(2); // 3 +tableau.lastIndexOf(7); // -1 +tableau.lastIndexOf(2, 3); // 3 +tableau.lastIndexOf(2, 2); // 0 tableau.lastIndexOf(2, -2); // 0 tableau.lastIndexOf(2, -1); // 3 ``` @@ -54,12 +54,12 @@ L'exemple suivant utilise `lastIndexOf` pour trouver tous les index (`indices`) ```js var indices = []; -var tableau = ['a', 'b', 'a', 'c', 'a', 'd']; -var élément = 'a'; +var tableau = ["a", "b", "a", "c", "a", "d"]; +var élément = "a"; var idx = tableau.lastIndexOf(élément); while (idx !== -1) { indices.push(idx); - idx = (idx > 0 ? tableau.lastIndexOf(élément, idx - 1) : -1); + idx = idx > 0 ? tableau.lastIndexOf(élément, idx - 1) : -1; } console.log(indices); @@ -76,14 +76,15 @@ Remarquez que nous avons dû traiter le cas de `idx === 0` séparément (`idx > // Production steps of ECMA-262, Edition 5, 15.4.4.15 // Reference: http://es5.github.io/#x15.4.4.15 if (!Array.prototype.lastIndexOf) { - Array.prototype.lastIndexOf = function(searchElement /*, fromIndex*/) { - 'use strict'; + Array.prototype.lastIndexOf = function (searchElement /*, fromIndex*/) { + "use strict"; if (this === void 0 || this === null) { throw new TypeError(); } - var n, k, + var n, + k, t = Object(this), len = t.length >>> 0; if (len === 0) { @@ -95,8 +96,7 @@ if (!Array.prototype.lastIndexOf) { n = Number(arguments[1]); if (n != n) { n = 0; - } - else if (n != 0 && n != (1 / 0) && n != -(1 / 0)) { + } else if (n != 0 && n != 1 / 0 && n != -(1 / 0)) { n = (n > 0 || -1) * Math.floor(Math.abs(n)); } } diff --git a/files/fr/web/javascript/reference/global_objects/array/length/index.md b/files/fr/web/javascript/reference/global_objects/array/length/index.md index b897e393be4cda..62da84a843cc3f 100644 --- a/files/fr/web/javascript/reference/global_objects/array/length/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/length/index.md @@ -16,13 +16,13 @@ La valeur de la propriété `length` est un entier de signe positif dont la vale ```js var tableauA = new Array(4294967296); // 2 à la puissance 32 = 4294967296 -var tableauC = new Array(-100) // une valeur négative +var tableauC = new Array(-100); // une valeur négative console.log(tableauA.length); // RangeError: Invalid array length console.log(tableauC.length); // RangeError: Invalid array length var tableauB = []; -tableauB.length = Math.pow(2,32)-1; // On déclare une longueur inférieure à 2 puissance 32 +tableauB.length = Math.pow(2, 32) - 1; // On déclare une longueur inférieure à 2 puissance 32 console.log(tableauB.length); // 4294967295 ``` @@ -37,7 +37,7 @@ arr.length = 5; // On définit une longueur à 5 console.table(arr); // [1, 2, <3 éléments vides>] -arr.forEach(element => console.log(element)); +arr.forEach((element) => console.log(element)); // 1 // 2 ``` @@ -58,7 +58,7 @@ items.length; // 4 Dans l'exemple suivant, on itère sur le tableau `nombres` en utilisant la propriété `length` afin de connaître son nombre d'élément. La valeur de chaque élément est ensuite multipliée par deux : ```js -var nombres = [1,2,3,4,5]; +var nombres = [1, 2, 3, 4, 5]; for (var i = 0; i < nombres.length; i++) { nombres[i] *= 2; @@ -72,7 +72,7 @@ L'exemple suivant raccourcit le tableau `etatsUS` à 50 si sa longueur actuelle ```js if (etatsUS.length > 50) { - etatsUS.length = 50; + etatsUS.length = 50; } ``` diff --git a/files/fr/web/javascript/reference/global_objects/array/map/index.md b/files/fr/web/javascript/reference/global_objects/array/map/index.md index 377bcf3519635b..7efb5d488d5442 100644 --- a/files/fr/web/javascript/reference/global_objects/array/map/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/map/index.md @@ -69,7 +69,7 @@ Ici, on illustre le fonctionnement de `map` avec une fonction à un argument. Ce ```js var nombres = [1, 4, 9]; -var doubles = nombres.map(function(num) { +var doubles = nombres.map(function (num) { return num * 2; }); // doubles vaut désormais [2, 8, 18]. @@ -81,8 +81,12 @@ var doubles = nombres.map(function(num) { Dans le code qui suit, on utilise un tableau d'objets pour créer un autre tableau contenant de nouveaux objets dans un autre format : ```js -var tableauOrig = [{clé:1, valeur:10}, {clé:2, valeur:20}, {clé:3, valeur: 30}]; -var tableauFormaté = tableauOrig.map(obj => { +var tableauOrig = [ + { clé: 1, valeur: 10 }, + { clé: 2, valeur: 20 }, + { clé: 3, valeur: 30 }, +]; +var tableauFormaté = tableauOrig.map((obj) => { var rObj = {}; rObj[obj.clé] = obj.valeur; return rObj; @@ -101,7 +105,9 @@ Dans cet exemple, on voit comment utiliser la fonction `map` sur une chaîne de ```js var map = Array.prototype.map; -var a = map.call('Hello World', function(x) { return x.charCodeAt(0); }); +var a = map.call("Hello World", function (x) { + return x.charCodeAt(0); +}); // a vaut désormais [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100] ``` @@ -110,8 +116,8 @@ var a = map.call('Hello World', function(x) { return x.charCodeAt(0); }); Dans cet exemple, on illustre comment utiliser la méthode map de façon générique, sur un tableau d'objets collectés grâce à `querySelectorAll` : ```js -var elems = document.querySelectorAll('select option:checked'); -var values = Array.prototype.map.call(elems, function(obj) { +var elems = document.querySelectorAll("select option:checked"); +var values = Array.prototype.map.call(elems, function (obj) { return obj.value; }); ``` @@ -126,7 +132,7 @@ Il est fréquent d'utiliser la fonction `callback` avec un seul argument (l'él ```js // Si on utilise : -['1', '2', '3'].map(parseInt); +["1", "2", "3"].map(parseInt); // On s'attend à obtenir [1, 2, 3] // Le résultat qu'on obtient est en fait [1, NaN, NaN] @@ -143,10 +149,10 @@ function returnInt(element) { return parseInt(element, 10); } -['1', '2', '3'].map(returnInt); // [1, 2, 3] +["1", "2", "3"].map(returnInt); // [1, 2, 3] // Le résultat qu'on obtient avec la fonction auxiliaire -['1', '2', '3'].map(parseInt); // [1, NaN, NaN] +["1", "2", "3"].map(parseInt); // [1, NaN, NaN] // car map passe trois argument à la fonction et que parseInt // considère le second argument comme base. // En détails : @@ -154,16 +160,15 @@ function returnInt(element) { // Deuxième élément : "2" à l'indice 1 : parseInt("2",1); donne NaN // Troisième élément : "3" à l'indice 2 : parseInt("3",2); donne NaN - // Formulation équivalente plus concise avec // une fonction fléchée -['1', '2', '3'].map( str => parseInt(str)); +["1", "2", "3"].map((str) => parseInt(str)); // Une autre méthode, plus simple -['1', '2', '3'].map(Number); // [1, 2, 3] +["1", "2", "3"].map(Number); // [1, 2, 3] // à la différence de parseInt, cela fonctionnera pour les // nombres décimaux ou en notation exponentielle -['1.1', '2.2e2', '3e300'].map(Number); // [1.1, 220, 3e+300] +["1.1", "2.2e2", "3e300"].map(Number); // [1.1, 220, 3e+300] ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/array/of/index.md b/files/fr/web/javascript/reference/global_objects/array/of/index.md index 597852afa68207..1cca34e1b815ec 100644 --- a/files/fr/web/javascript/reference/global_objects/array/of/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/of/index.md @@ -11,11 +11,11 @@ La methode **`Array.of()`** permet de créer une nouvelle instance d'objet `Arra La différence entre **`Array.of()`** et le constructeur **`Array`** se situe dans la gestion de d'arguments entiers : **`Array.of(7)`** crée un tableau avec un seul élément, 7, tandis que **`Array(7)`** produit un tableau avec 7 éléments vides (à ne pas confondre avec des éléments qui auraient explicitement la valeur [`undefined`](/fr/docs/Web/JavaScript/Reference/Objets_globaux/undefined)). ```js -Array.of(7); // [7] +Array.of(7); // [7] Array.of(1, 2, 3); // [1, 2, 3] -Array(7); // un tableau avec 7 emplacements vides -Array(1, 2, 3); // [1, 2, 3] +Array(7); // un tableau avec 7 emplacements vides +Array(1, 2, 3); // [1, 2, 3] ``` ## Syntaxe @@ -38,18 +38,18 @@ Une nouvelle instance de {{jsxref("Array")}}. Cette fonction fait partie du standard ECMAScript 2015. Pour plus d'informations, voir les pages sur [la proposition pour `Array.of` et `Array.from`](https://gist.github.com/rwaldron/1074126) ainsi que la page sur le [fragment d'émulation pour `Array.of`](https://gist.github.com/rwaldron/3186576). ```js -Array.of(7); // [7] +Array.of(7); // [7] Array.of(1, 2, 3); // [1, 2, 3] -Array(7); // [ , , , , , , ] -Array(1, 2, 3); // [1, 2, 3] +Array(7); // [ , , , , , , ] +Array(1, 2, 3); // [1, 2, 3] ``` ## Exemples ```js -Array.of(1); // [1] -Array.of(1, 2, 3); // [1, 2, 3] +Array.of(1); // [1] +Array.of(1, 2, 3); // [1, 2, 3] Array.of(undefined); // [undefined] ``` @@ -59,7 +59,7 @@ Exécuter ce code avant tout autre code permettra de créer la méthode **`Array ```js if (!Array.of) { - Array.of = function() { + Array.of = function () { return Array.prototype.slice.call(arguments); }; } diff --git a/files/fr/web/javascript/reference/global_objects/array/pop/index.md b/files/fr/web/javascript/reference/global_objects/array/pop/index.md index 51c32e65a05a5e..3a9d30d74cc50b 100644 --- a/files/fr/web/javascript/reference/global_objects/array/pop/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/pop/index.md @@ -13,7 +13,7 @@ La méthode **`pop()`** supprime le **dernier** élément d'un tableau et retour ## Syntaxe ```js -arr.pop() +arr.pop(); ``` ### Valeur de retour @@ -42,7 +42,7 @@ var mesPoissons = ["angel", "clown", "mandarin", "sturgeon"]; var popped = mesPoissons.pop(); console.table(mesPoissons); // angel, clown, madarin -console.log(popped); // sturgeon +console.log(popped); // sturgeon ``` ### Utiliser `apply()` ou `call()` sur les objets semblables aux tableaux @@ -50,11 +50,17 @@ console.log(popped); // sturgeon Le code suivant crée un objet `mesPoissons` semblable à un tableau, qui contient 4 propriétés indexées avec des nombres et une propriété `length`. On utilise la méthode {{jsxref("Function.call()")}} pour invoquer `pop()` sur cet objet : ```js -var mesPoissons = {0: 'angel', 1: 'clown', 2: 'mandarin', 3: 'sturgeon', length: 4}; +var mesPoissons = { + 0: "angel", + 1: "clown", + 2: "mandarin", + 3: "sturgeon", + length: 4, +}; var popped = Array.prototype.pop.call(mesPoissons); // on aurait pu utiliser apply() console.log(mesPoissons); // {0: 'angel', 1: 'clown', 2: 'mandarin', length: 3} -console.log(popped); // 'sturgeon' +console.log(popped); // 'sturgeon' ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/array/push/index.md b/files/fr/web/javascript/reference/global_objects/array/push/index.md index 197e04a460b966..cc34dfb7328eee 100644 --- a/files/fr/web/javascript/reference/global_objects/array/push/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/push/index.md @@ -46,7 +46,7 @@ var sports = ["plongée", "baseball"]; var total = sports.push("football", "tennis"); console.log(sports); // ["plongée", "baseball", "football", "tennis"] -console.log(total); // 4 +console.log(total); // 4 ``` ### Fusionner deux tableaux @@ -54,8 +54,8 @@ console.log(total); // 4 Dans l'exemple qui suit, on utilise la méthode {{jsxref("Function.apply()")}} pour ajouter les différents éléments d'un second tableau ```js -var legumes = ['navet', 'pomme de terre']; -var autresLegumes = ['céleri', 'radis']; +var legumes = ["navet", "pomme de terre"]; +var autresLegumes = ["céleri", "radis"]; // On fusionne les deux tableaux // Équivalent à legumes.push('céleri', 'radis'); @@ -69,8 +69,8 @@ console.log(legumes); // ['navet', 'pomme de terre', 'céleri', 'radis'] L'exemple qui suit utilise [la syntaxe de décomposition](/fr/docs/Web/JavaScript/Reference/Operators/Spread_syntax) pour ajouter les éléments d'un second tableau à la fin du premier tableau. ```js -const legumes = ['navet', 'pomme de terre']; -const autresLegumes = ['céleri', 'radis']; +const legumes = ["navet", "pomme de terre"]; +const autresLegumes = ["céleri", "radis"]; // On fusionne les deux tableaux // Équivalent à legumes.push('céleri', 'radis'); @@ -85,13 +85,13 @@ Comme nous l'avons vu auparavant, `push` est une méthode générique et nous po ```js var obj = { - length: 0, + length: 0, - ajoutElem: function ajoutElem (elem) { - // obj.length est automatiquement incrémenté - // quand on ajoute un élément - [].push.call(this, elem); - } + ajoutElem: function ajoutElem(elem) { + // obj.length est automatiquement incrémenté + // quand on ajoute un élément + [].push.call(this, elem); + }, }; // Ajoutons quelques objets vides pour illustrer diff --git a/files/fr/web/javascript/reference/global_objects/array/reduce/index.md b/files/fr/web/javascript/reference/global_objects/array/reduce/index.md index 4f201747f2543f..12ede23d8bb82a 100644 --- a/files/fr/web/javascript/reference/global_objects/array/reduce/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/reduce/index.md @@ -13,8 +13,8 @@ La méthode **`reduce()`** applique une fonction qui est un « accumulateur » e ## Syntaxe ```js -arr.reduce(callback) -arr.reduce(callback, valeurInitiale) +arr.reduce(callback); +arr.reduce(callback, valeurInitiale); ``` ### Paramètres @@ -55,7 +55,7 @@ Autrement dit, si `valeurInitiale` n'est pas fournie, `reduce` exécutera la fon En considérant le code suivant : ```js -[0, 1, 2, 3, 4].reduce(function(accumulateur, valeurCourante, index, array){ +[0, 1, 2, 3, 4].reduce(function (accumulateur, valeurCourante, index, array) { return accumulateur + valeurCourante; }); ``` @@ -122,7 +122,7 @@ Il est aussi possible d'utiliser une {{jsxref("Fonctions/Fonctions_fléchées"," Si on fournit une valeur initiale comme second argument à l'appel de `reduce()`, le résultat sera alors le suivant : ```js -[0, 1, 2, 3, 4].reduce(function(accumulateur, valeurCourante, index, array){ +[0, 1, 2, 3, 4].reduce(function (accumulateur, valeurCourante, index, array) { return accumulateur + valeurCourante; }, 10); ``` @@ -189,7 +189,7 @@ Ici, la valeur renvoyée par `reduce()` serait `20`. ### Additionner toutes les valeurs d'un tableau ```js -var total = [0, 1, 2, 3].reduce((a, b)=> a + b,0); +var total = [0, 1, 2, 3].reduce((a, b) => a + b, 0); // total == 6 ``` @@ -199,8 +199,11 @@ Pour additionner les valeurs d'une propriété donnée des objets d'un tableau, ```js var valeurInitiale = 0; -var somme = [{x: 1}, {x:2}, {x:3}].reduce(function (accumulateur, valeurCourante) { - return accumulateur + valeurCourante.x; +var somme = [{ x: 1 }, { x: 2 }, { x: 3 }].reduce(function ( + accumulateur, + valeurCourante, +) { + return accumulateur + valeurCourante.x; }, valeurInitiale); console.log(somme); // affiche 6 dans la console @@ -210,9 +213,9 @@ On peut également écrire une version plus concise avec les fonctions fléchée ```js var valeurInitiale = 0; -var somme = [{x: 1}, {x:2}, {x:3}].reduce( - (accumulateur, valeurCourante) => accumulateur + valeurCourante.x - , valeurInitiale +var somme = [{ x: 1 }, { x: 2 }, { x: 3 }].reduce( + (accumulateur, valeurCourante) => accumulateur + valeurCourante.x, + valeurInitiale, ); console.log(somme); // affiche 6 dans la console @@ -221,8 +224,12 @@ console.log(somme); // affiche 6 dans la console ### Aplatir une liste de listes ```js -var applati = [[0, 1], [2, 3], [4, 5]].reduce(function(a, b) { - return a.concat(b); +var applati = [ + [0, 1], + [2, 3], + [4, 5], +].reduce(function (a, b) { + return a.concat(b); }); // applati vaut [0, 1, 2, 3, 4, 5] ``` @@ -231,13 +238,16 @@ var applati = [[0, 1], [2, 3], [4, 5]].reduce(function(a, b) { ```js var amis = [ - { "nom": "Quentin", "livres": ["City Hall", "Harry Potter"]}, - { "nom": "Alice", "livres": ["L'Avare", "Les Fleurs du Mal"]} -] + { nom: "Quentin", livres: ["City Hall", "Harry Potter"] }, + { nom: "Alice", livres: ["L'Avare", "Les Fleurs du Mal"] }, +]; -var tousLivres = amis.reduce(function(prev, curr) { - return [...prev, ...curr.livres]; -}, ["Perceval"]); +var tousLivres = amis.reduce( + function (prev, curr) { + return [...prev, ...curr.livres]; + }, + ["Perceval"], +); // tousLivres = ["Perceval", "City Hall", "Harry Potter", // "L'Avare", "Les Fleurs du Mal"] @@ -255,9 +265,8 @@ var tousLivres = amis.reduce(function(prev, curr) { function runPromiseInSequense(arr) { return arr.reduce((promiseChain, currentPromise) => { return promiseChain.then((chainedResult) => { - return currentPromise(chainedResult) - .then((res) => res) - }) + return currentPromise(chainedResult).then((res) => res); + }); }, Promise.resolve()); } @@ -283,10 +292,9 @@ function p3(a) { } const promiseArr = [p1, p2, p3]; -runPromiseInSequense(promiseArr) - .then((res) => { - console.log(res); // 30 - }); +runPromiseInSequense(promiseArr).then((res) => { + console.log(res); // 30 +}); ``` ### Regrouper des objets selon une propriété @@ -295,13 +303,13 @@ runPromiseInSequense(promiseArr) var personnes = [ { nom: "Alice", age: 21 }, { nom: "Bob", age: 20 }, - { nom: "Charlie", age: 20 } + { nom: "Charlie", age: 20 }, ]; -function groupBy(tableauObjets, propriete){ +function groupBy(tableauObjets, propriete) { return tableauObjets.reduce(function (acc, obj) { var cle = obj[propriete]; - if(!acc[cle]){ + if (!acc[cle]) { acc[cle] = []; } acc[cle].push(obj); @@ -324,15 +332,15 @@ var personnesParAge = groupBy(personnes, "age"); ```js // Les briques de base que nous allons composer -const double = x => x + x; -const triple = x => 3 * x; -const quadruple = x => 4 * x; +const double = (x) => x + x; +const triple = (x) => 3 * x; +const quadruple = (x) => 4 * x; // Une fonction qui permet d'appliquer une composition -const pipe = (...functions) => input => functions.reduce( - (acc, fn) => fn(acc), - input -); +const pipe = + (...functions) => + (input) => + functions.reduce((acc, fn) => fn(acc), input); // On crée des fonctions pour multiplier par un facteur donné const multiply6 = pipe(double, triple); @@ -361,11 +369,14 @@ console.table(tableauSansDoublon); // [1, 2, 3, 4, 5, 6] ```js var tableauAvecDoublons = [1, 2, 3, 1, 4, 5, 4, 6]; -var tableauSansDoublon = tableauAvecDoublons.reduce(function (acc, valCourante) { - if(acc.indexOf(valCourante) === -1) { +var tableauSansDoublon = tableauAvecDoublons.reduce(function ( + acc, + valCourante, +) { + if (acc.indexOf(valCourante) === -1) { acc.push(valCourante); } - return acc + return acc; }, []); console.log(tableauSansDoublon); // [1, 2, 3, 4, 5, 6] diff --git a/files/fr/web/javascript/reference/global_objects/array/reduceright/index.md b/files/fr/web/javascript/reference/global_objects/array/reduceright/index.md index fe393faa88b338..8612e11f17d75b 100644 --- a/files/fr/web/javascript/reference/global_objects/array/reduceright/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/reduceright/index.md @@ -47,8 +47,8 @@ La valeur obtenue grâce à la fonction de réduction. L'usage de `reduceRight` avec définition d'un `callback` devrait ressembler à ceci : ```js -array.reduceRight(function(accumulator, valeurCourante, index, array) { - // ... +array.reduceRight(function (accumulator, valeurCourante, index, array) { + // ... }); ``` @@ -57,9 +57,11 @@ La première fois que la fonction de callback est appelée, `accumulator` et `va Si on utilise la méthode `reduceRight` de la façon suivante : ```js -[0, 1, 2, 3, 4].reduceRight(function(accumulator, valeurCourante, index, array) { +[0, 1, 2, 3, 4].reduceRight( + function (accumulator, valeurCourante, index, array) { return accumulator + valeurCourante; -}); + }, +); ``` La fonction `callback` sera appelée quatre fois, avec les arguments et les valeurs de retour de chaque appel suivant : @@ -116,8 +118,13 @@ La valeur retournée par `reduceRight` sera alors celle du dernier appel de la f Si vous fournissez une valeur initiale comme second argument à l'appel de `reduceRight`, le résultat sera alors le suivant : ```js -[0, 1, 2, 3, 4].reduceRight(function(accumulator, valeurCourante, index, array) { - return accumulator + valeurCourante; +[0, 1, 2, 3, 4].reduceRight(function ( + accumulator, + valeurCourante, + index, + array, +) { + return accumulator + valeurCourante; }, 10); ``` @@ -183,8 +190,8 @@ La valeur renvoyée par `reduceRight` sera ici `20`. ### Additionner toutes les valeurs d'une liste ```js -var total = [0, 1, 2, 3].reduceRight(function(a, b) { - return a + b; +var total = [0, 1, 2, 3].reduceRight(function (a, b) { + return a + b; }); // total == 6 ``` @@ -192,8 +199,12 @@ var total = [0, 1, 2, 3].reduceRight(function(a, b) { ### Aplatir une liste de listes ```js -var aplati = [[0, 1], [2, 3], [4, 5]].reduceRight(function(a, b) { - return a.concat(b); +var aplati = [ + [0, 1], + [2, 3], + [4, 5], +].reduceRight(function (a, b) { + return a.concat(b); }, []); // aplati [4, 5, 2, 3, 0, 1] ``` @@ -201,12 +212,12 @@ var aplati = [[0, 1], [2, 3], [4, 5]].reduceRight(function(a, b) { ### Différence entre `reduce` et `reduceRight` ```js -var a = ['1', '2', '3', '4','5'] -var gauche = a.reduce(function(prev, cur) { +var a = ["1", "2", "3", "4", "5"]; +var gauche = a.reduce(function (prev, cur) { return prev + cur; }); -var droite = a.reduceRight(function(prev, cur) { +var droite = a.reduceRight(function (prev, cur) { return prev + cur; }); @@ -226,19 +237,22 @@ La composition de fonctions consiste en l'enchaînement de n fonctions l'une apr * https://fr.wikipedia.org/wiki/Composition_de_fonctions */ -const compose = (...args) => (value) => args.reduceRight((acc, fn) => fn(acc), value) +const compose = + (...args) => + (value) => + args.reduceRight((acc, fn) => fn(acc), value); // On incrémente un nombre passé en argument -const inc = (n) => n + 1 +const inc = (n) => n + 1; // On double la valeur passée en argument -const double = (n) => n * 2 +const double = (n) => n * 2; // On compose double(inc(x)) -compose(double, inc)(2) // 6 +compose(double, inc)(2); // 6 // On compose inc(double(x)) -compose(inc, double)(2) // 5 +compose(inc, double)(2); // 5 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/array/reverse/index.md b/files/fr/web/javascript/reference/global_objects/array/reverse/index.md index cffc8d691b3d30..616029bf2ff8ad 100644 --- a/files/fr/web/javascript/reference/global_objects/array/reverse/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/reverse/index.md @@ -13,7 +13,7 @@ La méthode **`reverse()`** transpose les éléments d'un tableau : le prem ## Syntaxe ```js -arr.reverse() +arr.reverse(); ``` ### Valeur de retour @@ -36,7 +36,7 @@ L'exemple qui suit crée un tableau `monArray`, qui contient trois éléments, p var monArray = ["un", "deux", "trois"]; monArray.reverse(); -console.log(monArray) // ["trois", "deux", "un"] +console.log(monArray); // ["trois", "deux", "un"] ``` ### Inverser l'ordre des éléments d'un objet semblable à un tableau @@ -44,7 +44,7 @@ console.log(monArray) // ["trois", "deux", "un"] Dans l'exemple suivant, on crée un objet semblable à un tableau `a` qui contient trois éléments et une propriété `length`. On appelle ensuite `reverse()` grâce à `call()` sur cet objet pour inverser ses éléments : ```js -const a = {0: 1, 1: 2, 2: 3, length: 3}; +const a = { 0: 1, 1: 2, 2: 3, length: 3 }; console.log(a); // {0: 1, 1: 2, 2: 3, length: 3} diff --git a/files/fr/web/javascript/reference/global_objects/array/shift/index.md b/files/fr/web/javascript/reference/global_objects/array/shift/index.md index bc7684c04cf15c..0a7c9945b808bb 100644 --- a/files/fr/web/javascript/reference/global_objects/array/shift/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/shift/index.md @@ -13,7 +13,7 @@ La méthode **`shift()`** permet de retirer le **premier** élément d'un tablea ## Syntaxe ```js -arr.shift() +arr.shift(); ``` ### Valeur de retour @@ -57,7 +57,7 @@ La méthode `shift()` peut être utilisée dans une boucle [`while`](/fr/docs/We ```js var noms = ["André", "Édouard", "Paul", "Christophe", "Jean"]; -while ( (i = noms.shift()) !== undefined ) { +while ((i = noms.shift()) !== undefined) { console.log(i); } // André, Édouard, Paul, Christophe, Jean diff --git a/files/fr/web/javascript/reference/global_objects/array/slice/index.md b/files/fr/web/javascript/reference/global_objects/array/slice/index.md index 3bdadd65fa457a..3f6ee9c9767a94 100644 --- a/files/fr/web/javascript/reference/global_objects/array/slice/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/slice/index.md @@ -13,9 +13,9 @@ La méthode **`slice()`** renvoie un objet tableau, contenant une copie superfic ## Syntaxe ```js -arr.slice() -arr.slice(début) -arr.slice(début, fin) +arr.slice(); +arr.slice(début); +arr.slice(début, fin); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/array/some/index.md b/files/fr/web/javascript/reference/global_objects/array/some/index.md index 0ff93808f3e5e7..34216aa5f25a7f 100644 --- a/files/fr/web/javascript/reference/global_objects/array/some/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/some/index.md @@ -58,7 +58,7 @@ L'exemple suivant teste si certains éléments d'un tableau sont plus grands que ```js function estAssezGrand(element, indice, array) { - return (element >= 10); + return element >= 10; } var resultat = [2, 5, 8, 1, 4].some(estAssezGrand); // resultat vaut false @@ -71,8 +71,8 @@ passed = [12, 5, 8, 1, 4].some(estAssezGrand); [Les fonctions fléchées](/fr/docs/Web/JavaScript/Reference/Fonctions/Fonctions_fléchées) permettent d'utiliser une syntaxe plus concise pour réaliser la même opération que l'exemple précédent. ```js -[2, 5, 8, 1, 4].some(elem => elem > 10); // false -[12, 5, 8, 1, 4].some(elem => elem > 10); // true +[2, 5, 8, 1, 4].some((elem) => elem > 10); // false +[12, 5, 8, 1, 4].some((elem) => elem > 10); // true ``` > **Note :** Si on veut vérifier qu'un élément est dans un tableau, on pourra utiliser la méthode {{jsxref("Array.prototype.includes()")}}. diff --git a/files/fr/web/javascript/reference/global_objects/array/sort/index.md b/files/fr/web/javascript/reference/global_objects/array/sort/index.md index 4d16550a5c5bf7..24ae6d4b448a00 100644 --- a/files/fr/web/javascript/reference/global_objects/array/sort/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/sort/index.md @@ -15,8 +15,8 @@ La complexité en espace mémoire et en temps utilisée pour le tri ne peut pas ## Syntaxe ```js -arr.sort() -arr.sort(fonctionComparaison) +arr.sort(); +arr.sort(fonctionComparaison); ``` ### Paramètres @@ -66,7 +66,7 @@ L'usage des {{jsxref("Opérateurs/L_opérateur_function", "expressions de foncti ```js var nombres = [4, 2, 5, 1, 3]; -nombres.sort(function(a, b) { +nombres.sort(function (a, b) { return a - b; }); console.log(nombres); @@ -90,7 +90,7 @@ var items = [ { name: "And", value: 45 }, { name: "The", value: -12 }, { name: "Magnetic", value: 13 }, - { name: "Zeros", value: 37 } + { name: "Zeros", value: 37 }, ]; items.sort(function (a, b) { return a.value - b.value; @@ -117,8 +117,7 @@ a[5] = "zèbre"; function writeArray(x) { for (i = 0; i < x.length; i++) { console.log(x[i]); - if (i < x.length-1) - console.log(", "); + if (i < x.length - 1) console.log(", "); } } @@ -158,20 +157,44 @@ function compareNombres(a, b) { return a - b; } -console.log("Chaînes : " + stringArray.join() +"\n"); -console.log("Triées : " + stringArray.sort() +"\n\n"); - -console.log("Nombres : " + numberArray.join() +"\n"); -console.log("Triés sans fonction de comparaison : " + numberArray.sort() +"\n"); -console.log("Triés avec compareNombres : " + numberArray.sort(compareNombres) +"\n\n"); - -console.log("Chaînes numériques : " + numericStringArray.join() +"\n"); -console.log("Triées sans fonction de comparaison : " + numericStringArray.sort() +"\n"); -console.log("Triées avec compareNombres : " + numericStringArray.sort(compareNombres) +"\n\n"); - -console.log("Nombres et chaînes numériques : " + mixedNumericArray.join() +"\n"); -console.log("Triés sans fonction de comparaison : " + mixedNumericArray.sort() +"\n"); -console.log("Triés avec compareNombres : " + mixedNumericArray.sort(compareNombres) +"\n\n"); +console.log("Chaînes : " + stringArray.join() + "\n"); +console.log("Triées : " + stringArray.sort() + "\n\n"); + +console.log("Nombres : " + numberArray.join() + "\n"); +console.log( + "Triés sans fonction de comparaison : " + numberArray.sort() + "\n", +); +console.log( + "Triés avec compareNombres : " + + numberArray.sort(compareNombres) + + "\n\n", +); + +console.log("Chaînes numériques : " + numericStringArray.join() + "\n"); +console.log( + "Triées sans fonction de comparaison : " + + numericStringArray.sort() + + "\n", +); +console.log( + "Triées avec compareNombres : " + + numericStringArray.sort(compareNombres) + + "\n\n", +); + +console.log( + "Nombres et chaînes numériques : " + mixedNumericArray.join() + "\n", +); +console.log( + "Triés sans fonction de comparaison : " + + mixedNumericArray.sort() + + "\n", +); +console.log( + "Triés avec compareNombres : " + + mixedNumericArray.sort(compareNombres) + + "\n\n", +); ``` Cet exemple produit la sortie suivante. Comme on peut le voir, lorsqu'on utilise la fonction de comparaison, les nombres sont triés correctement qu'ils soient des nombres ou des chaînes numériques. @@ -198,7 +221,7 @@ Triés avec compareNombres : 1,5,9,40,80,200,700 Pour des chaines de caractères contenant des caractères non ASCII, c'est à dire des chaines de caractères contenant par exemple des accents (é, è, a, ä, etc.) : utilisez {{jsxref("String.localeCompare")}}. Cette fonction peut comparer ces caractères afin qu'ils apparaissent dans le bon ordre. ```js -var items = ["réservé", "premier", "cliché", "communiqué", "café" ,"adieu"]; +var items = ["réservé", "premier", "cliché", "communiqué", "café", "adieu"]; items.sort(function (a, b) { return a.localeCompare(b); }); @@ -212,16 +235,16 @@ La fonction de comparaison peut être amenée à être appelée plusieurs fois p ```js // le tableau à trier -var liste = ['Delta', 'alpha', 'CHARLIE', 'bravo']; +var liste = ["Delta", "alpha", "CHARLIE", "bravo"]; // Création d'objet temporaire qui contient les positions // et les valeurs en minuscules -var mapped = liste.map(function(e, i) { +var mapped = liste.map(function (e, i) { return { index: i, value: e.toLowerCase() }; -}) +}); // on trie l'objet temporaire avec les valeurs réduites -mapped.sort(function(a, b) { +mapped.sort(function (a, b) { if (a.value > b.value) { return 1; } @@ -232,7 +255,7 @@ mapped.sort(function(a, b) { }); // on utilise un objet final pour les résultats -var result = mapped.map(function(e){ +var result = mapped.map(function (e) { return liste[e.index]; }); ``` diff --git a/files/fr/web/javascript/reference/global_objects/array/splice/index.md b/files/fr/web/javascript/reference/global_objects/array/splice/index.md index 7f3707c3e27e1d..4f6a8afcc47caa 100644 --- a/files/fr/web/javascript/reference/global_objects/array/splice/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/splice/index.md @@ -41,7 +41,7 @@ Si vous spécifiez un nombre différent d'éléments à insérer et d'éléments Le script suivant illustre l'utilisation de `splice` : ```js -var mesPoissons = ["scalaire", "clown", "mandarin", "chirurgien"]; +var mesPoissons = ["scalaire", "clown", "mandarin", "chirurgien"]; // supprime 0 élément à partir de l'index 2, et insère "tambour" var enleves = mesPoissons.splice(2, 0, "tambour"); diff --git a/files/fr/web/javascript/reference/global_objects/array/tolocalestring/index.md b/files/fr/web/javascript/reference/global_objects/array/tolocalestring/index.md index 20721cf74490d7..32106673f7bc82 100644 --- a/files/fr/web/javascript/reference/global_objects/array/tolocalestring/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/tolocalestring/index.md @@ -43,7 +43,7 @@ Ici, on voit qu'on affiche le symbole de la devise de la locale pour chacun des ```js var prix = ["¥7", 500, 8123, 12]; -prix.toLocaleString('ja-JP', { style: 'currency', currency: 'JPY' }); +prix.toLocaleString("ja-JP", { style: "currency", currency: "JPY" }); // "¥7,¥500,¥8,123,¥12" ``` @@ -55,8 +55,8 @@ Pour plus d'exemples, on peut se référer aux pages {{jsxref("Intl")}}, {{jsxre ```js // https://tc39.github.io/ecma402/#sup-array.prototype.tolocalestring if (!Array.prototype.toLocaleString) { - Object.defineProperty(Array.prototype, 'toLocaleString', { - value: function(locales, options) { + Object.defineProperty(Array.prototype, "toLocaleString", { + value: function (locales, options) { // 1. Let O be ? ToObject(this value). if (this == null) { throw new TypeError('"this" is null or not defined'); @@ -72,11 +72,11 @@ if (!Array.prototype.toLocaleString) { // host environment's current locale (this is // derived in an implementation-defined way). // NOTE: In this case, we will use a comma - var separator = ','; + var separator = ","; // 4. If len is zero, return the empty String. if (len === 0) { - return ''; + return ""; } // 5. Let firstElement be ? Get(A, "0"). @@ -92,8 +92,10 @@ if (!Array.prototype.toLocaleString) { // « locales, options » // ) // ) - var r = firstElement == null ? - '' : firstElement.toLocaleString(locales, options); + var r = + firstElement == null + ? "" + : firstElement.toLocaleString(locales, options); // 8. Let k be 1. var k = 1; @@ -118,8 +120,10 @@ if (!Array.prototype.toLocaleString) { // « locales, options » // ) // ) - r = nextElement == null ? - '' : nextElement.toLocaleString(locales, options); + r = + nextElement == null + ? "" + : nextElement.toLocaleString(locales, options); // e. Let R be a String value produced by // concatenating S and R. @@ -131,7 +135,7 @@ if (!Array.prototype.toLocaleString) { // 10. Return R. return r; - } + }, }); } ``` diff --git a/files/fr/web/javascript/reference/global_objects/array/tostring/index.md b/files/fr/web/javascript/reference/global_objects/array/tostring/index.md index 7cbef9d5e4929a..f6f877da1c4dc3 100644 --- a/files/fr/web/javascript/reference/global_objects/array/tostring/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/tostring/index.md @@ -13,7 +13,7 @@ La méthode **`toString()`** renvoie une chaine de caractères représentant le ## Syntaxe ```js -arr.toString() +arr.toString(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/array/unshift/index.md b/files/fr/web/javascript/reference/global_objects/array/unshift/index.md index bb383cf550e95d..4f2b886ec16816 100644 --- a/files/fr/web/javascript/reference/global_objects/array/unshift/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/unshift/index.md @@ -61,7 +61,7 @@ arr.unshift(0); // renvoie 3, la nouvelle longueur du tableau arr.unshift(-2, -1); // = 5 // arr est [-2, -1, 0, 1, 2] -arr.unshift( [-3] ); // 6 +arr.unshift([-3]); // 6 // arr est [[-3], -2, -1, 0, 1, 2] arr.unshift([-7, -6], [-5]); // 8 diff --git a/files/fr/web/javascript/reference/global_objects/array/values/index.md b/files/fr/web/javascript/reference/global_objects/array/values/index.md index c6727eb51e6dce..42ae19b0dd5b0a 100644 --- a/files/fr/web/javascript/reference/global_objects/array/values/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/values/index.md @@ -11,7 +11,7 @@ La méthode **`values()`** renvoie un nouvel objet **`Array Iterator`** qui cont {{EmbedInteractiveExample("pages/js/array-values.html")}} ```js -var a = ['t', 'i', 't', 'o', 'u']; +var a = ["t", "i", "t", "o", "u"]; var iterateur = a.values(); console.log(iterateur.next().value); // t @@ -24,7 +24,7 @@ console.log(iterateur.next().value); // u ## Syntaxe ```js -array.values() +array.values(); ``` ### Valeur de retour @@ -36,7 +36,7 @@ Un nouvel objet itérateur sur {{jsxref("Array")}}. ### Itérer avec une boucle `for...of` ```js -var arr = ['w', 'y', 'k', 'o', 'p']; +var arr = ["w", "y", "k", "o", "p"]; var eArr = arr.values(); // votre navigateur doit supporter les boucles for..of // et les variables définies avec let @@ -48,7 +48,7 @@ for (let lettre of eArr) { ### Itérer avec `next()` ```js -var arr = ['w', 'y', 'k', 'o', 'p']; +var arr = ["w", "y", "k", "o", "p"]; var eArr = arr.values(); console.log(eArr.next().value); // w console.log(eArr.next().value); // y diff --git a/files/fr/web/javascript/reference/global_objects/arraybuffer/@@species/index.md b/files/fr/web/javascript/reference/global_objects/arraybuffer/@@species/index.md index cb621a591678c5..8c7ce855756af8 100644 --- a/files/fr/web/javascript/reference/global_objects/arraybuffer/@@species/index.md +++ b/files/fr/web/javascript/reference/global_objects/arraybuffer/@@species/index.md @@ -11,7 +11,7 @@ La propriété d'accesseur **`ArrayBuffer[@@species]`** renvoie le constructeur ## Syntaxe ```js -ArrayBuffer[Symbol.species] +ArrayBuffer[Symbol.species]; ``` ## Description @@ -32,7 +32,9 @@ Pour un objet dérivé (par exemple une classe sur mesure `MonArrayBuffer`), le class MonArrayBuffer extends ArrayBuffer { // On surcharge species pour renvoyer // le constructeur parent ArrayBuffer - static get [Symbol.species]() { return ArrayBuffer; } + static get [Symbol.species]() { + return ArrayBuffer; + } } ``` diff --git a/files/fr/web/javascript/reference/global_objects/arraybuffer/arraybuffer/index.md b/files/fr/web/javascript/reference/global_objects/arraybuffer/arraybuffer/index.md index 79f1146657b353..9001afcc591c8c 100644 --- a/files/fr/web/javascript/reference/global_objects/arraybuffer/arraybuffer/index.md +++ b/files/fr/web/javascript/reference/global_objects/arraybuffer/arraybuffer/index.md @@ -13,7 +13,7 @@ Le **constructeur `ArrayBuffer()`** permet de créer des objets [`ArrayBuffer`]( ## Syntaxe ```js -new ArrayBuffer(longueur) +new ArrayBuffer(longueur); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/arraybuffer/bytelength/index.md b/files/fr/web/javascript/reference/global_objects/arraybuffer/bytelength/index.md index fe48cd2ea83593..93ce8d40987c9f 100644 --- a/files/fr/web/javascript/reference/global_objects/arraybuffer/bytelength/index.md +++ b/files/fr/web/javascript/reference/global_objects/arraybuffer/bytelength/index.md @@ -13,7 +13,7 @@ L'accesseur **`byteLength`** est une propriété représentant la longueur d'un ## Syntaxe ```js -arraybuffer.byteLength +arraybuffer.byteLength; ``` ## Description diff --git a/files/fr/web/javascript/reference/global_objects/arraybuffer/isview/index.md b/files/fr/web/javascript/reference/global_objects/arraybuffer/isview/index.md index fcce75a573659a..8b993a6d8eebe7 100644 --- a/files/fr/web/javascript/reference/global_objects/arraybuffer/isview/index.md +++ b/files/fr/web/javascript/reference/global_objects/arraybuffer/isview/index.md @@ -13,7 +13,7 @@ La méthode **`ArrayBuffer.isView()`** renvoie `true` si l'argument passé est u ## Syntaxe ```js -ArrayBuffer.isView(arg) +ArrayBuffer.isView(arg); ``` ### Paramètres @@ -28,15 +28,15 @@ ArrayBuffer.isView(arg) ## Exemples ```js -ArrayBuffer.isView(); // false -ArrayBuffer.isView([]); // false -ArrayBuffer.isView({}); // false -ArrayBuffer.isView(null); // false -ArrayBuffer.isView(undefined); // false +ArrayBuffer.isView(); // false +ArrayBuffer.isView([]); // false +ArrayBuffer.isView({}); // false +ArrayBuffer.isView(null); // false +ArrayBuffer.isView(undefined); // false ArrayBuffer.isView(new ArrayBuffer(10)); // false -ArrayBuffer.isView(new Uint8Array()); // true -ArrayBuffer.isView(new Float32Array()); // true +ArrayBuffer.isView(new Uint8Array()); // true +ArrayBuffer.isView(new Float32Array()); // true ArrayBuffer.isView(new Int8Array(10).subarray(0, 3)); // true var buffer = new ArrayBuffer(2); diff --git a/files/fr/web/javascript/reference/global_objects/arraybuffer/slice/index.md b/files/fr/web/javascript/reference/global_objects/arraybuffer/slice/index.md index 1c99c0fa94c905..9e7d67b34229c1 100644 --- a/files/fr/web/javascript/reference/global_objects/arraybuffer/slice/index.md +++ b/files/fr/web/javascript/reference/global_objects/arraybuffer/slice/index.md @@ -37,7 +37,7 @@ La méthode `slice` copie les octets contenus jusqu'au (au sens exclusif) param ```js var buf1 = new ArrayBuffer(8); -var buf2 = buf1.slice(0) +var buf2 = buf1.slice(0); ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/asyncfunction/index.md b/files/fr/web/javascript/reference/global_objects/asyncfunction/index.md index a08cd17029987d..46474a1107bca6 100644 --- a/files/fr/web/javascript/reference/global_objects/asyncfunction/index.md +++ b/files/fr/web/javascript/reference/global_objects/asyncfunction/index.md @@ -8,18 +8,18 @@ translation_of: Web/JavaScript/Reference/Global_Objects/AsyncFunction Le constructeur **`AsyncFunction`** crée un nouvel objet pour [une fonction asynchrone](/fr/docs/Web/JavaScript/Reference/Statements/async_function). En JavaScript, chaque fonction asynchrone est en fait un objet `AsyncFunction`. -On notera que `AsyncFunction` *n'est pas* un objet global. On peut l'obtenir grâce au code suivant : +On notera que `AsyncFunction` _n'est pas_ un objet global. On peut l'obtenir grâce au code suivant : ```js -Object.getPrototypeOf(async function(){}).constructor +Object.getPrototypeOf(async function () {}).constructor; ``` ## Syntaxe ```js -new AsyncFunction(arg0, corpsFonction) -new AsyncFunction(arg0, arg1, corpsFonction) -new AsyncFunction(arg0, arg1, ...argN, corpsFonction) +new AsyncFunction(arg0, corpsFonction); +new AsyncFunction(arg0, arg1, corpsFonction); +new AsyncFunction(arg0, arg1, ...argN, corpsFonction); ``` ### Paramètres @@ -53,20 +53,22 @@ Si on appelle `AsyncFunction` comme une fonction (c'est-à-dire sans `new`), cel ```js function resoudreApres2Secondes(x) { - return new Promise(resolve => { + return new Promise((resolve) => { setTimeout(() => { resolve(x); }, 2000); }); } -let AsyncFunction = Object.getPrototypeOf(async function(){}).constructor; +let AsyncFunction = Object.getPrototypeOf(async function () {}).constructor; -let a = new AsyncFunction('a', - 'b', - 'return await resoudreApres2Secondes(a) + await resoudreApres2Secondes(b);'); +let a = new AsyncFunction( + "a", + "b", + "return await resoudreApres2Secondes(a) + await resoudreApres2Secondes(b);", +); -a(10, 20).then(v => { +a(10, 20).then((v) => { console.log(v); // affiche 30 dans la console après 4 secondes }); ``` diff --git a/files/fr/web/javascript/reference/global_objects/atomics/add/index.md b/files/fr/web/javascript/reference/global_objects/atomics/add/index.md index cd2a050f226b3c..a339c81c77b453 100644 --- a/files/fr/web/javascript/reference/global_objects/atomics/add/index.md +++ b/files/fr/web/javascript/reference/global_objects/atomics/add/index.md @@ -13,7 +13,7 @@ La méthode statique **`Atomics.add()`** ajoute une valeur donnée à un éléme ## Syntaxe ```js -Atomics.add(typedArray, index, valeur) +Atomics.add(typedArray, index, valeur); ``` ### Paramètres @@ -42,7 +42,7 @@ var sab = new SharedArrayBuffer(1024); var ta = new Uint8Array(sab); Atomics.add(ta, 0, 12); // renvoie 0, l'ancienne valeur -Atomics.load(ta, 0); // 12 +Atomics.load(ta, 0); // 12 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/atomics/and/index.md b/files/fr/web/javascript/reference/global_objects/atomics/and/index.md index 13b20d197a56cb..721c80ee46818d 100644 --- a/files/fr/web/javascript/reference/global_objects/atomics/and/index.md +++ b/files/fr/web/javascript/reference/global_objects/atomics/and/index.md @@ -13,7 +13,7 @@ La méthode statique **`Atomics.and()`** calcule un ET binaire avec une valeur d ## Syntaxe ```js -Atomics.and(typedArray, index, valeur) +Atomics.and(typedArray, index, valeur); ``` ### Paramètres @@ -64,7 +64,7 @@ var ta = new Uint8Array(sab); ta[0] = 5; Atomics.and(ta, 0, 1); // renvoie 0, l'ancienne valeur -Atomics.load(ta, 0); // 1 +Atomics.load(ta, 0); // 1 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/atomics/compareexchange/index.md b/files/fr/web/javascript/reference/global_objects/atomics/compareexchange/index.md index 688c52cb42c47f..521ab48e93f84f 100644 --- a/files/fr/web/javascript/reference/global_objects/atomics/compareexchange/index.md +++ b/files/fr/web/javascript/reference/global_objects/atomics/compareexchange/index.md @@ -13,7 +13,7 @@ La méthode statique **`Atomics.compareExchange()`** échange une valeur d'un ta ## Syntaxe ```js -Atomics.compareExchange(typedArray, index, valeurAttendue, valeurRemplacement) +Atomics.compareExchange(typedArray, index, valeurAttendue, valeurRemplacement); ``` ### Paramètres @@ -45,7 +45,7 @@ var ta = new Uint8Array(sab); ta[0] = 7; Atomics.compareExchange(ta, 0, 7, 12); // renvoie 7, l'ancienne valeur -Atomics.load(ta, 0); // 12 +Atomics.load(ta, 0); // 12 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/atomics/exchange/index.md b/files/fr/web/javascript/reference/global_objects/atomics/exchange/index.md index 4f6b3a10c5f49c..70d877eca92cdb 100644 --- a/files/fr/web/javascript/reference/global_objects/atomics/exchange/index.md +++ b/files/fr/web/javascript/reference/global_objects/atomics/exchange/index.md @@ -13,7 +13,7 @@ La méthode statique **`Atomics.exchange()`** permet d'enregistrer une valeur à ## Syntaxe ```js -Atomics.exchange(typedArray, index, valeur) +Atomics.exchange(typedArray, index, valeur); ``` ### Paramètres @@ -41,8 +41,8 @@ L'ancienne valeur qui était contenue à (`typedArray[index]`). var sab = new SharedArrayBuffer(1024); var ta = new Uint8Array(sab); -Atomics.exchange(ta, 0, 12); // renvoie 0, l'ancienne valeur -Atomics.load(ta, 0); // 12 +Atomics.exchange(ta, 0, 12); // renvoie 0, l'ancienne valeur +Atomics.load(ta, 0); // 12 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/atomics/islockfree/index.md b/files/fr/web/javascript/reference/global_objects/atomics/islockfree/index.md index 314215e57ccc84..89b53c0ff4b501 100644 --- a/files/fr/web/javascript/reference/global_objects/atomics/islockfree/index.md +++ b/files/fr/web/javascript/reference/global_objects/atomics/islockfree/index.md @@ -6,14 +6,14 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Atomics/isLockFree {{JSRef}} -La méthode statique **`Atomics.isLockFree()`** est utilisée afin de déterminer si on doit utiliser des verrous (*locks*) ou des opérations atomiques. Elle renvoie `true` si la taille donnée correspond à une des propriétés [`BYTES_PER_ELEMENT`](/fr/docs/Web/JavaScript/Reference/Objets_globaux/TypedArray/BYTES_PER_ELEMENT) d'un des types `TypedArray`. +La méthode statique **`Atomics.isLockFree()`** est utilisée afin de déterminer si on doit utiliser des verrous (_locks_) ou des opérations atomiques. Elle renvoie `true` si la taille donnée correspond à une des propriétés [`BYTES_PER_ELEMENT`](/fr/docs/Web/JavaScript/Reference/Objets_globaux/TypedArray/BYTES_PER_ELEMENT) d'un des types `TypedArray`. {{EmbedInteractiveExample("pages/js/atomics-islockfree.html")}} ## Syntaxe ```js -Atomics.isLockFree(taille) +Atomics.isLockFree(taille); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/atomics/load/index.md b/files/fr/web/javascript/reference/global_objects/atomics/load/index.md index 64bad02717980d..8bae2ad26d1ed8 100644 --- a/files/fr/web/javascript/reference/global_objects/atomics/load/index.md +++ b/files/fr/web/javascript/reference/global_objects/atomics/load/index.md @@ -13,7 +13,7 @@ La méthode statique **`Atomics.load()`** renvoie une valeur située à une posi ## Syntaxe ```js -Atomics.load(typedArray, index) +Atomics.load(typedArray, index); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/atomics/notify/index.md b/files/fr/web/javascript/reference/global_objects/atomics/notify/index.md index 5f198120bdf4dc..9e623a1a82770f 100644 --- a/files/fr/web/javascript/reference/global_objects/atomics/notify/index.md +++ b/files/fr/web/javascript/reference/global_objects/atomics/notify/index.md @@ -13,7 +13,7 @@ La méthode statique **`Atomics.notify()`** permet de réveiller des agents dorm ## Syntaxe ```js -Atomics.notify(typedArray, index, count) +Atomics.notify(typedArray, index, count); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/atomics/or/index.md b/files/fr/web/javascript/reference/global_objects/atomics/or/index.md index 94909c0ccdc43e..3f8213555aff3f 100644 --- a/files/fr/web/javascript/reference/global_objects/atomics/or/index.md +++ b/files/fr/web/javascript/reference/global_objects/atomics/or/index.md @@ -13,7 +13,7 @@ La méthode statique **`Atomics.or()`** calcule le résultat d'un OU binaire ent ## Syntaxe ```js -Atomics.or(typedArray, index, value) +Atomics.or(typedArray, index, value); ``` ### Paramètres @@ -64,7 +64,7 @@ var ta = new Uint8Array(sab); ta[0] = 2; Atomics.or(ta, 0, 1); // renvoie 2, l'ancienne valeur -Atomics.load(ta, 0); // 3 +Atomics.load(ta, 0); // 3 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/atomics/store/index.md b/files/fr/web/javascript/reference/global_objects/atomics/store/index.md index 87586da523bcc7..5c2614746064ae 100644 --- a/files/fr/web/javascript/reference/global_objects/atomics/store/index.md +++ b/files/fr/web/javascript/reference/global_objects/atomics/store/index.md @@ -13,7 +13,7 @@ La méthode statique **`Atomics.store()`** enregistre une valeur donnée à un e ## Syntaxe ```js -Atomics.store(typedArray, index, valeur) +Atomics.store(typedArray, index, valeur); ``` ### Paramètres @@ -38,14 +38,14 @@ La valeur qui a été enregistrée. ## Exemples ```js -var buffer = new ArrayBuffer(4); // Buffer classique -var float32 = new Float32Array(buffer); // Nombre flottant -var uint32 = new Uint32Array(buffer); // Représentation IEEE754 +var buffer = new ArrayBuffer(4); // Buffer classique +var float32 = new Float32Array(buffer); // Nombre flottant +var uint32 = new Uint32Array(buffer); // Représentation IEEE754 float32[0] = 0.5; console.log("0x" + uint32[0].toString(16)); -uint32[0] = 0x3f000000; /// Représentation sur 32 bits de 0.5 (IEEE754) +uint32[0] = 0x3f000000; /// Représentation sur 32 bits de 0.5 (IEEE754) console.log(float32[0]); ``` diff --git a/files/fr/web/javascript/reference/global_objects/atomics/sub/index.md b/files/fr/web/javascript/reference/global_objects/atomics/sub/index.md index 6b9c68b6c8cc51..4a3e7b907f5839 100644 --- a/files/fr/web/javascript/reference/global_objects/atomics/sub/index.md +++ b/files/fr/web/javascript/reference/global_objects/atomics/sub/index.md @@ -13,7 +13,7 @@ La méthode statique **`Atomics.sub()`** permet de soustraire une valeur donnée ## Syntaxe ```js -Atomics.sub(typedArray, index, valeur) +Atomics.sub(typedArray, index, valeur); ``` ### Paramètres @@ -43,7 +43,7 @@ var ta = new Uint8Array(sab); ta[0] = 48; Atomics.sub(ta, 0, 12); // renvoie 48, l'ancienne valeur -Atomics.load(ta, 0); // 36 +Atomics.load(ta, 0); // 36 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/atomics/waitasync/index.md b/files/fr/web/javascript/reference/global_objects/atomics/waitasync/index.md index c8b2133362c8df..ff5881c945bfd2 100644 --- a/files/fr/web/javascript/reference/global_objects/atomics/waitasync/index.md +++ b/files/fr/web/javascript/reference/global_objects/atomics/waitasync/index.md @@ -15,8 +15,8 @@ La méthode statique **`Atomics.waitAsync()`** permet d'attendre de façon async ## Syntaxe ```js -Atomics.waitAsync(typedArray, index, value) -Atomics.waitAsync(typedArray, index, value, timeout) +Atomics.waitAsync(typedArray, index, value); +Atomics.waitAsync(typedArray, index, value, timeout); ``` ### Paramètres @@ -36,7 +36,7 @@ Un objet [`Promise`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Promise) d ```js { async: false, value: 'ok' } -{ async: false, value: 'not-equal' } +{ async: false, value: 'not-equal' } { async: false, value: 'timed-out' } { async: true, value: promise } ``` diff --git a/files/fr/web/javascript/reference/global_objects/atomics/xor/index.md b/files/fr/web/javascript/reference/global_objects/atomics/xor/index.md index cc38aef27e5db7..7ea2861c55d308 100644 --- a/files/fr/web/javascript/reference/global_objects/atomics/xor/index.md +++ b/files/fr/web/javascript/reference/global_objects/atomics/xor/index.md @@ -13,7 +13,7 @@ La méthode statique **`Atomics.xor()`** calcule le résultat d'un OU exclusif ( ## Syntaxe ```js -Atomics.xor(typedArray, index, valeur) +Atomics.xor(typedArray, index, valeur); ``` ### Paramètres @@ -64,7 +64,7 @@ var ta = new Uint8Array(sab); ta[0] = 5; Atomics.xor(ta, 0, 1); // renvoie 5, l'ancienne valeur -Atomics.load(ta, 0); // 4 +Atomics.load(ta, 0); // 4 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/bigint/index.md b/files/fr/web/javascript/reference/global_objects/bigint/index.md index 507f57fdae7c17..9bab8d1257e66a 100644 --- a/files/fr/web/javascript/reference/global_objects/bigint/index.md +++ b/files/fr/web/javascript/reference/global_objects/bigint/index.md @@ -18,16 +18,18 @@ const plusGrandEntier = 9007199254740991n; const grandNombre = BigInt(9007199254740991); // ↪ 9007199254740991n -const grandNombreEnChaîne = BigInt('9007199254740991'); +const grandNombreEnChaîne = BigInt("9007199254740991"); // ↪ 9007199254740991n -const grandeNombreHexa = BigInt('0x1fffffffffffff'); +const grandeNombreHexa = BigInt("0x1fffffffffffff"); // ↪ 9007199254740991n -const grandNombreOctal = BigInt('0o377777777777777777'); +const grandNombreOctal = BigInt("0o377777777777777777"); // ↪ 9007199254740991n -const grandeNombreBinaire = BigInt('0b11111111111111111111111111111111111111111111111111111'); +const grandeNombreBinaire = BigInt( + "0b11111111111111111111111111111111111111111111111111111", +); // ↪ 9007199254740991n ``` @@ -38,14 +40,14 @@ Les objets `BigInt` sont semblables aux objets [`Number`](/fr/docs/Web/JavaScrip Lorsqu'on utilise `typeof` sur une valeur `BigInt`, cet opérateur renverra `"bigint"` : ```js -typeof 1n === 'bigint'; // true -typeof BigInt('1') === 'bigint'; // true +typeof 1n === "bigint"; // true +typeof BigInt("1") === "bigint"; // true ``` Lorsqu'on « enveloppe » la valeur primitive dans un objet, on aura alors un type `"object"` (comme pour les autres valeurs primitives lorsqu'on les enveloppe dans le constructeur objet) : ```js -typeof Object(1n) === 'object'; // true +typeof Object(1n) === "object"; // true ``` ### Opérateurs @@ -111,19 +113,19 @@ Un objet `BigInt` n'est pas strictement égal à [`Number`](/fr/docs/Web/JavaScr On peut toutefois comparer des objets [`Number`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Number) et `BigInt` : ```js -1n < 2 +1n < 2; // ↪ true -2n > 1 +2n > 1; // ↪ true -2 > 2 +2 > 2; // ↪ false -2n > 2 +2n > 2; // ↪ false -2n >= 2 +2n >= 2; // ↪ true ``` @@ -137,23 +139,23 @@ mixed.sort(); // ↪ [-12n, 0, 0n, 10, 4n, 4, 6] mixed.sort((a, b) => a - b); -// ne fonctionnera pas car la soustraction ne +// ne fonctionnera pas car la soustraction ne // fonctionne pas sur des types mixtes // TypeError: can't convert BigInt value to Number value // On peut trier avec un comparateur numérique approprié -mixed.sort((a, b) => (a < b) ? -1 : ((a > b) ? 1 : 0)); +mixed.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0)); // ↪ [ -12n, 0, 0n, 4n, 4, 6, 10 ] ``` On notera que les comparaisons entre les valeurs `BigInt` et les mêmes valeurs, passées dans le constructeur `Object()`, ne seront pas équivalentes au sens strict : ```js -0n === Object(0n); // false -Object(0n) === Object(0n); // false +0n === Object(0n); // false +Object(0n) === Object(0n); // false const o = Object(0n); -o === o; // true +o === o; // true ``` ### Opérations conditionnelles @@ -162,29 +164,29 @@ Une valeur `BigInt` se comporte comme une valeur [`Number`](/fr/docs/Web/JavaScr ```js if (0n) { - console.log('Nous voici dans le if !'); + console.log("Nous voici dans le if !"); } else { - console.log('Et nous voilà dans le else !'); + console.log("Et nous voilà dans le else !"); } // ↪ "Et nous voilà dans le else !" -0n || 12n +0n || 12n; // ↪ 12n -0n && 12n +0n && 12n; // ↪ 0n -Boolean(0n) +Boolean(0n); // ↪ false -Boolean(12n) +Boolean(12n); // ↪ true -!12n +!12n; // ↪ false -!0n +!0n; // ↪ true ``` @@ -228,7 +230,7 @@ L'utilisation de [`JSON.stringify()`](/fr/docs/Web/JavaScript/Reference/Global_O ```js function remplacement(cle, valeur) { - if (cle === 'big') { + if (cle === "big") { return valeur.toString(); } return valeur; @@ -236,7 +238,7 @@ function remplacement(cle, valeur) { const donnee = { number: 1, - big: BigInt('18014398509481982'), + big: BigInt("18014398509481982"), }; const chaine = JSON.stringify(donnee, remplacement); @@ -248,7 +250,7 @@ Si vous avez des données JSON contenant des valeurs dont vous savez qu'il s'agi ```js function reviver(cle, value) { - if (cle === 'big') { + if (cle === "big") { return BigInt(value); } return value; diff --git a/files/fr/web/javascript/reference/global_objects/bigint/tolocalestring/index.md b/files/fr/web/javascript/reference/global_objects/bigint/tolocalestring/index.md index cff64b0c698dae..ee8824d93cd404 100644 --- a/files/fr/web/javascript/reference/global_objects/bigint/tolocalestring/index.md +++ b/files/fr/web/javascript/reference/global_objects/bigint/tolocalestring/index.md @@ -49,28 +49,28 @@ var bigint = 123456789123456789n; // En allemand, on utilise les points pour séparer // les milliers -console.log(bigint.toLocaleString('de-DE')); +console.log(bigint.toLocaleString("de-DE")); // → 123.456.789.123.456.789 // La plupart des pays arabes utilise // des chiffres hindoux-arabes -console.log(bigint.toLocaleString('ar-EG')); +console.log(bigint.toLocaleString("ar-EG")); // → ١٢٣٬٤٥٦٬٧٨٩٬١٢٣٬٤٥٦٬٧٨٩ // India utilise des séparateurs pour // les milliers/lakh/crore -console.log(bigint.toLocaleString('en-IN')); +console.log(bigint.toLocaleString("en-IN")); // → 1,23,45,67,89,12,34,56,789 // La clé d'extension requiert un système de numérotation // par exemple, le système décimal chinois -console.log(bigint.toLocaleString('zh-Hans-CN-u-nu-hanidec')); +console.log(bigint.toLocaleString("zh-Hans-CN-u-nu-hanidec")); // → 一二三,四五六,七八九,一二三,四五六,七八九 // Lorsqu'on demande une langue qui peut ne pas être prise // en charge (ici le balinais), on peut ajouter une autre // locale qui sera utilisée en recours (ici l'indonésien) -console.log(bigint.toLocaleString(['ban', 'id'])); +console.log(bigint.toLocaleString(["ban", "id"])); // → 123.456.789.123.456.789 ``` @@ -82,15 +82,19 @@ Ici, on personnalise le résultat fourni par `toLocaleString()` grâce à l'argu var bigint = 123456789123456789n; // On utilise un format avec une devise -console.log(bigint.toLocaleString('de-DE', { style: 'currency', currency: 'EUR' })); +console.log( + bigint.toLocaleString("de-DE", { style: "currency", currency: "EUR" }), +); // → 123.456.789.123.456.789,00 € // Le yen japonais n'utilise pas de sous-unité -console.log(bigint.toLocaleString('ja-JP', { style: 'currency', currency: 'JPY' })) +console.log( + bigint.toLocaleString("ja-JP", { style: "currency", currency: "JPY" }), +); // → ¥123,456,789,123,456,789 // On limite l'écriture aux trois premiers chiffres significatifs -console.log(bigint.toLocaleString('en-IN', { maximumSignificantDigits: 3 })); +console.log(bigint.toLocaleString("en-IN", { maximumSignificantDigits: 3 })); // → 1,23,00,00,00,00,00,00,000 ``` diff --git a/files/fr/web/javascript/reference/global_objects/bigint/tostring/index.md b/files/fr/web/javascript/reference/global_objects/bigint/tostring/index.md index 51924769bf5478..d9a4980fe1d42f 100644 --- a/files/fr/web/javascript/reference/global_objects/bigint/tostring/index.md +++ b/files/fr/web/javascript/reference/global_objects/bigint/tostring/index.md @@ -13,7 +13,7 @@ The **`toString()`** method returns a string representing the specified {{jsxref ## Syntaxe ```js -bigIntObj.toString([base]) +bigIntObj.toString([base]); ``` ### Paramètres @@ -45,11 +45,11 @@ Si `bigIntObj` est négatif, le signe est conservé, y compris lorsque la base e ### Utiliser `toString()` ```js -17n.toString(); // '17' -66n.toString(2); // '1000010' -254n.toString(16); // 'fe' --10n.toString(2); // -1010' --0xffn.toString(2); // '-11111111' +17n.toString(); // '17' +66n.toString(2); // '1000010' +254n.toString(16); // 'fe' +-10n.toString(2); // -1010' +-0xffn.toString(2); // '-11111111' ``` ### Gestion du zéro négatif en `BigInt` @@ -57,7 +57,7 @@ Si `bigIntObj` est négatif, le signe est conservé, y compris lorsque la base e Il n'existe pas de zéro négatif pour `BigInt` car les entiers ne gèrent pas de concept de zéro négatif. `-0.0` est un concept relatif à la représentation flottante IEEE et n'est présent que pour le type {{jsxref("Number")}}. ```js -(-0n).toString(); // '0' +(-0n).toString(); // '0' BigInt(-0).toString(); // '0' ``` diff --git a/files/fr/web/javascript/reference/global_objects/bigint/valueof/index.md b/files/fr/web/javascript/reference/global_objects/bigint/valueof/index.md index 64fe0f23f1ca3e..da69e1269d68ab 100644 --- a/files/fr/web/javascript/reference/global_objects/bigint/valueof/index.md +++ b/files/fr/web/javascript/reference/global_objects/bigint/valueof/index.md @@ -13,7 +13,7 @@ La méthode **`valueOf()`** renvoie la valeur primitive encapsulée dans un obje ## Syntaxe ```js -bigIntObj.valueOf() +bigIntObj.valueOf(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/bigint64array/bigint64array/index.md b/files/fr/web/javascript/reference/global_objects/bigint64array/bigint64array/index.md index d3821df0e018a9..6df1901ff563bd 100644 --- a/files/fr/web/javascript/reference/global_objects/bigint64array/bigint64array/index.md +++ b/files/fr/web/javascript/reference/global_objects/bigint64array/bigint64array/index.md @@ -45,7 +45,7 @@ console.log(bigint64.length); // 2 console.log(bigint64.BYTES_PER_ELEMENT); // 8 // À partir d'un tableau -const arr = new BigInt64Array([21n,31n]); +const arr = new BigInt64Array([21n, 31n]); console.log(arr[1]); // 31n // À partir d'un autre tableau typé @@ -58,7 +58,9 @@ const buffer = new ArrayBuffer(32); const z = new BigInt64Array(buffer, 0, 4); // À partir d'un itérable -const iterable = function*(){ yield* [1n, 2n, 3n]; }(); +const iterable = (function* () { + yield* [1n, 2n, 3n]; +})(); const bigint64 = new BigInt64Array(iterable); // BigInt64Array[1n, 2n, 3n] ``` diff --git a/files/fr/web/javascript/reference/global_objects/bigint64array/index.md b/files/fr/web/javascript/reference/global_objects/bigint64array/index.md index f5e616e0390754..927a84796e2408 100644 --- a/files/fr/web/javascript/reference/global_objects/bigint64array/index.md +++ b/files/fr/web/javascript/reference/global_objects/bigint64array/index.md @@ -123,7 +123,7 @@ console.log(bigInt64.length); // 2 console.log(bigInt64.BYTES_PER_ELEMENT); // 8 // Construction à partir d'un tableau -var arr = new BigInt64Array([21n,31n]); +var arr = new BigInt64Array([21n, 31n]); console.log(arr[1]); // 31n // Construction à partir d'un tableau typé @@ -136,7 +136,9 @@ var buffer = new ArrayBuffer(32); var z = new BigInt64Array(buffer, 0, 4); // Construction à partir d'un itérable -var iterable = function*(){ yield* [1n, 2n, 3n]; }(); +var iterable = (function* () { + yield* [1n, 2n, 3n]; +})(); var BigInt64 = new BigInt64Array(iterable); // BigInt64Array[1n, 2n, 3n] ``` diff --git a/files/fr/web/javascript/reference/global_objects/biguint64array/biguint64array/index.md b/files/fr/web/javascript/reference/global_objects/biguint64array/biguint64array/index.md index 9de69483bbe10e..eb25671455f451 100644 --- a/files/fr/web/javascript/reference/global_objects/biguint64array/biguint64array/index.md +++ b/files/fr/web/javascript/reference/global_objects/biguint64array/biguint64array/index.md @@ -45,7 +45,7 @@ console.log(biguint64.length); // 2 console.log(biguint64.BYTES_PER_ELEMENT); // 8 // À partir d'un tableau -const arr = new BigUint64Array([21n,31n]); +const arr = new BigUint64Array([21n, 31n]); console.log(arr[1]); // 31n // À partir d'un autre tableau typé @@ -58,7 +58,9 @@ const buffer = new ArrayBuffer(32); const z = new BigUint64Array(buffer, 0, 4); // À partir d'un itérable -const iterable = function*(){ yield* [1n, 2n, 3n]; }(); +const iterable = (function* () { + yield* [1n, 2n, 3n]; +})(); const biguint64 = new BigUint64Array(iterable); // BigUint64Array[1n, 2n, 3n] ``` diff --git a/files/fr/web/javascript/reference/global_objects/biguint64array/index.md b/files/fr/web/javascript/reference/global_objects/biguint64array/index.md index dc676323422134..4b059d14257155 100644 --- a/files/fr/web/javascript/reference/global_objects/biguint64array/index.md +++ b/files/fr/web/javascript/reference/global_objects/biguint64array/index.md @@ -123,7 +123,7 @@ console.log(bigInt64.length); // 2 console.log(bigInt64.BYTES_PER_ELEMENT); // 8 // Construction à partir d'un tableau -var arr = new BigUint64Array([21n,31n]); +var arr = new BigUint64Array([21n, 31n]); console.log(arr[1]); // 31n // Construction à partir d'un tableau typé @@ -136,7 +136,9 @@ var buffer = new ArrayBuffer(32); var z = new BigUint64Array(buffer, 0, 4); // Construction à partir d'un itérable -var iterable = function*(){ yield* [1n, 2n, 3n]; }(); +var iterable = (function* () { + yield* [1n, 2n, 3n]; +})(); var BigInt64 = new BigUint64Array(iterable); // BigUint64Array[1n, 2n, 3n] ``` diff --git a/files/fr/web/javascript/reference/global_objects/boolean/boolean/index.md b/files/fr/web/javascript/reference/global_objects/boolean/boolean/index.md index b4eca2dbaa32fb..b30cc1be494bc6 100644 --- a/files/fr/web/javascript/reference/global_objects/boolean/boolean/index.md +++ b/files/fr/web/javascript/reference/global_objects/boolean/boolean/index.md @@ -13,8 +13,8 @@ Le **constructeur `Boolean()`** permet de créer des objets [`Boolean`](/fr/docs ## Syntaxe ```js -new Boolean() -new Boolean(valeur) +new Boolean(); +new Boolean(valeur); ``` ### Paramètres @@ -30,7 +30,7 @@ new Boolean(valeur) const bPasDeParam = new Boolean(); const bZero = new Boolean(0); const bNull = new Boolean(null); -const bChaineVide = new Boolean(''); +const bChaineVide = new Boolean(""); const bFalse = new Boolean(false); ``` @@ -38,9 +38,9 @@ const bFalse = new Boolean(false); ```js const bTrue = new Boolean(true); -const bChaineTrue = new Boolean('true'); -const bChaineFalse = new Boolean('false'); -const bSuLin = new Boolean('Su Lin'); +const bChaineTrue = new Boolean("true"); +const bChaineFalse = new Boolean("false"); +const bSuLin = new Boolean("Su Lin"); const bArrayProto = new Boolean([]); const bObjProto = new Boolean({}); ``` diff --git a/files/fr/web/javascript/reference/global_objects/boolean/index.md b/files/fr/web/javascript/reference/global_objects/boolean/index.md index 127b5d53152319..eb4bf988e61aaf 100644 --- a/files/fr/web/javascript/reference/global_objects/boolean/index.md +++ b/files/fr/web/javascript/reference/global_objects/boolean/index.md @@ -35,18 +35,18 @@ if (x) { Il ne faut pas utiliser un objet `Boolean` pour convertir une valeur non-booléenne en une valeur booléenne. On utilisera plutôt `Boolean` comme une fonction (sans l'opérateur `new`) ou alors la [double négation](/fr/docs/Web/JavaScript/Reference/Operators/Logical_NOT) : ```js -var x = Boolean(expression); // conseillé -var x = !!(expression); // une autre méthode +var x = Boolean(expression); // conseillé +var x = !!expression; // une autre méthode var x = new Boolean(expression); // à ne pas utiliser ``` Si vous spécifiez un objet quelconque, incluant un objet booléen qui vaut `false`, le nouvel objet `Boolean` vaudra `true`. ```js -var monFalse = new Boolean(false); // valeur initiale à false -var g = Boolean(monFalse); // valeur initiale à true -var maChaine = new String("Hello"); // un objet String -var s = Boolean(maChaine); // valeur initiale à true +var monFalse = new Boolean(false); // valeur initiale à false +var g = Boolean(monFalse); // valeur initiale à true +var maChaine = new String("Hello"); // un objet String +var s = Boolean(maChaine); // valeur initiale à true ``` Il ne faut pas utiliser un objet `Boolean` à la place d'une valeur primitive booléenne. @@ -64,10 +64,10 @@ if ([]) { if ([] == false) { console.log("[] == false"); // affiche "[] == false" -} +} ``` -En effet, on a bien `[] == false` bien que `[]` est équivalent à vrai. La comparaison `[] == false` compare la *valeur* de `[]` avec `false`. Or, pour obtenir la *valeur* de `[]`, le moteur JavaScript appelle `[].toString()` dont le résultat vaut `""`, et c'est *cette chaîne de caractères* qui est comparée avec `false`. Autrement dit, `[] == false` est équivalent à `"" == false`. Avec `""` qui est équivalent à faux, on a donc le résultat observé. +En effet, on a bien `[] == false` bien que `[]` est équivalent à vrai. La comparaison `[] == false` compare la _valeur_ de `[]` avec `false`. Or, pour obtenir la _valeur_ de `[]`, le moteur JavaScript appelle `[].toString()` dont le résultat vaut `""`, et c'est _cette chaîne de caractères_ qui est comparée avec `false`. Autrement dit, `[] == false` est équivalent à `"" == false`. Avec `""` qui est équivalent à faux, on a donc le résultat observé. ## Constructeur @@ -89,7 +89,7 @@ En effet, on a bien `[] == false` bien que `[]` est équivalent à vrai. La comp var bSansParam = new Boolean(); var bZero = new Boolean(0); var bNull = new Boolean(null); -var bChaineVide = new Boolean(''); +var bChaineVide = new Boolean(""); var bfalse = new Boolean(false); ``` @@ -97,9 +97,9 @@ var bfalse = new Boolean(false); ```js var bTrue = new Boolean(true); -var bChaineTrue = new Boolean('true'); -var bChaineFalse = new Boolean('false'); -var bSuLin = new Boolean('Su Lin'); +var bChaineTrue = new Boolean("true"); +var bChaineFalse = new Boolean("false"); +var bSuLin = new Boolean("Su Lin"); var bArrayProto = new Boolean([]); var bObjProto = new Boolean({}); ``` diff --git a/files/fr/web/javascript/reference/global_objects/boolean/tostring/index.md b/files/fr/web/javascript/reference/global_objects/boolean/tostring/index.md index 53bf0f87504e59..0783c95fbfd8c3 100644 --- a/files/fr/web/javascript/reference/global_objects/boolean/tostring/index.md +++ b/files/fr/web/javascript/reference/global_objects/boolean/tostring/index.md @@ -13,7 +13,7 @@ La méthode **`toString()`** renvoie une chaine de caractères correspondant à ## Syntaxe ```js -bool.toString() +bool.toString(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/boolean/valueof/index.md b/files/fr/web/javascript/reference/global_objects/boolean/valueof/index.md index 5527346334f731..7a0d0c53f8ad39 100644 --- a/files/fr/web/javascript/reference/global_objects/boolean/valueof/index.md +++ b/files/fr/web/javascript/reference/global_objects/boolean/valueof/index.md @@ -13,7 +13,7 @@ La méthode **`valueOf()`** renvoie la valeur primitive de l'objet {{jsxref("Boo ## Syntaxe ```js -bool.valueOf() +bool.valueOf(); ``` ### Valeur de retour @@ -32,7 +32,7 @@ Cette méthode est généralement utilisée de façon interne pas le moteur Java ```js var x = new Boolean(); -var maVar = x.valueOf() // assigne false à maVar +var maVar = x.valueOf(); // assigne false à maVar ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/dataview/buffer/index.md b/files/fr/web/javascript/reference/global_objects/dataview/buffer/index.md index 48a07577d00055..4bb331b776ccbe 100644 --- a/files/fr/web/javascript/reference/global_objects/dataview/buffer/index.md +++ b/files/fr/web/javascript/reference/global_objects/dataview/buffer/index.md @@ -13,7 +13,7 @@ L'accesseur **`buffer`** est une propriété représentant l'objet {{jsxref("Arr ## Syntaxe ```js -dataview.buffer +dataview.buffer; ``` ## Description diff --git a/files/fr/web/javascript/reference/global_objects/dataview/bytelength/index.md b/files/fr/web/javascript/reference/global_objects/dataview/bytelength/index.md index 427fb7efa6cfac..a263d36d413382 100644 --- a/files/fr/web/javascript/reference/global_objects/dataview/bytelength/index.md +++ b/files/fr/web/javascript/reference/global_objects/dataview/bytelength/index.md @@ -13,7 +13,7 @@ L'accesseur **`byteLength`** est une propriété représentant la longueur, expr ## Syntaxe ```js -dataview.byteLength +dataview.byteLength; ``` ## Description diff --git a/files/fr/web/javascript/reference/global_objects/dataview/byteoffset/index.md b/files/fr/web/javascript/reference/global_objects/dataview/byteoffset/index.md index 07a69545481c6b..d5f4065b2c7a7f 100644 --- a/files/fr/web/javascript/reference/global_objects/dataview/byteoffset/index.md +++ b/files/fr/web/javascript/reference/global_objects/dataview/byteoffset/index.md @@ -13,7 +13,7 @@ La propriété **`byteOffset`** est un accesseur représentant le décalage, exp ## Syntaxe ```js -dataview.byteOffset +dataview.byteOffset; ``` ## Description diff --git a/files/fr/web/javascript/reference/global_objects/dataview/dataview/index.md b/files/fr/web/javascript/reference/global_objects/dataview/dataview/index.md index f6e4fb935db86f..0ac61edb7e5f82 100644 --- a/files/fr/web/javascript/reference/global_objects/dataview/dataview/index.md +++ b/files/fr/web/javascript/reference/global_objects/dataview/dataview/index.md @@ -13,9 +13,9 @@ Le constructeur **`DataView()`** permet de construire des objets [`DataView`](/f ## Syntaxe ```js -new DataView(buffer) -new DataView(buffer, decalageOctets) -new DataView(buffer, decalageOctets, longueurOctets) +new DataView(buffer); +new DataView(buffer, decalageOctets); +new DataView(buffer, decalageOctets, longueurOctets); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/dataview/getint8/index.md b/files/fr/web/javascript/reference/global_objects/dataview/getint8/index.md index b86e3678fd9bb9..702b4a47139739 100644 --- a/files/fr/web/javascript/reference/global_objects/dataview/getint8/index.md +++ b/files/fr/web/javascript/reference/global_objects/dataview/getint8/index.md @@ -13,7 +13,7 @@ La méthode **`getInt8()`** permet de lire un entier signé sur 8 bits à l'octe ## Syntaxe ```js -dataview.getInt8(positionOctet) +dataview.getInt8(positionOctet); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/dataview/getuint8/index.md b/files/fr/web/javascript/reference/global_objects/dataview/getuint8/index.md index d85b519423acc6..277df6d9c89baa 100644 --- a/files/fr/web/javascript/reference/global_objects/dataview/getuint8/index.md +++ b/files/fr/web/javascript/reference/global_objects/dataview/getuint8/index.md @@ -13,7 +13,7 @@ La méthode **`getUint8()`** permet de lire un entier non-signé sur 8 bits à l ## Syntaxe ```js -dataview.getUint8(positionOctet) +dataview.getUint8(positionOctet); ``` ### Paramètres From 5154dc2695afa17021127627c8c4056fad367bbc Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 01:42:32 -0700 Subject: [PATCH 08/30] fr: Format /web/javascript using Prettier (part 3) (#14641) --- .../global_objects/dataview/index.md | 29 ++++-- .../global_objects/dataview/setint8/index.md | 2 +- .../global_objects/dataview/setuint8/index.md | 2 +- .../global_objects/date/date/index.md | 30 +++--- .../global_objects/date/getdate/index.md | 2 +- .../global_objects/date/getday/index.md | 8 +- .../global_objects/date/getfullyear/index.md | 2 +- .../global_objects/date/gethours/index.md | 2 +- .../date/getmilliseconds/index.md | 2 +- .../global_objects/date/getminutes/index.md | 2 +- .../global_objects/date/getmonth/index.md | 8 +- .../global_objects/date/getseconds/index.md | 2 +- .../global_objects/date/gettime/index.md | 9 +- .../date/gettimezoneoffset/index.md | 2 +- .../global_objects/date/getutcdate/index.md | 2 +- .../global_objects/date/getutcday/index.md | 6 +- .../date/getutcfullyear/index.md | 2 +- .../global_objects/date/getutchours/index.md | 2 +- .../date/getutcmilliseconds/index.md | 2 +- .../date/getutcminutes/index.md | 2 +- .../global_objects/date/getutcmonth/index.md | 2 +- .../date/getutcseconds/index.md | 2 +- .../global_objects/date/getyear/index.md | 2 +- .../reference/global_objects/date/index.md | 46 ++++----- .../global_objects/date/now/index.md | 1 - .../global_objects/date/parse/index.md | 36 +++---- .../global_objects/date/setdate/index.md | 14 +-- .../global_objects/date/sethours/index.md | 2 +- .../date/setmilliseconds/index.md | 2 +- .../global_objects/date/setminutes/index.md | 2 +- .../global_objects/date/setmonth/index.md | 2 +- .../global_objects/date/setseconds/index.md | 4 +- .../global_objects/date/settime/index.md | 2 +- .../global_objects/date/setutcdate/index.md | 2 +- .../date/setutcmilliseconds/index.md | 2 +- .../global_objects/date/setyear/index.md | 2 +- .../global_objects/date/todatestring/index.md | 4 +- .../global_objects/date/toisostring/index.md | 40 ++++---- .../global_objects/date/tojson/index.md | 4 +- .../date/tolocaledatestring/index.md | 13 ++- .../date/tolocalestring/index.md | 18 ++-- .../date/tolocaletimestring/index.md | 10 +- .../global_objects/date/tostring/index.md | 2 +- .../global_objects/date/totimestring/index.md | 4 +- .../global_objects/date/toutcstring/index.md | 2 +- .../global_objects/date/valueof/index.md | 4 +- .../global_objects/decodeuri/index.md | 10 +- .../decodeuricomponent/index.md | 2 +- .../global_objects/encodeuri/index.md | 16 ++-- .../encodeuricomponent/index.md | 70 +++++++------- .../error/columnnumber/index.md | 2 +- .../global_objects/error/error/index.md | 12 ++- .../reference/global_objects/error/index.md | 37 ++++---- .../global_objects/error/linenumber/index.md | 6 +- .../global_objects/error/stack/index.md | 46 ++++----- .../global_objects/error/tostring/index.md | 15 ++- .../reference/global_objects/escape/index.md | 10 +- .../reference/global_objects/eval/index.md | 93 ++++++++++--------- .../evalerror/evalerror/index.md | 22 ++--- .../global_objects/evalerror/index.md | 14 +-- .../finalizationregistry/index.md | 2 +- .../finalizationregistry/index.md | 10 +- .../finalizationregistry/register/index.md | 2 +- .../finalizationregistry/unregister/index.md | 20 ++-- .../float32array/float32array/index.md | 6 +- .../global_objects/float32array/index.md | 6 +- .../float64array/float64array/index.md | 6 +- .../global_objects/float64array/index.md | 6 +- .../global_objects/function/apply/index.md | 33 +++---- .../function/arguments/index.md | 6 +- .../global_objects/function/bind/index.md | 27 +++--- .../global_objects/function/call/index.md | 28 +++--- .../global_objects/function/caller/index.md | 22 +++-- .../function/displayname/index.md | 28 +++--- .../global_objects/function/function/index.md | 16 +++- .../global_objects/function/index.md | 22 ++--- .../global_objects/function/length/index.md | 10 +- .../global_objects/function/name/index.md | 48 +++++----- .../global_objects/generator/index.md | 15 ++- .../global_objects/generator/next/index.md | 12 +-- .../global_objects/generator/return/index.md | 6 +- .../global_objects/generator/throw/index.md | 8 +- .../global_objects/generatorfunction/index.md | 6 +- .../global_objects/globalthis/index.md | 18 ++-- .../global_objects/infinity/index.md | 10 +- .../global_objects/int16array/index.md | 6 +- .../int16array/int16array/index.md | 6 +- .../global_objects/int32array/index.md | 6 +- .../int32array/int32array/index.md | 8 +- .../global_objects/int8array/index.md | 6 +- .../int8array/int8array/index.md | 6 +- .../global_objects/internalerror/index.md | 2 +- .../internalerror/internalerror/index.md | 10 +- .../intl/collator/collator/index.md | 17 ++-- .../intl/collator/compare/index.md | 9 +- .../global_objects/intl/collator/index.md | 14 +-- .../intl/collator/resolvedoptions/index.md | 14 +-- .../intl/collator/supportedlocalesof/index.md | 2 +- .../datetimeformat/datetimeformat/index.md | 65 +++++++++---- .../intl/datetimeformat/format/index.md | 23 +++-- 100 files changed, 698 insertions(+), 566 deletions(-) diff --git a/files/fr/web/javascript/reference/global_objects/dataview/index.md b/files/fr/web/javascript/reference/global_objects/dataview/index.md index 008951950044ae..cae7f978181b2b 100644 --- a/files/fr/web/javascript/reference/global_objects/dataview/index.md +++ b/files/fr/web/javascript/reference/global_objects/dataview/index.md @@ -15,7 +15,7 @@ La vue **`DataView`** fournit une interface de bas niveau pour lire et écrire d Les formats numériques sur plusieurs octets sont représentés différemment en mémoire selon l'architecture de la machine (voir [la page du glossaire sur le boutisme](/fr/docs/Glossary/Endianness) pour plus d'explications). Les accesseurs `DataView` permettent de contrôler explicitement la façon dont se fait l'accès aux données, quel que soit le boutisme de l'ordinateur. ```js -var littleEndian = (function() { +var littleEndian = (function () { var buffer = new ArrayBuffer(2); new DataView(buffer).setInt16(0, 256, true /* littleEndian */); // Int16Array utilise le boutisme de la plateforme @@ -35,9 +35,14 @@ function getUint64(dataview, byteOffset, littleEndian) { const droite = dataview.getUint32(byteOffset + 4, littleEndian); // on combine les deux valeurs 32 bits - const combinaison = littleEndian ? gauche + 2**32*droite : 2**32*gauche + droite; - if(!Number.isSafeInteger(combinaison)){ - console.warn(combinaison, " dépasse MAX_SAFE_INTEGER : perte de précision !"); + const combinaison = littleEndian + ? gauche + 2 ** 32 * droite + : 2 ** 32 * gauche + droite; + if (!Number.isSafeInteger(combinaison)) { + console.warn( + combinaison, + " dépasse MAX_SAFE_INTEGER : perte de précision !", + ); } return combinaison; } @@ -46,14 +51,22 @@ function getUint64(dataview, byteOffset, littleEndian) { On peut également créer un objet [`BigInt`](/fr/docs/Web/JavaScript/Reference/Global_Objects/BigInt) si on veut avoir accès à 64 bits. Sur le plan des performances, les grands entiers ([`BigInt`](/fr/docs/Web/JavaScript/Reference/Global_Objects/BigInt) ont une taille variable, aussi leur manipulation sera nécessairement plus lente que celle des nombres stockés sur 32 bits. Ceci étant écrit, les valeurs natives [`BigInt`](/fr/docs/Web/JavaScript/Reference/Global_Objects/BigInt) seront plus performantes que les implémentations tierces (bibliothèques, etc.). ```js -const BigInt = window.BigInt, bigThirtyTwo = BigInt(32), bigZero = BigInt(0); +const BigInt = window.BigInt, + bigThirtyTwo = BigInt(32), + bigZero = BigInt(0); function getUint64BigInt(dataview, byteOffset, littleEndian) { // on décompose la valeur 64 sur bits en deux nombres 32 bits (4 octets) - const gauche = BigInt(dataview.getUint32(byteOffset|0, !!littleEndian)>>>0); - const droite = BigInt(dataview.getUint32((byteOffset|0) + 4|0, !!littleEndian)>>>0); + const gauche = BigInt( + dataview.getUint32(byteOffset | 0, !!littleEndian) >>> 0, + ); + const droite = BigInt( + dataview.getUint32(((byteOffset | 0) + 4) | 0, !!littleEndian) >>> 0, + ); // on recombine les deux valeurs sur 32 bits et on la renvoie - return littleEndian ? (droite< **Note :** La seule façon correcte d'instancier un nouvel objet `Date` est d'utiliser l'opérateur [`new`](/fr/docs/Web/JavaScript/Reference/Operators/new). Si vous invoquez ce constructeur directement (`now = Date()` par exemple), la valeur renvoyée sera une chaîne de caractères plutôt qu'un objet `Date`. @@ -87,11 +87,11 @@ Les exemples qui suivent illustrent différentes façons de créer des dates Jav > **Note :** L'analyse de chaîne de caractères représentant des dates avec le constructeur `Date` (ou `Date.parse` qui est équivalent à cet égard) est fortement déconseillée en raison des différences et incohérences entre les navigateurs. ```js -let today = new Date() -let birthday = new Date('December 17, 1995 13:24:00') -let birthday = new Date('1995-12-17T13:24:00') -let birthday = new Date(1995, 11, 17) // les mois sont numérotés à partir de 0 -let birthday = new Date(1995, 11, 17, 13, 24, 0) +let today = new Date(); +let birthday = new Date("December 17, 1995 13:24:00"); +let birthday = new Date("1995-12-17T13:24:00"); +let birthday = new Date(1995, 11, 17); // les mois sont numérotés à partir de 0 +let birthday = new Date(1995, 11, 17, 13, 24, 0); ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/date/getdate/index.md b/files/fr/web/javascript/reference/global_objects/date/getdate/index.md index d45f97b81e5254..832c5fbfdaa9b4 100644 --- a/files/fr/web/javascript/reference/global_objects/date/getdate/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/getdate/index.md @@ -13,7 +13,7 @@ La méthode **`getDate()`** retourne le jour du mois pour la date spécifiée d' ## Syntaxe ```js -dateObj.getDate() +dateObj.getDate(); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/date/getday/index.md b/files/fr/web/javascript/reference/global_objects/date/getday/index.md index a00a140c20ddef..3259130f3e8a73 100644 --- a/files/fr/web/javascript/reference/global_objects/date/getday/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/getday/index.md @@ -13,7 +13,7 @@ La méthode **`getDay()`** renvoie le jour de la semaine pour la date spécifié ## Syntaxe ```js -dateObj.getDay() +dateObj.getDay(); ``` ### Valeur de retour @@ -36,10 +36,10 @@ console.log(jourSemaine); //1 > **Note :** Si besoin, on pourra obtenir le nom complet du jour (`"lundi"` par exemple) en utilisant la méthode {{jsxref("DateTimeFormat", "Intl.DateTimeFormat")}} avec un paramètre `options`. Ce faisant, il est plus simple d'internationaliser un site ou une application : > > ```js -> var options = { weekday: 'long'}; -> console.log(new Intl.DateTimeFormat('en-US', options).format(Xmas95)); +> var options = { weekday: "long" }; +> console.log(new Intl.DateTimeFormat("en-US", options).format(Xmas95)); > // Monday -> console.log(new Intl.DateTimeFormat('de-DE', options).format(Xmas95)); +> console.log(new Intl.DateTimeFormat("de-DE", options).format(Xmas95)); > // Montag > ``` diff --git a/files/fr/web/javascript/reference/global_objects/date/getfullyear/index.md b/files/fr/web/javascript/reference/global_objects/date/getfullyear/index.md index bdfab5e3ff0517..38722f916e2be4 100644 --- a/files/fr/web/javascript/reference/global_objects/date/getfullyear/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/getfullyear/index.md @@ -15,7 +15,7 @@ Cette méthode doit être utilisée à la place de {{jsxref("Date.prototype.getY ## Syntaxe ```js -dateObj.getFullYear() +dateObj.getFullYear(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/date/gethours/index.md b/files/fr/web/javascript/reference/global_objects/date/gethours/index.md index efe04904f34134..0033b5c6d0f136 100644 --- a/files/fr/web/javascript/reference/global_objects/date/gethours/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/gethours/index.md @@ -13,7 +13,7 @@ La méthode **`getHours()`** renvoie l'heure pour la date renseignée, d'après ## Syntaxe ```js -dateObj.getHours() +dateObj.getHours(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/date/getmilliseconds/index.md b/files/fr/web/javascript/reference/global_objects/date/getmilliseconds/index.md index 0af6723548e847..201fd30a298515 100644 --- a/files/fr/web/javascript/reference/global_objects/date/getmilliseconds/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/getmilliseconds/index.md @@ -13,7 +13,7 @@ La méthode **`getMilliseconds()`** renvoie les millièmes de secondes de la dat ## Syntaxe ```js -dateObj.getMilliseconds() +dateObj.getMilliseconds(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/date/getminutes/index.md b/files/fr/web/javascript/reference/global_objects/date/getminutes/index.md index 58a188af775cab..5f3f80fcec6817 100644 --- a/files/fr/web/javascript/reference/global_objects/date/getminutes/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/getminutes/index.md @@ -13,7 +13,7 @@ La méthode **`getMinutes()`** renvoie les minutes pour la date renseignée d'ap ## Syntaxe ```js -dateObj.getMinutes() +dateObj.getMinutes(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/date/getmonth/index.md b/files/fr/web/javascript/reference/global_objects/date/getmonth/index.md index 03cdcd5f6aa10e..54861d144f8656 100644 --- a/files/fr/web/javascript/reference/global_objects/date/getmonth/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/getmonth/index.md @@ -13,7 +13,7 @@ La méthode **`getMonth()`** retourne le mois de la date renseignée d'après l' ## Syntaxe ```js -dateObj.getMonth() +dateObj.getMonth(); ``` ### Valeur de retour @@ -36,10 +36,10 @@ console.log(mois); //11 > **Note :** Si besoin, on pourra récupérer le nom complet du mois (`"Janvier"` par exemple) en utilisant [`Intl.DateTimeFormat()`](/fr/docs/Web/JavaScript/Reference/Objets_globaux/DateTimeFormat) avec un paramètre `options`. En utilisant cette méthode, il est plus simple d'internationaliser le site ou l'application : > > ```js -> var options = { month: 'long'}; -> console.log(new Intl.DateTimeFormat('en-US', options).format(noel95)); +> var options = { month: "long" }; +> console.log(new Intl.DateTimeFormat("en-US", options).format(noel95)); > // December -> console.log(new Intl.DateTimeFormat('de-DE', options).format(noel95)); +> console.log(new Intl.DateTimeFormat("de-DE", options).format(noel95)); > // Dezember > ``` diff --git a/files/fr/web/javascript/reference/global_objects/date/getseconds/index.md b/files/fr/web/javascript/reference/global_objects/date/getseconds/index.md index a1e599bff30296..128c7b78fecf00 100644 --- a/files/fr/web/javascript/reference/global_objects/date/getseconds/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/getseconds/index.md @@ -13,7 +13,7 @@ La méthode **`getSeconds()`** renvoie les secondes pour la date renseignée d'a ## Syntaxe ```js -dateObj.getSeconds() +dateObj.getSeconds(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/date/gettime/index.md b/files/fr/web/javascript/reference/global_objects/date/gettime/index.md index bd797dc54ff52f..a0d441471b3799 100644 --- a/files/fr/web/javascript/reference/global_objects/date/gettime/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/gettime/index.md @@ -15,7 +15,7 @@ Vous pouvez utiliser cette méthode pour vous affecter une date et un temps à u ## Syntaxe ```js -dateObj.getTime() +dateObj.getTime(); ``` ### Valeur de retour @@ -29,7 +29,7 @@ La valeur renvoyée par la méthode `getTime()` est le nombre de millièmes de s L'exemple qui suit assigne la valeur de `anniversaire` à `copie` : ```js -var anniversaire = new Date(1994 , 11, 10); // 10 décembre 1994 +var anniversaire = new Date(1994, 11, 10); // 10 décembre 1994 var copie = new Date(); copie.setTime(anniversaire.getTime()); ``` @@ -47,7 +47,9 @@ for (var i = 0; i < 1000; i++) { } fin = new Date(); -console.log('Durée de cette opération : ' + (fin.getTime() - début.getTime()) + ' msec'); +console.log( + "Durée de cette opération : " + (fin.getTime() - début.getTime()) + " msec", +); ``` ## Précision temporelle réduite @@ -62,7 +64,6 @@ new Date().getTime(); // 1519211811670 // ... - // précision temporelle avec `privacy.resistFingerprinting` activé new Date().getTime(); // 1519129853500 diff --git a/files/fr/web/javascript/reference/global_objects/date/gettimezoneoffset/index.md b/files/fr/web/javascript/reference/global_objects/date/gettimezoneoffset/index.md index c04c0d3adcae84..00626ac2d5805e 100644 --- a/files/fr/web/javascript/reference/global_objects/date/gettimezoneoffset/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/gettimezoneoffset/index.md @@ -13,7 +13,7 @@ La méthode **`getTimezoneOffset()`** retourne la différence en minutes entre l ## Syntaxe ```js -dateObj.getTimezoneOffset() +dateObj.getTimezoneOffset(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/date/getutcdate/index.md b/files/fr/web/javascript/reference/global_objects/date/getutcdate/index.md index 514e41174c566a..8decd00dafd0d6 100644 --- a/files/fr/web/javascript/reference/global_objects/date/getutcdate/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/getutcdate/index.md @@ -13,7 +13,7 @@ La méthode **`getUTCDate()`** renvoie le jour du mois pour la date renseignée ## Syntaxe ```js -dateObj.getUTCDate() +dateObj.getUTCDate(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/date/getutcday/index.md b/files/fr/web/javascript/reference/global_objects/date/getutcday/index.md index 281deb69b65d95..57cbee00ea0c78 100644 --- a/files/fr/web/javascript/reference/global_objects/date/getutcday/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/getutcday/index.md @@ -13,7 +13,7 @@ La méthode **`getUTCDay()`** renvoie le jour de la semaine pour la date renseig ## Syntaxe ```js -dateObj.getUTCDay() +dateObj.getUTCDay(); ``` ### Valeur de retour @@ -27,8 +27,8 @@ La valeur renvoyée par `getUTCDay()` est un entier correspondant au jour de la L'exemple suivant assigne le jour de la semaine de la date actuelle à la variable `jourSemaine`. ```js -var aujourdhui = new Date() -var jourSemaine = aujourdhui.getUTCDay() +var aujourdhui = new Date(); +var jourSemaine = aujourdhui.getUTCDay(); ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/date/getutcfullyear/index.md b/files/fr/web/javascript/reference/global_objects/date/getutcfullyear/index.md index abd790e9b30790..8749bd812d7876 100644 --- a/files/fr/web/javascript/reference/global_objects/date/getutcfullyear/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/getutcfullyear/index.md @@ -13,7 +13,7 @@ La méthode **`getUTCFullYear()`** renvoie l'année de la date renseignée, d'ap ## Syntaxe ```js -dateObj.getUTCFullYear() +dateObj.getUTCFullYear(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/date/getutchours/index.md b/files/fr/web/javascript/reference/global_objects/date/getutchours/index.md index 76bedb4408df37..3d229776c72c35 100644 --- a/files/fr/web/javascript/reference/global_objects/date/getutchours/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/getutchours/index.md @@ -13,7 +13,7 @@ La méthode **`getUTCHours()`** renvoie les heures de la date renseignée, d'apr ## Syntaxe ```js -dateObj.getUTCHours() +dateObj.getUTCHours(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/date/getutcmilliseconds/index.md b/files/fr/web/javascript/reference/global_objects/date/getutcmilliseconds/index.md index 82aec8625f0286..1e8818c439d27b 100644 --- a/files/fr/web/javascript/reference/global_objects/date/getutcmilliseconds/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/getutcmilliseconds/index.md @@ -13,7 +13,7 @@ La méthode **`getUTCMilliseconds()`** renvoie les millièmes de secondes pour l ## Syntaxe ```js -dateObj.getUTCMilliseconds() +dateObj.getUTCMilliseconds(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/date/getutcminutes/index.md b/files/fr/web/javascript/reference/global_objects/date/getutcminutes/index.md index b161d459ae6d52..53b428fb5dc184 100644 --- a/files/fr/web/javascript/reference/global_objects/date/getutcminutes/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/getutcminutes/index.md @@ -13,7 +13,7 @@ La méthode **`getUTCMinutes()`** renvoie les minutes de la date renseignée, d' ## Syntaxe ```js -dateObj.getUTCMinutes() +dateObj.getUTCMinutes(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/date/getutcmonth/index.md b/files/fr/web/javascript/reference/global_objects/date/getutcmonth/index.md index c4af809d1971a8..fae98ff7cbbd2d 100644 --- a/files/fr/web/javascript/reference/global_objects/date/getutcmonth/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/getutcmonth/index.md @@ -13,7 +13,7 @@ La méthode **`getUTCMonth()`** renvoie le mois de la date renseignée, d'après ## Syntaxe ```js -dateObj.getUTCMonth() +dateObj.getUTCMonth(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/date/getutcseconds/index.md b/files/fr/web/javascript/reference/global_objects/date/getutcseconds/index.md index 26ad75f0e7b266..5faab4939d2006 100644 --- a/files/fr/web/javascript/reference/global_objects/date/getutcseconds/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/getutcseconds/index.md @@ -13,7 +13,7 @@ La méthode **`getUTCSeconds()`** renvoie les secondes de la date renseignée, d ## Syntaxe ```js -dateObj.getUTCSeconds() +dateObj.getUTCSeconds(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/date/getyear/index.md b/files/fr/web/javascript/reference/global_objects/date/getyear/index.md index f439fc2280dfae..9aaa514b60126d 100644 --- a/files/fr/web/javascript/reference/global_objects/date/getyear/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/getyear/index.md @@ -11,7 +11,7 @@ La méthode **`getYear()`** renvoie l'année de la date renseignée, d'après l' ## Syntaxe ```js -dateObj.getYear() +dateObj.getYear(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/date/index.md b/files/fr/web/javascript/reference/global_objects/date/index.md index 9efa333d9b4560..23470a53ab8057 100644 --- a/files/fr/web/javascript/reference/global_objects/date/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/index.md @@ -148,14 +148,14 @@ Ainsi, on dispose de méthodes permettant d'obtenir ou de définir les différen Les exemples qui suivent illustrent différentes méthodes permettant de créer des dates JavaScript : -> **Note :** L'analyse de chaîne de caractères représentant des dates avec le constructeur `Date` (ou `Date.parse` qui est équivalent) est fortement déconseillée en raison des différences de comportement existant entre les navigateurs. +> **Note :** L'analyse de chaîne de caractères représentant des dates avec le constructeur `Date` (ou `Date.parse` qui est équivalent) est fortement déconseillée en raison des différences de comportement existant entre les navigateurs. ```js -let aujourdhui = new Date() -let anniversaire = new Date('September 22, 2018 15:00:00') -let anniversaire = new Date('2018-09-22T15:00:00') -let anniversaire = new Date(2018, 8, 22) // the month is 0-indexed -let anniversaire = new Date(2018, 8, 22, 15, 0, 0) +let aujourdhui = new Date(); +let anniversaire = new Date("September 22, 2018 15:00:00"); +let anniversaire = new Date("2018-09-22T15:00:00"); +let anniversaire = new Date(2018, 8, 22); // the month is 0-indexed +let anniversaire = new Date(2018, 8, 22, 15, 0, 0); ``` ### Les années sur deux chiffres correspondent à la période 1900 – 1999 @@ -163,12 +163,12 @@ let anniversaire = new Date(2018, 8, 22, 15, 0, 0) Afin de créer et de manipuler des dates sur les années `0` à `99` de notre ère, on doit utiliser les méthodes {{jsxref("Date.prototype.setFullYear()")}} and {{jsxref("Date.prototype.getFullYear()")}}. ```js -let date = new Date(98, 1) // Sun Feb 01 1998 00:00:00 GMT+0000 (GMT) +let date = new Date(98, 1); // Sun Feb 01 1998 00:00:00 GMT+0000 (GMT) // Méthode dépréciée, 98 correspond également ici à 1998 -date.setYear(98) // Sun Feb 01 1998 00:00:00 GMT+0000 (GMT) +date.setYear(98); // Sun Feb 01 1998 00:00:00 GMT+0000 (GMT) -date.setFullYear(98) // Sat Feb 01 0098 00:00:00 GMT+0000 (BST) +date.setFullYear(98); // Sat Feb 01 0098 00:00:00 GMT+0000 (BST) ``` ### Calculer le temps écoulé @@ -179,36 +179,36 @@ En raison de durées différentes pour les jours (heure d'été / heure d'hiver) ```js // Utiliser des objets Date -let debut = Date.now() +let debut = Date.now(); // Ici, l'évènement dont on veut mesurer la durée : -faireQuelqueChosePendantLongtemps() -let fin = Date.now() -let duree = fin - debut // La durée écoulée, en millisecondes +faireQuelqueChosePendantLongtemps(); +let fin = Date.now(); +let duree = fin - debut; // La durée écoulée, en millisecondes ``` ```js // En utilisant les méthodes natives -let debut = new Date() +let debut = new Date(); // Ici, l'évènement dont on veut mesurer la durée : -faireQuelqueChosePendantLongtemps() -let fin = new Date() -let duree = fin.getTime() - debut.getTime() // La durée écoulée, en millisecondes +faireQuelqueChosePendantLongtemps(); +let fin = new Date(); +let duree = fin.getTime() - debut.getTime(); // La durée écoulée, en millisecondes ``` ```js // Pour tester le temps d'exécution d'une fonction function afficheDureeEcoulee(fTest) { let debut = Date.now(), - valRetour = fTest(), - fin = Date.now() + valRetour = fTest(), + fin = Date.now(); - console.log(`Durée écoulée : ${ String(fin - debut) } millisecondes`) - return valRetour + console.log(`Durée écoulée : ${String(fin - debut)} millisecondes`); + return valRetour; } -let valeurDeRetour = afficheDureeEcoulee(maFonctionATester) +let valeurDeRetour = afficheDureeEcoulee(maFonctionATester); ``` > **Note :** Pour les navigateurs qui prennent en charge l'{{domxref("Window.performance", "API Web Performance", "", 1)}}, la méthode {{domxref("Performance.now()")}} peut fournir un outil de mesure des durées écoulées plus fiable et précis que {{jsxref("Date.now()")}}. @@ -216,7 +216,7 @@ let valeurDeRetour = afficheDureeEcoulee(maFonctionATester) ### Obtenir le nombre de secondes écoulées depuis l'epoch ECMAScript ```js -let secondes = Math.floor(Date.now() / 1000) +let secondes = Math.floor(Date.now() / 1000); ``` Dans ce cas, on renvoie un entier et c'est pour ça qu'on utilise {{jsxref("Math.floor()")}}. Par ailleurs, on n'utilise pas {{jsxref("Math.round()")}} afin d'avoir le nombre de secondes effectivement écoulées. diff --git a/files/fr/web/javascript/reference/global_objects/date/now/index.md b/files/fr/web/javascript/reference/global_objects/date/now/index.md index 4f8fa741a1d9f0..e4f949f6c6fb31 100644 --- a/files/fr/web/javascript/reference/global_objects/date/now/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/now/index.md @@ -50,7 +50,6 @@ new Date().getTime(); // 1519211811670 // ... - // précision temporelle avec `privacy.resistFingerprinting` activé new Date().getTime(); // 1519129853500 diff --git a/files/fr/web/javascript/reference/global_objects/date/parse/index.md b/files/fr/web/javascript/reference/global_objects/date/parse/index.md index 113485d643cfdb..0bf60281f04d8c 100644 --- a/files/fr/web/javascript/reference/global_objects/date/parse/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/parse/index.md @@ -17,13 +17,13 @@ La méthode **`Date.parse()`** analyse la représentation textuelle d'une date, Appel direct : ```js -Date.parse(dateString) +Date.parse(dateString); ``` Appel implicite : ```js -new Date(dateString) +new Date(dateString); ``` ### Paramètres @@ -61,29 +61,29 @@ Cependant, les valeurs invalides qui ne sont pas reconnues dans un format ISO pr ```js // Chaîne non ISO avec des valeurs invalides -new Date('23/25/2014'); +new Date("23/25/2014"); ``` sera traitée comme la date locale du 25 novembre 2015 avec Firefox 30 et comme invalide avec Safari 7. Cependant, si la chaîne est reconnue dans un format ISO mais contient des valeurs invalides, la méthode renverra {{jsxref("NaN")}} pour tous les navigateurs conformes à ES5 (ou aux versions ultérieures) : ```js // Chaîne ISO avec des valeurs invalides new -Date('2014-25-23').toISOString(); +Date("2014-25-23").toISOString(); // renvoie "RangeError: invalid date" pour les navigateurs ES5 ``` L'implémentation spécifique de SpiderMonkey peut être trouvée dans le fichier [`jsdate.cpp`](https://dxr.mozilla.org/mozilla-central/source/js/src/jsdate.cpp?rev=64553c483cd1#889). La chaîne `"10 06 2014"` est un exemple de chaîne non ISO, utiliser parse() sur cette chaîne entraînera le moteur JavaScript à utiliser son implémentation de recours. Voir ce [bug](https://bugzilla.mozilla.org/show_bug.cgi?id=1023155#c6) pour une explication rapide de la façon dont est faite l'analyse de la chaîne. ```js -new Date('10 06 2014'); +new Date("10 06 2014"); ``` sera traitée comme la date locale du 6 octobre 2014 et non comme le 10 juin 2014. D'autres exemples : ```js -new Date('toto-truc 2014').toString(); +new Date("toto-truc 2014").toString(); // renvoie : "Invalid Date" -Date.parse('toto-truc 2014'); +Date.parse("toto-truc 2014"); // renvoie : NaN ``` @@ -94,15 +94,15 @@ Date.parse('toto-truc 2014'); Les appels suivants renvoient tous `1546300800000`. Dans le premier appel, on indique uniquement la date (et donc le fuseau UTC implicite). Les chaînes qui suivent utilisent une indication de fuseau horaire selon la norme ISO (`Z` et `+00:00`) ```js -Date.parse("2019-01-01") -Date.parse("2019-01-01T00:00:00.000Z") -Date.parse("2019-01-01T00:00:00.000+00:00") +Date.parse("2019-01-01"); +Date.parse("2019-01-01T00:00:00.000Z"); +Date.parse("2019-01-01T00:00:00.000+00:00"); ``` L'appel suivant, qui ne précise pas le fuseau horaire, fournira le nombre de millisecondes écoulées entre le premier janvier 1970 minuit UTC et le premier janvier 2019 à minuit selon l'heure locale du système utilisé. ```js -Date.parse("2019-01-01T00:00:00") +Date.parse("2019-01-01T00:00:00"); ``` ### Chaînes de caractères non-standard @@ -112,43 +112,43 @@ Date.parse("2019-01-01T00:00:00") Si `IPOdate` est un objet {{jsxref("Date")}}, on peut définir sa valeur au 9 août 1995 (heure locale), de la façon suivante : ```js -IPOdate.setTime(Date.parse('Aug 9, 1995')); +IPOdate.setTime(Date.parse("Aug 9, 1995")); ``` Voici un autre exemple avec une chaîne qui ne suit pas le format standard. ```js -Date.parse('Aug 9, 1995'); +Date.parse("Aug 9, 1995"); ``` Cette méthode renverra `807937200000` pour le fuseau horaire GMT-0300 et d'autres valeurs pour d'autres fuseaux car la chaîne n'indique pas le fuseau horaire et ne respecte pas le format ISO (le fuseau considéré par défaut est donc le fuseau local). ```js -Date.parse('Wed, 09 Aug 1995 00:00:00 GMT'); +Date.parse("Wed, 09 Aug 1995 00:00:00 GMT"); ``` Renvoie `807926400000` quel que soit le fuseau local car on indique GMT. ```js -Date.parse('Wed, 09 Aug 1995 00:00:00'); +Date.parse("Wed, 09 Aug 1995 00:00:00"); ``` Renvoie `807937200000` dans le fuseau GMT-0300 et d'autres valeurs pour d'autres fuseaux car aucune indication de fuseau n'est fournie et que la chaîne n'est pas au format ISO, elle est donc traitée comme un temps local. ```js -Date.parse('Thu, 01 Jan 1970 00:00:00 GMT'); +Date.parse("Thu, 01 Jan 1970 00:00:00 GMT"); ``` Renvoie `0` quel que soit le fuseau local car l'indicateur GMT est fourni. ```js -Date.parse('Thu, 01 Jan 1970 00:00:00'); +Date.parse("Thu, 01 Jan 1970 00:00:00"); ``` Renvoie `14400000` pour le fuseau GMT-0400 et d'autres valeurs dans d'autres fuseaux car aucune indication de fuseau n'est fournie et la chaîne n'est pas au format ISO, elle est donc traitée comme un temps local. ```js -Date.parse('Thu, 01 Jan 1970 00:00:00 GMT-0400'); +Date.parse("Thu, 01 Jan 1970 00:00:00 GMT-0400"); ``` Renvoie `14400000` quel que soit le fuseau car l'indicateur GMT est fourni. diff --git a/files/fr/web/javascript/reference/global_objects/date/setdate/index.md b/files/fr/web/javascript/reference/global_objects/date/setdate/index.md index 06297bd1ad271b..f3273640d4ec65 100644 --- a/files/fr/web/javascript/reference/global_objects/date/setdate/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/setdate/index.md @@ -13,7 +13,7 @@ La méthode **`setDate()`** définit le jour du mois (relatif au début du mois ## Syntaxe ```js -dateObj.setDate(valeurJour) +dateObj.setDate(valeurJour); ``` ### Paramètres @@ -39,12 +39,12 @@ Si on fournit un nombre négatif, la date sera déterminée à rebours à partir ```js var theBigDay = new Date(1962, 6, 7); // 1962-07-06T23:00:00.000Z -theBigDay.setDate(24); // 1962-07-23T23:00:00.000Z -theBigDay.setDate(32); // 1962-07-31T23:00:00.000Z -theBigDay.setDate(22); // 1962-08-21T23:00:00.000Z -theBigDay.setDate(0); // 1962-07-30T23:00:00.000Z -theBigDay.setDate(98); // 1962-10-05T23:00:00.000Z -theBigDay.setDate(-50); // 1962-08-10T23:00:00.000Z +theBigDay.setDate(24); // 1962-07-23T23:00:00.000Z +theBigDay.setDate(32); // 1962-07-31T23:00:00.000Z +theBigDay.setDate(22); // 1962-08-21T23:00:00.000Z +theBigDay.setDate(0); // 1962-07-30T23:00:00.000Z +theBigDay.setDate(98); // 1962-10-05T23:00:00.000Z +theBigDay.setDate(-50); // 1962-08-10T23:00:00.000Z ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/date/sethours/index.md b/files/fr/web/javascript/reference/global_objects/date/sethours/index.md index 8dda6499d82d94..127143a0092c71 100644 --- a/files/fr/web/javascript/reference/global_objects/date/sethours/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/sethours/index.md @@ -19,7 +19,7 @@ dateObj.setHours(valeurHeures[, valeurMinutes[, valeurSecondes[, valeurMs]]]) ### Versions antérieures à JavaScript 1.3 ```js -dateObj.setHours(valeurHeures) +dateObj.setHours(valeurHeures); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/date/setmilliseconds/index.md b/files/fr/web/javascript/reference/global_objects/date/setmilliseconds/index.md index a63e8ffcb44250..85c8535d50aaef 100644 --- a/files/fr/web/javascript/reference/global_objects/date/setmilliseconds/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/setmilliseconds/index.md @@ -13,7 +13,7 @@ La méthode **`setMilliseconds()`** définit les millièmes de secondes pour la ## Syntaxe ```js -dateObj.setMilliseconds(valeurMs) +dateObj.setMilliseconds(valeurMs); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/date/setminutes/index.md b/files/fr/web/javascript/reference/global_objects/date/setminutes/index.md index d9d62411385d07..fbd45b8a9e4b9b 100644 --- a/files/fr/web/javascript/reference/global_objects/date/setminutes/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/setminutes/index.md @@ -19,7 +19,7 @@ dateObj.setMinutes(valeurMinutes[, valeurSecondes[, valeurMs]]) ### Versions antérieures à JavaScript 1.3 ```js -dateObj.setMinutes(valeurMinutes) +dateObj.setMinutes(valeurMinutes); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/date/setmonth/index.md b/files/fr/web/javascript/reference/global_objects/date/setmonth/index.md index 809f02a2c32bd4..cf175abdc4ce98 100644 --- a/files/fr/web/javascript/reference/global_objects/date/setmonth/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/setmonth/index.md @@ -19,7 +19,7 @@ dateObj.setMonth(valeurMois[, valeurJour]) ### Versions antérieures à JavaScript 1.3 ```js -dateObj.setMonth(valeurMois) +dateObj.setMonth(valeurMois); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/date/setseconds/index.md b/files/fr/web/javascript/reference/global_objects/date/setseconds/index.md index 67ea97bca59500..9b7bc92d39e03b 100644 --- a/files/fr/web/javascript/reference/global_objects/date/setseconds/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/setseconds/index.md @@ -19,7 +19,7 @@ dateObj.setSeconds(valeurSecondes[, valeurMs]) ### Versions antérieures à JavaScript 1.3 ```js -dateObj.setSeconds(valeurSecondes) +dateObj.setSeconds(valeurSecondes); ``` ### Paramètres @@ -45,7 +45,7 @@ Si un paramètre utilisé est en dehors des limites attendues, `setSeconds()` te ```js var leGrandJour = new Date(); -leGrandJour.setSeconds(30) +leGrandJour.setSeconds(30); ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/date/settime/index.md b/files/fr/web/javascript/reference/global_objects/date/settime/index.md index 7919b9b25f6036..d9136bf04edcb3 100644 --- a/files/fr/web/javascript/reference/global_objects/date/settime/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/settime/index.md @@ -13,7 +13,7 @@ La méthode **`setTime()`** met l'objet {{jsxref("Date")}} à jour par rapport a ## Syntaxe ```js -dateObj.setTime(valeurTemps) +dateObj.setTime(valeurTemps); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/date/setutcdate/index.md b/files/fr/web/javascript/reference/global_objects/date/setutcdate/index.md index 54ae98c9854999..994e49a3d92aa2 100644 --- a/files/fr/web/javascript/reference/global_objects/date/setutcdate/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/setutcdate/index.md @@ -13,7 +13,7 @@ La méthode **`setUTCDate()`** définit le jour du mois pour la date, selon UTC. ## Syntaxe ```js -dateObj.setUTCDate(valeurJour) +dateObj.setUTCDate(valeurJour); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/date/setutcmilliseconds/index.md b/files/fr/web/javascript/reference/global_objects/date/setutcmilliseconds/index.md index e25e2625c18b31..5ecf75dd5aee68 100644 --- a/files/fr/web/javascript/reference/global_objects/date/setutcmilliseconds/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/setutcmilliseconds/index.md @@ -13,7 +13,7 @@ La méthode **`setUTCMilliseconds()`** définit les millièmes de secondes pour ## Syntaxe ```js -dateObj.setUTCMilliseconds(valeurMs) +dateObj.setUTCMilliseconds(valeurMs); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/date/setyear/index.md b/files/fr/web/javascript/reference/global_objects/date/setyear/index.md index d7388c9d49e1a7..e4be0f0d8c2f27 100644 --- a/files/fr/web/javascript/reference/global_objects/date/setyear/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/setyear/index.md @@ -11,7 +11,7 @@ La méthode **`setYear()`** définit l'année pour pour la date, selon l'heure l ## Syntaxe ```js -dateObj.setYear(valeurAnnée) +dateObj.setYear(valeurAnnée); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/date/todatestring/index.md b/files/fr/web/javascript/reference/global_objects/date/todatestring/index.md index e72c660a44cf9f..85f9c2b6fa26a8 100644 --- a/files/fr/web/javascript/reference/global_objects/date/todatestring/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/todatestring/index.md @@ -18,7 +18,7 @@ La méthode **`toDateString()`** renvoie la date contenue dans un objet {{jsxref ## Syntaxe ```js -dateObj.toDateString() +dateObj.toDateString(); ``` ### Valeur de retour @@ -38,7 +38,7 @@ La méthode `toDateString()` est particulièrement utile car, pour les moteurs i ```js var d = new Date(1993, 6, 28, 14, 39, 7); -console.log(d.toString()); // écrit Wed Jul 28 1993 14:39:07 GMT-0600 (PDT) +console.log(d.toString()); // écrit Wed Jul 28 1993 14:39:07 GMT-0600 (PDT) console.log(d.toDateString()); // écrit Wed Jul 28 1993 ``` diff --git a/files/fr/web/javascript/reference/global_objects/date/toisostring/index.md b/files/fr/web/javascript/reference/global_objects/date/toisostring/index.md index a51806fbba189a..13e1d5c8bdf4ad 100644 --- a/files/fr/web/javascript/reference/global_objects/date/toisostring/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/toisostring/index.md @@ -13,7 +13,7 @@ La méthode **`toISOString()`** renvoie une chaîne de caractères au format ISO ## Syntaxe ```js -dateObj.toISOString() +dateObj.toISOString(); ``` ### Valeur de retour @@ -37,28 +37,34 @@ L'exemple ci-dessus analyse une chaîne de caractères non-standard, qui peut do Cette méthode fut standardisée avec la cinquième édition d'ECMAScript. Afin d'utiliser cette méthode avec les moteurs qui n'en disposent pas nativement, on pourra utiliser ce fragment de code : ```js -if ( !Date.prototype.toISOString ) { - ( function() { - +if (!Date.prototype.toISOString) { + (function () { function pad(number) { - if ( number < 10 ) { - return '0' + number; + if (number < 10) { + return "0" + number; } return number; } - Date.prototype.toISOString = function() { - return this.getUTCFullYear() + - '-' + pad( this.getUTCMonth() + 1 ) + - '-' + pad( this.getUTCDate() ) + - 'T' + pad( this.getUTCHours() ) + - ':' + pad( this.getUTCMinutes() ) + - ':' + pad( this.getUTCSeconds() ) + - '.' + (this.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) + - 'Z'; + Date.prototype.toISOString = function () { + return ( + this.getUTCFullYear() + + "-" + + pad(this.getUTCMonth() + 1) + + "-" + + pad(this.getUTCDate()) + + "T" + + pad(this.getUTCHours()) + + ":" + + pad(this.getUTCMinutes()) + + ":" + + pad(this.getUTCSeconds()) + + "." + + (this.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) + + "Z" + ); }; - - }() ); + })(); } ``` diff --git a/files/fr/web/javascript/reference/global_objects/date/tojson/index.md b/files/fr/web/javascript/reference/global_objects/date/tojson/index.md index c4162096636c9c..e71e1479904785 100644 --- a/files/fr/web/javascript/reference/global_objects/date/tojson/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/tojson/index.md @@ -13,7 +13,7 @@ La méthode **`toJSON()`** renvoie une chaîne représentant l'objet {{jsxref("D ## Syntaxe ```js -dateObj.toJSON() +dateObj.toJSON(); ``` ### Valeur de retour @@ -29,7 +29,7 @@ Les instances de {{jsxref("Date")}} identifient un instant précis dans le temps ### Utiliser `toJSON()` ```js -var jsonDate = (new Date()).toJSON(); +var jsonDate = new Date().toJSON(); var retourVersDate = new Date(jsonDate); console.log(jsonDate); //2015-10-26T07:46:36.611Z diff --git a/files/fr/web/javascript/reference/global_objects/date/tolocaledatestring/index.md b/files/fr/web/javascript/reference/global_objects/date/tolocaledatestring/index.md index bb9711206f6c08..a5539f8cd0e38b 100644 --- a/files/fr/web/javascript/reference/global_objects/date/tolocaledatestring/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/tolocaledatestring/index.md @@ -15,9 +15,9 @@ Les arguments `locales` et `options` permettent aux applications de définir le ## Syntaxe ```js -toLocaleDateString() -toLocaleDateString(locales) -toLocaleDateString(locales, options) +toLocaleDateString(); +toLocaleDateString(locales); +toLocaleDateString(locales, options); ``` ### Paramètres @@ -119,7 +119,12 @@ Les résultats fournis par `toLocaleDateString()` peuvent être personnalisés g let date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0)); // fournir le jour de la semaine avec une date longue -let options = {weekday: "long", year: "numeric", month: "long", day: "numeric"}; +let options = { + weekday: "long", + year: "numeric", + month: "long", + day: "numeric", +}; console.log(date.toLocaleDateString("de-DE", options)); // → "Donnerstag, 20. Dezember 2012" diff --git a/files/fr/web/javascript/reference/global_objects/date/tolocalestring/index.md b/files/fr/web/javascript/reference/global_objects/date/tolocalestring/index.md index c910280c2519dd..83fffa7c056464 100644 --- a/files/fr/web/javascript/reference/global_objects/date/tolocalestring/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/tolocalestring/index.md @@ -17,9 +17,9 @@ Les anciennes implémentations ignoraient ces arguments, la locale et le format ## Syntaxe ```js -toLocaleString() -toLocaleString(locales) -toLocaleString(locales, options) +toLocaleString(); +toLocaleString(locales); +toLocaleString(locales, options); ``` ### Paramètres @@ -113,7 +113,12 @@ Les résultats fournis par `toLocaleString()` peuvent être personnalisés grâc let date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0)); // obtenir le jour de la semaine avec une date longue -let options = {weekday: "long", year: "numeric", month: "long", day: "numeric"}; +let options = { + weekday: "long", + year: "numeric", + month: "long", + day: "numeric", +}; console.log(date.toLocaleString("de-DE", options)); // → "Donnerstag, 20. Dezember 2012" @@ -126,7 +131,7 @@ console.log(date.toLocaleString("en-US", options)); // → "Thursday, December 20, 2012, UTC" // parfois, même les USA ont besoin d'avoir une heure sur 24h -console.log(date.toLocaleString("en-US", {hour12: false})); +console.log(date.toLocaleString("en-US", { hour12: false })); // → "12/19/2012, 19:00:00" ``` @@ -139,7 +144,8 @@ Ainsi, IE et Edge ajoutent des caractères de contrôle bidirectionnels autour d Aussi, mieux vaut ne pas comparer un résultat fourni par `toLocaleString()` avec une valeur statique : ```js example-bad -"1/1/2019, 01:00:00" === new Date("2019-01-01T00:00:00Z").toLocaleString("en-US"); +"1/1/2019, 01:00:00" === + new Date("2019-01-01T00:00:00Z").toLocaleString("en-US"); // true pour Firefox et les autres // false pour IE et Edge ``` diff --git a/files/fr/web/javascript/reference/global_objects/date/tolocaletimestring/index.md b/files/fr/web/javascript/reference/global_objects/date/tolocaletimestring/index.md index 9c4a508f241d08..fb0f539087f709 100644 --- a/files/fr/web/javascript/reference/global_objects/date/tolocaletimestring/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/tolocaletimestring/index.md @@ -15,9 +15,9 @@ Les anciennes implémentations ignorent ces arguments, la locale utilisée et le ## Syntaxe ```js -toLocaleTimeString() -toLocaleTimeString(locales) -toLocaleTimeString(locales, options) +toLocaleTimeString(); +toLocaleTimeString(locales); +toLocaleTimeString(locales, options); ``` ### Paramètres @@ -95,12 +95,12 @@ Les résultats fournis par `toLocaleTimeString()` peuvent être personnalisés g var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0)); // une application peut vouloir utiliser UTC et le montrer -var options = {timeZone: "UTC", timeZoneName: "short"}; +var options = { timeZone: "UTC", timeZoneName: "short" }; console.log(date.toLocaleTimeString("en-US", options)); // → "3:00:00 AM GMT" // parfois, même les USA ont besoin du format sur 24h -console.log(date.toLocaleTimeString("en-US", {hour12: false})); +console.log(date.toLocaleTimeString("en-US", { hour12: false })); // → "19:00:00" ``` diff --git a/files/fr/web/javascript/reference/global_objects/date/tostring/index.md b/files/fr/web/javascript/reference/global_objects/date/tostring/index.md index dbfc6020fae43d..755c49c631c3d1 100644 --- a/files/fr/web/javascript/reference/global_objects/date/tostring/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/tostring/index.md @@ -13,7 +13,7 @@ La méthode **`toString()`** renvoie une chaîne de caractères représentant l' ## Syntaxe ```js -dateObj.toString() +dateObj.toString(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/date/totimestring/index.md b/files/fr/web/javascript/reference/global_objects/date/totimestring/index.md index 4af7aeacc5389f..d268b53cd63fba 100644 --- a/files/fr/web/javascript/reference/global_objects/date/totimestring/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/totimestring/index.md @@ -13,7 +13,7 @@ La méthode **`toTimeString()`** renvoie la partie « heure » de l'objet `Date` ## Syntaxe ```js -dateObj.toTimeString() +dateObj.toTimeString(); ``` ### Valeur de retour @@ -33,7 +33,7 @@ La méthode `toTimeString()` est particulièrement utile parce que les moteurs i ```js var d = new Date(1993, 6, 28, 14, 39, 7); -console.log(d.toString()); // Wed Jul 28 1993 14:39:07 GMT-0600 (PDT) +console.log(d.toString()); // Wed Jul 28 1993 14:39:07 GMT-0600 (PDT) console.log(d.toTimeString()); // 14:39:07 GMT-0600 (PDT) ``` diff --git a/files/fr/web/javascript/reference/global_objects/date/toutcstring/index.md b/files/fr/web/javascript/reference/global_objects/date/toutcstring/index.md index 5827783fac1c98..7012ca3e13be5e 100644 --- a/files/fr/web/javascript/reference/global_objects/date/toutcstring/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/toutcstring/index.md @@ -13,7 +13,7 @@ La méthode **`toUTCString()`** convertit une date en une chaîne de caractères ## Syntaxe ```js -dateObj.toUTCString() +dateObj.toUTCString(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/date/valueof/index.md b/files/fr/web/javascript/reference/global_objects/date/valueof/index.md index 64707cba2c4aa0..6110cf4eedb043 100644 --- a/files/fr/web/javascript/reference/global_objects/date/valueof/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/valueof/index.md @@ -13,7 +13,7 @@ La méthode **`valueOf()`** renvoie la valeur primitive d'un objet {{jsxref("Dat ## Syntaxe ```js -date.valueOf() +date.valueOf(); ``` ### Valeur de retour @@ -34,7 +34,7 @@ Cette méthode est souvent appelée en interne par le moteur JavaScript et n'est ```js var x = new Date(56, 6, 17); -var maVar = x.valueOf(); // maVar vaut -424713600000 +var maVar = x.valueOf(); // maVar vaut -424713600000 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/decodeuri/index.md b/files/fr/web/javascript/reference/global_objects/decodeuri/index.md index 4369e44e069776..21239ae7756032 100644 --- a/files/fr/web/javascript/reference/global_objects/decodeuri/index.md +++ b/files/fr/web/javascript/reference/global_objects/decodeuri/index.md @@ -13,7 +13,7 @@ La méthode **`decodeURI()`** permet de décoder un Uniform Resource Identifier ## Syntaxe ```js -decodeURI(encodedURI) +decodeURI(encodedURI); ``` ### Paramètres @@ -38,7 +38,9 @@ Cette méthode remplace chaque séquence d'échappement présente dans l'URI enc ### Décoder une URL cyrillique ```js -decodeURI("https://developer.mozilla.org/ru/docs/JavaScript_%D1%88%D0%B5%D0%BB%D0%BB%D1%8B"); +decodeURI( + "https://developer.mozilla.org/ru/docs/JavaScript_%D1%88%D0%B5%D0%BB%D0%BB%D1%8B", +); // "https://developer.mozilla.org/ru/docs/JavaScript_шеллы" ``` @@ -46,8 +48,8 @@ decodeURI("https://developer.mozilla.org/ru/docs/JavaScript_%D1%88%D0%B5%D0%BB%D ```js try { - var a = decodeURI('%E0%A4%A'); -} catch(e) { + var a = decodeURI("%E0%A4%A"); +} catch (e) { console.error(e); } diff --git a/files/fr/web/javascript/reference/global_objects/decodeuricomponent/index.md b/files/fr/web/javascript/reference/global_objects/decodeuricomponent/index.md index 9015a848b5610e..fc8df9dd6d43f8 100644 --- a/files/fr/web/javascript/reference/global_objects/decodeuricomponent/index.md +++ b/files/fr/web/javascript/reference/global_objects/decodeuricomponent/index.md @@ -13,7 +13,7 @@ La fonction **`decodeURIComponent()`** permet de décoder un composant d'un Unif ## Syntaxe ```js -decodeURIComponent(encodedURI) +decodeURIComponent(encodedURI); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/encodeuri/index.md b/files/fr/web/javascript/reference/global_objects/encodeuri/index.md index b6f18b2d3d9abf..1e7030b36068b8 100644 --- a/files/fr/web/javascript/reference/global_objects/encodeuri/index.md +++ b/files/fr/web/javascript/reference/global_objects/encodeuri/index.md @@ -13,7 +13,7 @@ La fonction **`encodeURI()`** encode un Uniform Resource Identifier (URI) en rem ## Syntaxe ```js -encodeURI(URI) +encodeURI(URI); ``` ### Paramètres @@ -36,8 +36,8 @@ A-Z a-z 0-9 ; , / ? : @ & = + $ - _ . ! ~ * ' ( ) # `encodeURI()` est différente de {{jsxref("encodeURIComponent")}}. Par exemple : ```js -var set1 = ";,/?:@&=+$#"; // Caractères réservés -var set2 = "-_.!~*'()"; // Caractères non-réservés +var set1 = ";,/?:@&=+$#"; // Caractères réservés +var set2 = "-_.!~*'()"; // Caractères non-réservés var set3 = "ABC abc 123"; // Caractères alphanumériques et espace console.log(encodeURI(set1)); // ;,/?:@&=+$# @@ -49,19 +49,19 @@ console.log(encodeURIComponent(set2)); // -_.!~*'() console.log(encodeURIComponent(set3)); // ABC%20abc%20123 (l'espace est encodé en %20) ``` -Une exception {{jsxref("URIError")}} sera levée si on tente d'encoder un caractère *surrogate* (demi-codet) qui ne fait pas partie d'une paire : +Une exception {{jsxref("URIError")}} sera levée si on tente d'encoder un caractère _surrogate_ (demi-codet) qui ne fait pas partie d'une paire : ```js // On a une paire de codets surrogate -console.log(encodeURI('\uD800\uDFFF')); +console.log(encodeURI("\uD800\uDFFF")); // Ici, seul le caractère "haut" // ce qui déclenche une "URIError: malformed URI sequence" -console.log(encodeURI('\uD800')); +console.log(encodeURI("\uD800")); // Ici, seul le caractère "bas" // ce qui déclenche une "URIError: malformed URI sequence" -console.log(encodeURI('\uDFFF')); +console.log(encodeURI("\uDFFF")); ``` `encodeURI()` ne permet pas de former des requêtes HTTP GET ou POST (par exemple avec {{domxref("XMLHTTPRequest")}}) car "&", "+" et "=" ne sont pas encodés et sont traités comme des caractères spéciaux (toutefois, la méthode. {{jsxref("encodeURIComponent")}} pourra être utilisée pour encoder ces caractères). @@ -70,7 +70,7 @@ Si on souhaite suivre la [RFC3986](http://tools.ietf.org/html/rfc3986) qui conce ```js function fixedEncodeURI(str) { - return encodeURI(str).replace(/%5B/g, '[').replace(/%5D/g, ']'); + return encodeURI(str).replace(/%5B/g, "[").replace(/%5D/g, "]"); } ``` diff --git a/files/fr/web/javascript/reference/global_objects/encodeuricomponent/index.md b/files/fr/web/javascript/reference/global_objects/encodeuricomponent/index.md index 1142fbb67a3dce..28cca5c6b226ee 100644 --- a/files/fr/web/javascript/reference/global_objects/encodeuricomponent/index.md +++ b/files/fr/web/javascript/reference/global_objects/encodeuricomponent/index.md @@ -32,9 +32,9 @@ Une nouvelle chaîne de caractères qui représente un composant d'URI obtenu en La méthode `encodeURIComponent()` diffère de la méthode `encodeURI()` par rapport aux caractères qui sont encodés : ```js -var set1 = ";,/?:@&=+$"; // Caractères réservés -var set2 = "-_.!~*'()"; // Caractères non-réservés -var set3 = "#"; // Croisillon +var set1 = ";,/?:@&=+$"; // Caractères réservés +var set2 = "-_.!~*'()"; // Caractères non-réservés +var set3 = "#"; // Croisillon var set4 = "ABC abc 123"; // Caractères alphanumériques et espace console.log(encodeURI(set1)); // ;,/?:@&=+$ @@ -52,13 +52,13 @@ Une exception {{jsxref("URIError")}} sera levée lorsqu'on utilise cette fonctio ```js // la paire de demi-codets : OK -console.log(encodeURIComponent('\uD800\uDFFF')); +console.log(encodeURIComponent("\uD800\uDFFF")); // seul le demi-codet supérieur : "URIError: malformed URI sequence" -console.log(encodeURIComponent('\uD800')); +console.log(encodeURIComponent("\uD800")); // seul le demi-codet inférieur : "URIError: malformed URI sequence" -console.log(encodeURIComponent('\uDFFF')); +console.log(encodeURIComponent("\uDFFF")); ``` Afin d'éviter des requêtes inattendues vers le serveur, il est conseillé d'utiliser la fonction `encodeURIComponent()` pour n'importe quel paramètre qui aurait été saisi par l'utilisateur et qui ferait partie d'un URI. Ainsi, si un utilisateur peut saisir "`Thym &access=admin`" dans une variable `commentaire` et qu'on n'utilise pas `encodeURIComponent()`, on obtiendra la chaîne `commentaire=Thym%20&access=admin`. On voit ici que l'esperluette (&) et le signe égal forment une nouvelle paire clé/valeur. Au lieu d'avoir une clé POST `commentaire` égale à "`Thym &access=admin`", on aura deux clés POST, l'une égale à "`Thym`" et une seconde (`access`) égale à `admin`. @@ -68,9 +68,9 @@ Pour [`application/x-www-form-urlencoded`](https://www.whatwg.org/specs/web-apps Pour utiliser une fonction qui respecte la [RFC 3986](https://tools.ietf.org/html/rfc3986), plus stricte (qui réserve les caractères !, ', (, ), et \* même si ces caractères n'ont pas d'usage normalisé), on pourra utiliser la fonction suivante : ```js -function fixedEncodeURIComponent (str) { - return encodeURIComponent(str).replace(/[!'()*]/g, function(c) { - return '%' + c.charCodeAt(0).toString(16); +function fixedEncodeURIComponent(str) { + return encodeURIComponent(str).replace(/[!'()*]/g, function (c) { + return "%" + c.charCodeAt(0).toString(16); }); } ``` @@ -80,37 +80,43 @@ function fixedEncodeURIComponent (str) { Dans l'exemple qui suit, on utilise une méthode spéciale pour l'encodage afin d'utiliser les paramètres d'en-tête de réponse `Content-Disposition` et `Link` (pour, par exemple, représenter des noms de fichiers en UTF-8) : ```js -var nomFichier = 'mon fichier(2).txt'; -var header = "Content-Disposition: attachment; filename*=UTF-8''" - + encodeRFC5987ValueChars(nomFichier); +var nomFichier = "mon fichier(2).txt"; +var header = + "Content-Disposition: attachment; filename*=UTF-8''" + + encodeRFC5987ValueChars(nomFichier); console.log(header); // affiche "Content-Disposition: attachment; filename*=UTF-8''mon%20fichier%282%29.txt" - -function encodeRFC5987ValueChars (str) { - return encodeURIComponent(str). - // Bien que la RFC 3986 réserve "!", RFC 5987 ne réserve pas ce caractère, - // il n'est donc pas nécessaire l'échapper - replace(/['()]/g, escape). // c'est-à-dire %27 %28 %29 - replace(/\*/g, '%2A'). - // Selon la RFC 5987 ce qui suit n'est pas nécessairement requis - // on peut donc bénéficier d'un peu plus de lisibilité : |`^ - replace(/%(?:7C|60|5E)/g, unescape); +function encodeRFC5987ValueChars(str) { + return ( + encodeURIComponent(str) + // Bien que la RFC 3986 réserve "!", RFC 5987 ne réserve pas ce caractère, + // il n'est donc pas nécessaire l'échapper + .replace(/['()]/g, escape) // c'est-à-dire %27 %28 %29 + .replace(/\*/g, "%2A") + // Selon la RFC 5987 ce qui suit n'est pas nécessairement requis + // on peut donc bénéficier d'un peu plus de lisibilité : |`^ + .replace(/%(?:7C|60|5E)/g, unescape) + ); } // Voici une autre version équivalente function encodeRFC5987ValueChars2(str) { - return encodeURIComponent(str). - // Bien que la RFC 3986 réserve "!", RFC 5987 ne réserve pas ce caractère, - // il n'est donc pas nécessaire l'échapper - replace(/['()*]/g, c => '%' + c.charCodeAt(0).toString(16)). // i.e., %27 %28 %29 %2a - // on notera que l'encodage valide pour "*" est %2A et qui faut donc appeler toUpperCase() - // pour encoder exactement. - - // Selon la RFC 5987 ce qui suit n'est pas nécessairement requis - // on peut donc bénéficier d'un peu plus de lisibilité : |`^ - replace(/%(7C|60|5E)/g, (str, hex) => String.fromCharCode(parseInt(hex, 16))); + return ( + encodeURIComponent(str) + // Bien que la RFC 3986 réserve "!", RFC 5987 ne réserve pas ce caractère, + // il n'est donc pas nécessaire l'échapper + .replace(/['()*]/g, (c) => "%" + c.charCodeAt(0).toString(16)) // i.e., %27 %28 %29 %2a + // on notera que l'encodage valide pour "*" est %2A et qui faut donc appeler toUpperCase() + // pour encoder exactement. + + // Selon la RFC 5987 ce qui suit n'est pas nécessairement requis + // on peut donc bénéficier d'un peu plus de lisibilité : |`^ + .replace(/%(7C|60|5E)/g, (str, hex) => + String.fromCharCode(parseInt(hex, 16)), + ) + ); } ``` diff --git a/files/fr/web/javascript/reference/global_objects/error/columnnumber/index.md b/files/fr/web/javascript/reference/global_objects/error/columnnumber/index.md index 11f4a24a3ba80f..37c3ff47476b08 100644 --- a/files/fr/web/javascript/reference/global_objects/error/columnnumber/index.md +++ b/files/fr/web/javascript/reference/global_objects/error/columnnumber/index.md @@ -15,7 +15,7 @@ La propriété **`columnNumber`** contient le numéro de la colonne, dans la lig ```js var e = new Error("Ne peut pas lire la donnée"); throw e; -console.log(e.columnNumber) // 0 +console.log(e.columnNumber); // 0 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/error/error/index.md b/files/fr/web/javascript/reference/global_objects/error/error/index.md index 3166c8772c37f0..571246c6e1cd9b 100644 --- a/files/fr/web/javascript/reference/global_objects/error/error/index.md +++ b/files/fr/web/javascript/reference/global_objects/error/error/index.md @@ -11,11 +11,11 @@ Le constructeur **`Error`** permet de créer un objet représentant une erreur. ## Syntaxe ```js -new Error() -new Error(message) -new Error(message, options) -new Error(message, nomFichier) -new Error(message, nomFichier, numeroLigne) +new Error(); +new Error(message); +new Error(message, options); +new Error(message, nomFichier); +new Error(message, nomFichier, numeroLigne); ``` ### Paramètres @@ -23,10 +23,12 @@ new Error(message, nomFichier, numeroLigne) - `message` {{Optional_Inline}} - : Une description de l'erreur, compréhensible par un humain. - `options` {{Optional_Inline}} + - : Un objet avec les propriétés suivantes : - `cause` {{Optional_Inline}} - : Une propriété qui indique la cause spécifique de l'erreur. Lors de l'interception puis du renvoi d'une erreur avec un autre message d'erreur, cette propriété devrait être utilisée afin de transmettre le message d'erreur original. + - `nomFichier` {{Optional_Inline}} {{Non-standard_inline}} - : La valeur de la propriété `nomFichier` pour l'objet `Error` créé. Par défaut, il s'agit du nom du fichier contenant le code qui a invoqué le constructeur `Error()`. - `numeroLigne` {{Optional_Inline}} {{Non-standard_inline}} diff --git a/files/fr/web/javascript/reference/global_objects/error/index.md b/files/fr/web/javascript/reference/global_objects/error/index.md index 567051bfc91043..7bc6a9f33476d7 100644 --- a/files/fr/web/javascript/reference/global_objects/error/index.md +++ b/files/fr/web/javascript/reference/global_objects/error/index.md @@ -87,15 +87,14 @@ Il est possible de ne gérer que certains types d'erreur particuliers en testant ```js try { - toto.truc() + toto.truc(); } catch (e) { if (e instanceof EvalError) { - console.error(e.name + ' : ' + e.message) + console.error(e.name + " : " + e.message); } else if (e instanceof RangeError) { - console.error(e.name + ' : ' + e.message) + console.error(e.name + " : " + e.message); } // ... etc - else { // Si aucun cas ne correspond, on laisse l'erreur // non-gérée @@ -131,7 +130,7 @@ function faireTruc() { try { faireTruc(); } catch (err) { - switch(err.message) { + switch (err.message) { case "Echoue d'une certaine façon": gererUneFacon(err.cause); break; @@ -148,7 +147,7 @@ Il est aussi possible d'utiliser la propriété `cause` des [types d'erreur pers class MonErreur extends Error { constructor(/* des arguments */) { // Il faut passer les paramètres `message` et `options` - // pour que la propriété "cause" soit initialisée. + // pour que la propriété "cause" soit initialisée. super(message, options); } } @@ -168,7 +167,7 @@ Voir [cette question (en anglais) sur StackOverflow](https://stackoverflow.com/q ```js class ErreurSpecifique extends Error { - constructor(toto = 'truc', ...params) { + constructor(toto = "truc", ...params) { // On passe les arguments restants (y compris ceux // de l'éditeur tiers) au constructeur parent super(...params); @@ -179,7 +178,7 @@ class ErreurSpecifique extends Error { Error.captureStackTrace(this, ErreurSpecifique); } - this.name = 'ErreurSpecifique'; + this.name = "ErreurSpecifique"; // Les informations de débogage spécifiques this.toto = toto; this.date = new Date(); @@ -187,12 +186,12 @@ class ErreurSpecifique extends Error { } try { - throw new ErreurSpecifique('truc', 'trucMessage'); -} catch(e) { - console.error(e.name); // ErreurSpecifique - console.error(e.toto); // truc + throw new ErreurSpecifique("truc", "trucMessage"); +} catch (e) { + console.error(e.name); // ErreurSpecifique + console.error(e.toto); // truc console.error(e.message); // trucMessage - console.error(e.stack); // stacktrace + console.error(e.stack); // stacktrace } ``` @@ -203,7 +202,7 @@ try { ```js function ErreurSpecifique(toto, message, fileName, lineNumber) { var instance = new Error(message, fileName, lineNumber); - instance.name = 'ErreurSpecifique'; + instance.name = "ErreurSpecifique"; instance.toto = toto; Object.setPrototypeOf(instance, Object.getPrototypeOf(this)); if (Error.captureStackTrace) { @@ -217,19 +216,19 @@ ErreurSpecifique.prototype = Object.create(Error.prototype, { value: Error, enumerable: false, writable: true, - configurable: true - } + configurable: true, + }, }); -if (Object.setPrototypeOf){ +if (Object.setPrototypeOf) { Object.setPrototypeOf(ErreurSpecifique, Error); } else { ErreurSpecifique.__proto__ = Error; } try { - throw new ErreurSpecifique('truc', 'trucMessage'); -} catch(e){ + throw new ErreurSpecifique("truc", "trucMessage"); +} catch (e) { console.error(e.name); // ErreurSpecifique console.error(e.toto); // truc console.error(e.message); // trucMessage diff --git a/files/fr/web/javascript/reference/global_objects/error/linenumber/index.md b/files/fr/web/javascript/reference/global_objects/error/linenumber/index.md index 3e02c17b897887..795429d7da49da 100644 --- a/files/fr/web/javascript/reference/global_objects/error/linenumber/index.md +++ b/files/fr/web/javascript/reference/global_objects/error/linenumber/index.md @@ -15,16 +15,16 @@ La propriété **`lineNumber`** contient le numéro de la ligne qui a déclench ```js var e = new Error("Ne peut pas lire la donnée"); throw e; -console.log(e.lineNumber) // 2 +console.log(e.lineNumber); // 2 ``` ### Alternative en utilisant l'événement `error` ```js window.addEventListener("error", function (e) { - console.log(e.lineNumber); //5 + console.log(e.lineNumber); //5 }); -var e = new Error('Ne peut pas lire la donnée'); +var e = new Error("Ne peut pas lire la donnée"); throw e; ``` diff --git a/files/fr/web/javascript/reference/global_objects/error/stack/index.md b/files/fr/web/javascript/reference/global_objects/error/stack/index.md index 3a62c146117fa1..ce510ba35ea3a9 100644 --- a/files/fr/web/javascript/reference/global_objects/error/stack/index.md +++ b/files/fr/web/javascript/reference/global_objects/error/stack/index.md @@ -23,34 +23,34 @@ Les différents navigateurs définissent cette valeur à différents instants. P Le code HTML suivant démontre l'utilisation de la propriété `stack`. ```html - - + + Exemple de Trace de Pile - + + ``` En supposant que ce code a été enregistré comme `C:\exemple.html` sur un système de fichier Windows, il produira un message d'alerte dans une nouvelle fenêtre avec le texte suivant : À partir de Firefox 30 et ultérieur, ce message contiendra le numéro de colonne ([bug Firefox 762556](https://bugzil.la/762556)) : -```html +```plain trace@file:///C:/exemple.html:9:17 b@file:///C:/exemple.html:16:13 a@file:///C:/exemple.html:19:13 @@ -59,7 +59,7 @@ a@file:///C:/exemple.html:19:13 De Firefox 14 à Firefox 29 : -``` +```plain trace@file:///C:/exemple.html:9 b@file:///C:/exemple.html:16 a@file:///C:/exemple.html:19 @@ -68,7 +68,7 @@ a@file:///C:/exemple.html:19 Firefox 13 et antérieur aurait produit à la place le texte suivant : -``` +```plain Error("monError")@:0 trace()@file:///C:/exemple.html:9 b(3,4,"\n\n",(void 0),[object Object])@file:///C:/exemple.html:16 @@ -82,7 +82,7 @@ a("premier appel, premierarg")@file:///C:/exemple.html:19 ```js try { - new Function('throw new Error()')(); + new Function("throw new Error()")(); } catch (e) { console.log(e.stack); } diff --git a/files/fr/web/javascript/reference/global_objects/error/tostring/index.md b/files/fr/web/javascript/reference/global_objects/error/tostring/index.md index 3c00992559efc2..e3c3950d15e0b0 100644 --- a/files/fr/web/javascript/reference/global_objects/error/tostring/index.md +++ b/files/fr/web/javascript/reference/global_objects/error/tostring/index.md @@ -11,7 +11,7 @@ La méthode **`toString()`** renvoie une représentation de l'objet {{jsxref("Er ## Syntaxe ```js -e.toString() +e.toString(); ``` ### Valeur de retour @@ -27,19 +27,16 @@ Error.prototype.toString = function () { "use strict"; var obj = Object(this); - if (obj !== this) - throw new TypeError(); + if (obj !== this) throw new TypeError(); var name = this.name; - name = (name === undefined) ? "Error" : String(name); + name = name === undefined ? "Error" : String(name); var msg = this.message; - msg = (msg === undefined) ? "" : String(msg); + msg = msg === undefined ? "" : String(msg); - if (name === "") - return msg; - if (msg === "") - return name; + if (name === "") return msg; + if (msg === "") return name; return name + ": " + msg; }; diff --git a/files/fr/web/javascript/reference/global_objects/escape/index.md b/files/fr/web/javascript/reference/global_objects/escape/index.md index b65c678692ca90..e0e39c5c9f1ebb 100644 --- a/files/fr/web/javascript/reference/global_objects/escape/index.md +++ b/files/fr/web/javascript/reference/global_objects/escape/index.md @@ -18,7 +18,7 @@ La fonction **`escape()`** permet de renvoyer une nouvelle chaîne de caractère ## Syntaxe ```js -escape(str) +escape(str); ``` ### Paramètres @@ -39,12 +39,12 @@ La forme hexadécimale des caractères dont la valeur du codet est inférieure ## Exemples ```js -escape("abc123"); // "abc123" -escape("äöü"); // "%E4%F6%FC" -escape("ć"); // "%u0107" +escape("abc123"); // "abc123" +escape("äöü"); // "%E4%F6%FC" +escape("ć"); // "%u0107" // caractères spéciaux -escape("@*_+-./"); // "@*_+-./" +escape("@*_+-./"); // "@*_+-./" ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/eval/index.md b/files/fr/web/javascript/reference/global_objects/eval/index.md index 7cc8982ce79234..d4984fea7b1a43 100644 --- a/files/fr/web/javascript/reference/global_objects/eval/index.md +++ b/files/fr/web/javascript/reference/global_objects/eval/index.md @@ -15,7 +15,7 @@ La fonction **`eval()`** permet d'évaluer du code JavaScript représenté sous ## Syntaxe ```js -eval(str) +eval(str); ``` ### Paramètres @@ -39,7 +39,7 @@ Si l'argument passé à `eval()` n'est pas une chaîne de caractères, `eval()` ```js eval(new String("2 + 2")); // renvoie un objet String contenant "2 + 2" -eval("2 + 2"); // renvoie 4 +eval("2 + 2"); // renvoie 4 ``` Ce comportement peut être résolu de façon générique en utilisant la méthode `toString()`. @@ -53,11 +53,12 @@ Si la fonction `eval` est utilisée de manière indirecte, en l'invoquant par un ```js function test() { - var x = 2, y = 4; - console.log(eval("x + y")); // Appel direct, portée locale, résultat de 6 + var x = 2, + y = 4; + console.log(eval("x + y")); // Appel direct, portée locale, résultat de 6 var geval = eval; console.log(geval("x + y")); // Appel indirect, portée globale, lance une exception ReferenceError car `x` n'est pas défini - (0, eval)('x + y'); // un autre exemple d'appel indirect. + (0, eval)("x + y"); // un autre exemple d'appel indirect. } ``` @@ -74,23 +75,19 @@ De plus, les moteurs JavaScript modernes convertissent le code JavaScript en cod Avec `eval()` : ```js -function looseJsonParse(obj){ - return eval("(" + obj + ")"); +function looseJsonParse(obj) { + return eval("(" + obj + ")"); } -console.log(looseJsonParse( - "{a:(4-1), b:function(){}, c:new Date()}" -)) +console.log(looseJsonParse("{a:(4-1), b:function(){}, c:new Date()}")); ``` Avec `Function` : ```js -function looseJsonParse(obj){ - return Function('"use strict";return (' + obj + ')')(); +function looseJsonParse(obj) { + return Function('"use strict";return (' + obj + ")")(); } -console.log(looseJsonParse( - "{a:(4-1), b:function(){}, c:new Date()}" -)) +console.log(looseJsonParse("{a:(4-1), b:function(){}, c:new Date()}")); ``` Dans le premier cas, l'évaluation de `c: new Date()` sera beaucoup plus lente car `Date` peut faire référence à une variable déclarée avant. Dans le second cas, la fonction est évaluée dans la portée globale et le moteur peut donc utiliser {{jsxref("Date")}} directement. @@ -98,15 +95,21 @@ Dans le premier cas, l'évaluation de `c: new Date()` sera beaucoup plus lente c Autrement dit, dans le premier cas, on aurait pu avoir un code comme : ```js -function Date(n){ - return ["Monday","Tuesday","Wednesday","Thursaday","Friday","Saturday","Sunday"][n%7 || 0]; +function Date(n) { + return [ + "Monday", + "Tuesday", + "Wednesday", + "Thursaday", + "Friday", + "Saturday", + "Sunday", + ][n % 7 || 0]; } -function looseJsonParse(obj){ - return eval("(" + obj + ")"); +function looseJsonParse(obj) { + return eval("(" + obj + ")"); } -console.log(looseJsonParse( - "{a:(4-1), b:function(){}, c:new Date()}" -)) +console.log(looseJsonParse("{a:(4-1), b:function(){}, c:new Date()}")); ``` Auquel cas, le navigateur doit effectuer une recherche coûteuse afin de vérifier s'il y a des variables locales `Date`. @@ -114,17 +117,21 @@ Auquel cas, le navigateur doit effectuer une recherche coûteuse afin de vérifi Pour obtenir un résultat identique, on peut tout à fait se passer d'`eval()` : ```js -function Date(n){ - return ["Monday","Tuesday","Wednesday","Thursaday","Friday","Saturday","Sunday"][n%7 || 0]; +function Date(n) { + return [ + "Monday", + "Tuesday", + "Wednesday", + "Thursaday", + "Friday", + "Saturday", + "Sunday", + ][n % 7 || 0]; } -function runCodeWithDateFunction(obj){ - return Function('"use strict";return (' + obj + ')')()( - Date - ); +function runCodeWithDateFunction(obj) { + return Function('"use strict";return (' + obj + ")")()(Date); } -console.log(runCodeWithDateFunction( - "function(Date){ return Date(5) }" -)) +console.log(runCodeWithDateFunction("function(Date){ return Date(5) }")); ``` 1\. Le code passé à `runCodeWithDateFunction` peut être minifié. @@ -143,16 +150,16 @@ Enfin, pour la plupart des cas, on doit pouvoir éviter de passer par ```js var obj = { a: 20, b: 30 }; -var nomPropriété = getNomProp(); //une méthode qui renvoie "a" ou "b" +var nomPropriété = getNomProp(); //une méthode qui renvoie "a" ou "b" -eval( "var résultat = obj." + nomPropriété ); +eval("var résultat = obj." + nomPropriété); ``` Cependant, `eval()` n'est pas du tout nécessaire. Il est beaucoup plus simple, plus sécurisé, plus rapide, d'utiliser les [accesseurs de propriétés](/fr/docs/Web/JavaScript/Reference/Opérateurs/Opérateurs_de_membres) : ```js var obj = { a: 20, b: 30 }; -var nomPropriété = getNomProp(); // une méthode qui renvoie "a" or "b" +var nomPropriété = getNomProp(); // une méthode qui renvoie "a" or "b" var résultat = obj[nomPropriété]; // obj[ "a" ] correspond à obj.a ``` @@ -165,7 +172,7 @@ Les fonctions JavaScript sont des [citoyens de premier rang du langage](https:// setTimeout(function() { ... }, 1000); // au lieu de elt.setAttribute("onclick", "...") on utilisera : -elt.addEventListener("click", function() { ... } , false); +elt.addEventListener("click", function() { ... } , false); ``` [Les fermetures (_closures_)](/fr/docs/Web/JavaScript/Guide/Closures) sont utiles lorsqu'on souhaite obtenir des fonctions paramétrées sans avoir à concaténer des chaînes de caractères. @@ -195,7 +202,7 @@ var x = 2; var y = 39; var z = "42"; eval("x + y + 1"); // renvoie 42 -eval(z); // renvoie 42 +eval(z); // renvoie 42 ``` ### Utiliser `eval()` pour une chaîne d'instructions @@ -205,7 +212,7 @@ Dans l'exemple qui suit, `eval()` est utilisée pour évaluer la chaîne de cara ```js var x = 5; var str = "if (x == 5) {console.log('z vaut 42'); z = 42;} else z = 0; "; -console.log("z vaut "+eval(str)); +console.log("z vaut " + eval(str)); ``` ### Le résultat d'`eval()` est celui de la dernière expression @@ -215,12 +222,12 @@ console.log("z vaut "+eval(str)); ```js var str = "if ( a ) { 1+1; } else { 1+2; }"; var a = true; -var b = eval(str); // renvoie 2 +var b = eval(str); // renvoie 2 console.log("b vaut : " + b); a = false; -b = eval(str); // renvoie 3 +b = eval(str); // renvoie 3 console.log("b vaut : " + b); ``` @@ -230,10 +237,10 @@ console.log("b vaut : " + b); Pour qu'une fonction soit restituée lors de l'évaluation, il est nécessaire d'encadrer l'expression contenue dans la chaîne de caractères avec des parenthèses : ```js -var fctStr1 = "function a() {}" -var fctStr2 = "(function a() {})" -var fct1 = eval(fctStr1) // renvoie undefined -var fct2 = eval(fctStr2) // renvoie une function +var fctStr1 = "function a() {}"; +var fctStr2 = "(function a() {})"; +var fct1 = eval(fctStr1); // renvoie undefined +var fct2 = eval(fctStr2); // renvoie une function ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/evalerror/evalerror/index.md b/files/fr/web/javascript/reference/global_objects/evalerror/evalerror/index.md index 09f37ee09b80a3..ecaabb630ec7ee 100644 --- a/files/fr/web/javascript/reference/global_objects/evalerror/evalerror/index.md +++ b/files/fr/web/javascript/reference/global_objects/evalerror/evalerror/index.md @@ -11,10 +11,10 @@ Le **constructeur `EvalError()`** permet de créer un objet représentant une er ## Syntaxe ```js -new EvalError() -new EvalError(message) -new EvalError(message, nomFichier) -new EvalError(message, nomFichier, numeroLigne) +new EvalError(); +new EvalError(message); +new EvalError(message, nomFichier); +new EvalError(message, nomFichier, numeroLigne); ``` ### Paramètres @@ -34,15 +34,15 @@ new EvalError(message, nomFichier, numeroLigne) ```js try { - throw new EvalError('Coucou', 'unFichier.js', 10); + throw new EvalError("Coucou", "unFichier.js", 10); } catch (e) { console.log(e instanceof EvalError); // true - console.log(e.message); // "Coucou" - console.log(e.name); // "EvalError" - console.log(e.fileName); // "unFichier.js" - console.log(e.lineNumber); // 10 - console.log(e.columnNumber); // 0 - console.log(e.stack); // "@Scratchpad/2:2:9\n" + console.log(e.message); // "Coucou" + console.log(e.name); // "EvalError" + console.log(e.fileName); // "unFichier.js" + console.log(e.lineNumber); // 10 + console.log(e.columnNumber); // 0 + console.log(e.stack); // "@Scratchpad/2:2:9\n" } ``` diff --git a/files/fr/web/javascript/reference/global_objects/evalerror/index.md b/files/fr/web/javascript/reference/global_objects/evalerror/index.md index 5d40c472abddb0..0a458b77cb1ace 100644 --- a/files/fr/web/javascript/reference/global_objects/evalerror/index.md +++ b/files/fr/web/javascript/reference/global_objects/evalerror/index.md @@ -36,15 +36,15 @@ L'objet **`EvalError`** indique une erreur relative à la fonction [`eval()`](/f ```js try { - throw new EvalError('Coucou', 'unFichier.js', 10); + throw new EvalError("Coucou", "unFichier.js", 10); } catch (e) { console.log(e instanceof EvalError); // true - console.log(e.message); // "Coucou" - console.log(e.name); // "EvalError" - console.log(e.fileName); // "unFichier.js" - console.log(e.lineNumber); // 10 - console.log(e.columnNumber); // 0 - console.log(e.stack); // "@Scratchpad/2:2:9\n" + console.log(e.message); // "Coucou" + console.log(e.name); // "EvalError" + console.log(e.fileName); // "unFichier.js" + console.log(e.lineNumber); // 10 + console.log(e.columnNumber); // 0 + console.log(e.stack); // "@Scratchpad/2:2:9\n" } ``` diff --git a/files/fr/web/javascript/reference/global_objects/finalizationregistry/finalizationregistry/index.md b/files/fr/web/javascript/reference/global_objects/finalizationregistry/finalizationregistry/index.md index 495ecacdd15514..c3c635ea8538ac 100644 --- a/files/fr/web/javascript/reference/global_objects/finalizationregistry/finalizationregistry/index.md +++ b/files/fr/web/javascript/reference/global_objects/finalizationregistry/finalizationregistry/index.md @@ -33,7 +33,7 @@ new FinalizationRegistry(function(valeurTenue) { ... }) On crée le registre en fournissant la fonction de rappel : ```js -const registre = new FinalizationRegistry(valeurTenue => { +const registre = new FinalizationRegistry((valeurTenue) => { // .... }); ``` diff --git a/files/fr/web/javascript/reference/global_objects/finalizationregistry/index.md b/files/fr/web/javascript/reference/global_objects/finalizationregistry/index.md index 01edeb998660a4..593897129f9be6 100644 --- a/files/fr/web/javascript/reference/global_objects/finalizationregistry/index.md +++ b/files/fr/web/javascript/reference/global_objects/finalizationregistry/index.md @@ -17,12 +17,12 @@ Un objet **`FinalizationRegistry`** permet de déclencher une fonction de rappel On crée le registre en passant la fonction de rappel en paramètre : ```js -const registre = new FinalizationRegistry(valeurTenue => { +const registre = new FinalizationRegistry((valeurTenue) => { // … }); ``` -Ensuite, avec la méthode `register` on inscrit au registre les différents objets pour lesquels on veut que la fonction de rappel de nettoyage soit appelée. Cette fonction prend en argument la valeur courante et une *valeur tenue* pour celle-ci : +Ensuite, avec la méthode `register` on inscrit au registre les différents objets pour lesquels on veut que la fonction de rappel de nettoyage soit appelée. Cette fonction prend en argument la valeur courante et une _valeur tenue_ pour celle-ci : ```js registre.register(unObjet, "une valeur"); @@ -68,7 +68,7 @@ Une utilisation correcte de `FinalizationRegistry` nécessite une réflexion suf Voici quelques sujets spécifiques inclus dans [le document explicatif de la proposition correspondante](https://github.com/tc39/proposal-weakrefs/blob/master/reference.md) : -> [Les ramasses-miettes](https://fr.wikipedia.org/wiki/Ramasse-miettes_(informatique)) sont compliqués. Si une application ou une bibliothèque dépend d'un ramasse-miettes nettoyant un registre FinalizationRegistry ou appelant un finaliseur de façon précise et prédictible, qu'elle se prépare à être déçue : le nettoyage pourra avoir lieu bien plus tard que prévu voire pas du tout. Ce comportement grandement variable est dû : +> [Les ramasses-miettes]() sont compliqués. Si une application ou une bibliothèque dépend d'un ramasse-miettes nettoyant un registre FinalizationRegistry ou appelant un finaliseur de façon précise et prédictible, qu'elle se prépare à être déçue : le nettoyage pourra avoir lieu bien plus tard que prévu voire pas du tout. Ce comportement grandement variable est dû : > > - Au fait qu'un objet peut être récupéré par le ramasse-miettes bien plus tôt qu'un autre, même s'il devient inaccessible au même temps, par exemple en raison du ramassage générationnel. > - À l'action du ramasse-miettes qui peut être divisée dans le temps en utilisant des techniques incrémentales et concurrentes. @@ -95,14 +95,14 @@ Quelques notes à propos des fonctions de rappel de nettoyage : On crée le registre en y passant la fonction de rappel : ```js -const registre = new FinalizationRegistry(valeurTenue => { +const registre = new FinalizationRegistry((valeurTenue) => { // .... }); ``` ### Enregistrer des objets en vue de leur nettoyage -Ensuite, on enregistre les objets pour lesquels on souhaite avoir la fonction de rappel de nettoyage exécutée. Pour cela, on appelle la méthode `register` en lui passant l'objet et une *valeur tenue* correspondante : +Ensuite, on enregistre les objets pour lesquels on souhaite avoir la fonction de rappel de nettoyage exécutée. Pour cela, on appelle la méthode `register` en lui passant l'objet et une _valeur tenue_ correspondante : ```js registre.register(unObjet, "une valeur"); diff --git a/files/fr/web/javascript/reference/global_objects/finalizationregistry/register/index.md b/files/fr/web/javascript/reference/global_objects/finalizationregistry/register/index.md index 85f436bd72d596..f733ed83bb030b 100644 --- a/files/fr/web/javascript/reference/global_objects/finalizationregistry/register/index.md +++ b/files/fr/web/javascript/reference/global_objects/finalizationregistry/register/index.md @@ -45,7 +45,7 @@ registry.register(cible, "une valeur", cible); La ligne suivante enregistre l'objet `cible` et passe un autre objet comme valeur tenue. L'absence de jeton de désenregistrement indique que `cible` ne peut pas être retiré du registre) : ```js -registry.register(cible, {"utile": "info à propos de la cible"}); +registry.register(cible, { utile: "info à propos de la cible" }); ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/finalizationregistry/unregister/index.md b/files/fr/web/javascript/reference/global_objects/finalizationregistry/unregister/index.md index 94f36b710d14de..1389ef223ae882 100644 --- a/files/fr/web/javascript/reference/global_objects/finalizationregistry/unregister/index.md +++ b/files/fr/web/javascript/reference/global_objects/finalizationregistry/unregister/index.md @@ -35,9 +35,11 @@ Cet exemple illustre l'enregistrement d'un objet en l'utilisant lui-même comme ```js class Bidule { - #cleanup = label => { - // ^^^^^−−−−− valeur tenue - console.error(`La méthode \`release\` n'a jamais été appelée pour l'objet avec l'étiquette "${label}"`); + #cleanup = (label) => { + // ^^^^^−−−−− valeur tenue + console.error( + `La méthode \`release\` n'a jamais été appelée pour l'objet avec l'étiquette "${label}"`, + ); }; #registry = new FinalizationRegistry(this.#cleanup); @@ -57,8 +59,8 @@ class Bidule { * Libère les ressources tenues par cette instance de `Bidule` . */ release() { - this.#registry.unregister(this); - // ^^^^−−−−− jeton de désenregistrement + this.#registry.unregister(this); + // ^^^^−−−−− jeton de désenregistrement } } ``` @@ -67,9 +69,11 @@ Dans l'exemple qui suit, on illustre l'enregistrement en utilisant un autre obje ```js class Bidule { - #cleanup = label => { - // ^^^^−−−−− valeur tenue - console.error(`La méthode \`release\` n'a jamais été appelée pour \`Bidule\` pour le fichier "${file.name}"`); + #cleanup = (label) => { + // ^^^^^−−−−− valeur tenue + console.error( + `La méthode \`release\` n'a jamais été appelée pour \`Bidule\` pour le fichier "${file.name}"`, + ); }; #registry = new FinalizationRegistry(this.#cleanup); diff --git a/files/fr/web/javascript/reference/global_objects/float32array/float32array/index.md b/files/fr/web/javascript/reference/global_objects/float32array/float32array/index.md index de0460a4e37f84..8be7f95e5fbfe5 100644 --- a/files/fr/web/javascript/reference/global_objects/float32array/float32array/index.md +++ b/files/fr/web/javascript/reference/global_objects/float32array/float32array/index.md @@ -45,7 +45,7 @@ console.log(float32.length); // 2 console.log(float32.BYTES_PER_ELEMENT); // 4 // À partir d'un tableau -const arr = new Float32Array([21,31]); +const arr = new Float32Array([21, 31]); console.log(arr[1]); // 31 // À partir d'un autre tableau typé @@ -58,7 +58,9 @@ const buffer = new ArrayBuffer(16); const z = new Float32Array(buffer, 0, 4); // À partir d'un itérable -const iterable = function*(){ yield* [1,2,3]; }(); +const iterable = (function* () { + yield* [1, 2, 3]; +})(); const float32 = new Float32Array(iterable); // Float32Array[1, 2, 3] ``` diff --git a/files/fr/web/javascript/reference/global_objects/float32array/index.md b/files/fr/web/javascript/reference/global_objects/float32array/index.md index 21a117217d235d..dce632ed737d2c 100644 --- a/files/fr/web/javascript/reference/global_objects/float32array/index.md +++ b/files/fr/web/javascript/reference/global_objects/float32array/index.md @@ -125,7 +125,7 @@ console.log(float32.length); // 2 console.log(float32.BYTES_PER_ELEMENT); // 4 // Construction à partir d'un tableau -var arr = new Float32Array([21,31]); +var arr = new Float32Array([21, 31]); console.log(arr[1]); // 31 // Construction à partir d'un tableau typé @@ -138,7 +138,9 @@ var buffer = new ArrayBuffer(16); var z = new Float32Array(buffer, 0, 4); // Construction à partir d'un itérable -var iterable = function*(){ yield* [1,2,3]; }(); +var iterable = (function* () { + yield* [1, 2, 3]; +})(); var float32 = new Float32Array(iterable); // Float32Array[1, 2, 3] ``` diff --git a/files/fr/web/javascript/reference/global_objects/float64array/float64array/index.md b/files/fr/web/javascript/reference/global_objects/float64array/float64array/index.md index bf6608252d7c45..1c2286e135a751 100644 --- a/files/fr/web/javascript/reference/global_objects/float64array/float64array/index.md +++ b/files/fr/web/javascript/reference/global_objects/float64array/float64array/index.md @@ -45,7 +45,7 @@ console.log(float64.length); // 2 console.log(float64.BYTES_PER_ELEMENT); // 8 // À partir d'un tableau -const arr = new Float64Array([21,31]); +const arr = new Float64Array([21, 31]); console.log(arr[1]); // 31 // À partir d'un autre tableau typé @@ -58,7 +58,9 @@ const buffer = new ArrayBuffer(32); const z = new Float64Array(buffer, 0, 4); // À partir d'un itérable -const iterable = function*(){ yield* [1,2,3]; }(); +const iterable = (function* () { + yield* [1, 2, 3]; +})(); const float64 = new Float64Array(iterable); // Float64Array[1, 2, 3] ``` diff --git a/files/fr/web/javascript/reference/global_objects/float64array/index.md b/files/fr/web/javascript/reference/global_objects/float64array/index.md index 82acd1b4ea5111..42134859b1ee7c 100644 --- a/files/fr/web/javascript/reference/global_objects/float64array/index.md +++ b/files/fr/web/javascript/reference/global_objects/float64array/index.md @@ -125,7 +125,7 @@ console.log(float64.length); // 2 console.log(float64.BYTES_PER_ELEMENT); // 8 // Construction à partir d'un tableau -var arr = new Float64Array([21,31]); +var arr = new Float64Array([21, 31]); console.log(arr[1]); // 31 // Construction à partir d'un autre tableau typé @@ -138,7 +138,9 @@ var buffer = new ArrayBuffer(32); var z = new Float64Array(buffer, 0, 4); // Construction à partir d'un itérable -var iterable = function*(){ yield* [1,2,3]; }(); +var iterable = (function* () { + yield* [1, 2, 3]; +})(); var float64 = new Float64Array(iterable); // Float64Array[1, 2, 3] ``` diff --git a/files/fr/web/javascript/reference/global_objects/function/apply/index.md b/files/fr/web/javascript/reference/global_objects/function/apply/index.md index c444f0665270ef..eb41d1a642a809 100644 --- a/files/fr/web/javascript/reference/global_objects/function/apply/index.md +++ b/files/fr/web/javascript/reference/global_objects/function/apply/index.md @@ -17,7 +17,7 @@ La méthode **`apply()`** appelle une fonction en lui passant une valeur `this` ## Syntaxe ```js -fun.apply(thisArg, [argsArray]) +fun.apply(thisArg, [argsArray]); ``` ### Paramètres @@ -60,10 +60,11 @@ Function.prototype.construct = function (aArgs) { > **Note :** La méthode {{jsxref("Object.create()")}} utilisée ci-avant est relativement nouvelle. Pour une autre méthode qui utilise les `closure`, on pourra utiliser : > > ```js -> Function.prototype.construct = function(aArgs) { -> var fConstructeur = this, fNouveauConstructeur = function() { -> fConstructeur.apply(this, aArgs); -> }; +> Function.prototype.construct = function (aArgs) { +> var fConstructeur = this, +> fNouveauConstructeur = function () { +> fConstructeur.apply(this, aArgs); +> }; > fNouveauConstructeur.prototype = fConstructeur.prototype; > return new fNouveauConstructeur(); > }; @@ -72,10 +73,10 @@ Function.prototype.construct = function (aArgs) { Exemple d'utilisation : ```js -function MonConstructeur () { - for (var nProp = 0; nProp < arguments.length; nProp++) { - this["propriété" + nProp] = arguments[nProp]; - } +function MonConstructeur() { + for (var nProp = 0; nProp < arguments.length; nProp++) { + this["propriété" + nProp] = arguments[nProp]; + } } var monTableau = [4, "Coucou monde !", false]; @@ -127,13 +128,11 @@ var max = Math.max.apply(null, nombres); var min = Math.min.apply(null, nombres); /* vs. algorithme trivial avec une boucle */ -max = -Infinity, min = +Infinity; +(max = -Infinity), (min = +Infinity); for (var i = 0; i < nombres.length; i++) { - if (nombres[i] > max) - max = nombres[i]; - if (nombres[i] < min) - min = nombres[i]; + if (nombres[i] > max) max = nombres[i]; + if (nombres[i] < min) min = nombres[i]; } ``` @@ -145,8 +144,10 @@ function minimumDuTableau(tab) { var QUANTUM = 32768; for (var i = 0, longueur = tab.length; i < len; i += QUANTUM) { - var submin = Math.min.apply(null, - tab.slice(i, Math.min(i + QUANTUM, longueur))); + var submin = Math.min.apply( + null, + tab.slice(i, Math.min(i + QUANTUM, longueur)), + ); min = Math.min(submin, min); } diff --git a/files/fr/web/javascript/reference/global_objects/function/arguments/index.md b/files/fr/web/javascript/reference/global_objects/function/arguments/index.md index f9f06151ee5a01..8bf680d7b5dc9b 100644 --- a/files/fr/web/javascript/reference/global_objects/function/arguments/index.md +++ b/files/fr/web/javascript/reference/global_objects/function/arguments/index.md @@ -19,11 +19,13 @@ La valeur de la propriété `arguments` est normalement `null` si la fonction n' ## Exemples ```js -function f(n) { g(n-1); } +function f(n) { + g(n - 1); +} function g(n) { console.log("avant : " + g.arguments[0]); - if(n>0) f(n); + if (n > 0) f(n); console.log("après : " + g.arguments[0]); } diff --git a/files/fr/web/javascript/reference/global_objects/function/bind/index.md b/files/fr/web/javascript/reference/global_objects/function/bind/index.md index 83fd098b6ffeb8..d47f60bf9ca250 100644 --- a/files/fr/web/javascript/reference/global_objects/function/bind/index.md +++ b/files/fr/web/javascript/reference/global_objects/function/bind/index.md @@ -56,11 +56,13 @@ Une erreur courante lorsqu'on débute en JavaScript est d'extraire une méthode ```js this.x = 9; // en dehors de tout contexte, - // pour un navigateur, this est - // l'objet window +// pour un navigateur, this est +// l'objet window var module = { x: 81, - getX: function() { return this.x; } + getX: function () { + return this.x; + }, }; module.getX(); // 81 @@ -91,8 +93,7 @@ var leadingThirtysevenList = list.bind(null, 37); var list2 = leadingThirtysevenList(); // [37] var list3 = leadingThirtysevenList(1, 2, 3); // [37, 1, 2, 3] - -function sommeArguments(arg1, arg2){ +function sommeArguments(arg1, arg2) { return arg1 + arg2; } @@ -107,17 +108,16 @@ Par défaut à l'intérieur de {{domxref("window.setTimeout()")}}, le mot-clé ` ```js function Fleur() { - this.nbPétales = Math.floor( Math.random() * 12 ) + 1; + this.nbPétales = Math.floor(Math.random() * 12) + 1; } // On déclare floraison après un délai d'une seconde -Fleur.prototype.floraison = function() { - window.setTimeout( this.declare.bind( this ), 1000 ); +Fleur.prototype.floraison = function () { + window.setTimeout(this.declare.bind(this), 1000); }; -Fleur.prototype.declare = function() { - console.log('Je suis une fleur avec ' + - this.nbPétales + ' pétales !'); +Fleur.prototype.declare = function () { + console.log("Je suis une fleur avec " + this.nbPétales + " pétales !"); }; var fleur = new Fleur(); @@ -137,19 +137,18 @@ function Point(x, y) { this.y = y; } -Point.prototype.toString = function() { +Point.prototype.toString = function () { return this.x + "," + this.y; }; var p = new Point(1, 2); p.toString(); // "1,2" - var emptyObj = {}; var YAxisPoint = Point.bind(emptyObj, 0 /* x */); // non supporté dans le polyfill ci dessous, // fonctionne avec le bind natif : -var YAxisPoint = Point.bind(null,0 /* x */); +var YAxisPoint = Point.bind(null, 0 /* x */); var axisPoint = new YAxisPoint(5); axisPoint.toString(); // "0,5" diff --git a/files/fr/web/javascript/reference/global_objects/function/call/index.md b/files/fr/web/javascript/reference/global_objects/function/call/index.md index bb988b759ef581..e6c7301c3e5a71 100644 --- a/files/fr/web/javascript/reference/global_objects/function/call/index.md +++ b/files/fr/web/javascript/reference/global_objects/function/call/index.md @@ -49,16 +49,16 @@ function Product(name, price) { function Food(name, price) { Product.call(this, name, price); - this.category = 'food'; + this.category = "food"; } function Toy(name, price) { Product.call(this, name, price); - this.category = 'toy'; + this.category = "toy"; } -var cheese = new Food('feta', 5); -var fun = new Toy('robot', 40); +var cheese = new Food("feta", 5); +var fun = new Toy("robot", 40); ``` ### Utiliser `call()` pour invoquer une fonction anonyme @@ -67,15 +67,15 @@ Dans cet exemple (purement inventé), on crée une fonction anonyme et on utilis ```js var animaux = [ - {espece: 'Lion', nom: 'Roi'}, - {espece: 'Éléphant', nom: 'Dumbo'} + { espece: "Lion", nom: "Roi" }, + { espece: "Éléphant", nom: "Dumbo" }, ]; for (var i = 0; i < animaux.length; i++) { (function (i) { this.print = function () { - console.log('#' + i + ' ' + this.espece + ' : ' + this.nom); - } + console.log("#" + i + " " + this.espece + " : " + this.nom); + }; this.print(); }).call(animaux[i], i); } @@ -93,7 +93,7 @@ function saluer() { var personne1 = { nom: "Sénèque", - role: "philosophe" + role: "philosophe", }; saluer.call(personne1); // Sénèque est un philosophe. @@ -104,10 +104,10 @@ saluer.call(personne1); // Sénèque est un philosophe. Dans l'exemple qui suit, on appelle la fonction `afficher()` sans lui passer d'argument. C'est donc l'objet global qui est utilisé comme contexte : ```js -var prenom = 'Archibald'; +var prenom = "Archibald"; function afficher() { - console.log('prenom vaut ' + this.prenom); + console.log("prenom vaut " + this.prenom); } afficher.call(); // prenom est Archibald @@ -116,12 +116,12 @@ afficher.call(); // prenom est Archibald > **Note :** La valeur de `this` sera {{jsxref("undefined")}} en mode strict. > > ```js -> 'use strict'; +> "use strict"; > -> var prenom = 'Archibald'; +> var prenom = "Archibald"; > > function afficher() { -> console.log('prenom vaut ' + this.prenom); +> console.log("prenom vaut " + this.prenom); > } > > afficher.call(); // Cannot read the property prenom' of undefined diff --git a/files/fr/web/javascript/reference/global_objects/function/caller/index.md b/files/fr/web/javascript/reference/global_objects/function/caller/index.md index 494d44807f32fd..86f4cbbc7edcce 100644 --- a/files/fr/web/javascript/reference/global_objects/function/caller/index.md +++ b/files/fr/web/javascript/reference/global_objects/function/caller/index.md @@ -21,8 +21,16 @@ La propriété spéciale `__caller__` qui renvoyait l'objet qui dans lequel éta Dans une fonction récursive, cette propriété ne peut pas être utilisée pour reconstituer la pile d'appels (_call stack_). Par exemple, si on a : ```js -function f(n) { g(n - 1); } -function g(n) { if (n > 0) { f(n); } else { stop(); } } +function f(n) { + g(n - 1); +} +function g(n) { + if (n > 0) { + f(n); + } else { + stop(); + } +} f(2); ``` @@ -35,16 +43,16 @@ f(2) -> g(1) -> f(1) -> g(0) -> stop() Et ceci est vrai : ```js -stop.caller === g && f.caller === g && g.caller === f +stop.caller === g && f.caller === g && g.caller === f; ``` Donc si on essaie d'obtenir la pile de cette façon : ```js var f = stop; -var stack = 'Stack trace:'; +var stack = "Stack trace:"; while (f) { - stack += '\n' + f.name; + stack += "\n" + f.name; f = f.caller; } ``` @@ -60,9 +68,9 @@ Dans l'exemple suivant, on verifie la propriété `caller` de la fonction. ```js function maFonction() { if (maFonction.caller == null) { - return 'Fonction appelée au plus haut niveau !'; + return "Fonction appelée au plus haut niveau !"; } else { - return 'Fonction appelée par ' + maFonction.caller; + return "Fonction appelée par " + maFonction.caller; } } ``` diff --git a/files/fr/web/javascript/reference/global_objects/function/displayname/index.md b/files/fr/web/javascript/reference/global_objects/function/displayname/index.md index b7a66a11b903c7..d036bcc1f6234c 100644 --- a/files/fr/web/javascript/reference/global_objects/function/displayname/index.md +++ b/files/fr/web/javascript/reference/global_objects/function/displayname/index.md @@ -13,13 +13,15 @@ La propriété **`function.displayName`** renvoie le nom affiché de la fonction Lorsque la propriété `displayName` est définie, elle renvoie le nom affiché de la fonction : ```js -function faireTruc() { } +function faireTruc() {} console.log(faireTruc.displayName); // "undefined" -var logMessage = function(contenu) { console.log(contenu) }; +var logMessage = function (contenu) { + console.log(contenu); +}; -logMessage.displayName = 'Afficher les messages dans le journal'; +logMessage.displayName = "Afficher les messages dans le journal"; console.log(logMessage.displayName); // "Afficher les messages dans le journal" ``` @@ -28,15 +30,19 @@ Il est possible de définir une fonction avec un nom d'affichage grâce à une { ```js var objet = { - uneMéthode: function () {} + uneMéthode: function () {}, }; -objet.uneMéthode.displayName = 'uneMéthode'; +objet.uneMéthode.displayName = "uneMéthode"; console.log(objet.uneMéthode.displayName); // "uneMéthode" -try { uneMéthode } catch(e) { console.log(e); } +try { + uneMéthode; +} catch (e) { + console.log(e); +} // ReferenceError: uneMéthode is not defined ``` @@ -45,14 +51,14 @@ La propriété `displayName` peut être changée dynamiquement : ```js var objet = { // anonyme - uneMéthode: function(valeur) { + uneMéthode: function (valeur) { this.displayName = "uneMéthode (" + valeur + ")"; - } + }, }; console.log(objet.uneMéthode.displayName); // "undefined" -objet.uneMéthode("123") +objet.uneMéthode("123"); console.log(objet.uneMéthode.displayName); // "uneMéthode (123)" ``` @@ -63,8 +69,8 @@ On souhaite généralement utiliser cette propriété dans les consoles et profi Le code suivant devrait afficher quelque chose comme "function Ma Fonction()": ```js -var a = function () { }; -a.displayName = 'Ma Fonction'; +var a = function () {}; +a.displayName = "Ma Fonction"; a; ``` diff --git a/files/fr/web/javascript/reference/global_objects/function/function/index.md b/files/fr/web/javascript/reference/global_objects/function/function/index.md index 8a040c89b2ab39..143015062ecf62 100644 --- a/files/fr/web/javascript/reference/global_objects/function/function/index.md +++ b/files/fr/web/javascript/reference/global_objects/function/function/index.md @@ -45,7 +45,7 @@ Le code qui suit crée un objet `Function` qui prend deux arguments. ```js // Crée une fonction qui prend deux arguments et qui en renvoie la somme -const additionneur = new Function('a', 'b', 'return a + b'); +const additionneur = new Function("a", "b", "return a + b"); // Appeler la fonction additionneur(2, 6); @@ -62,7 +62,9 @@ Les arguments `"a"` et `"b"` sont les noms formels des arguments utilisés dans // On peut voir ici que le résultat de new Function est appelé. // Ainsi, on peut invoquer juste après la fonction qui vient d'être créée. -const sommeTableau = new Function('const sommeTableau = (arr) => arr.reduce((precedente, courante) => precedente + courante); return sommeTableau')(); +const sommeTableau = new Function( + "const sommeTableau = (arr) => arr.reduce((precedente, courante) => precedente + courante); return sommeTableau", +)(); // On appelle la fonction sommeTableau([1, 2, 3, 4]); @@ -70,17 +72,21 @@ sommeTableau([1, 2, 3, 4]); // Si on n'appelle pas new Function au moment de la création, // on peut toujours utiliser la méthode Function.call() ensuite -const plusGrandNombre = new Function('function plusGrandNombre (arr) { return Math.max(...arr) }; return plusGrandNombre'); +const plusGrandNombre = new Function( + "function plusGrandNombre (arr) { return Math.max(...arr) }; return plusGrandNombre", +); // On appelle la fonction plusGrandNombre.call({}).call({}, [2, 4, 1, 8, 5]); // 8 // Une déclaration de fonction ne nécessite pas d'instruction return -const direCoucou = new Function('return function (nom) { return `Coucou, ${nom}` }')(); +const direCoucou = new Function( + "return function (nom) { return `Coucou, ${nom}` }", +)(); // On appelle la fonction -direCoucou('monde'); +direCoucou("monde"); // Coucou, monde ``` diff --git a/files/fr/web/javascript/reference/global_objects/function/index.md b/files/fr/web/javascript/reference/global_objects/function/index.md index 6d4836719aba8d..e618792e854632 100644 --- a/files/fr/web/javascript/reference/global_objects/function/index.md +++ b/files/fr/web/javascript/reference/global_objects/function/index.md @@ -47,24 +47,24 @@ Les fonctions créées avec le constructeur `Function()` ne créent pas de ferme var x = 10; function creerFonction1() { - var x = 20; - return new Function('return x;'); - // ce x fait référence à la variable globale x + var x = 20; + return new Function("return x;"); + // ce x fait référence à la variable globale x } function creerFonction2() { - var x = 20; - function f() { - return x; - // ce x fait référence à la variable locale x juste avant - } - return f; + var x = 20; + function f() { + return x; + // ce x fait référence à la variable locale x juste avant + } + return f; } var f1 = creerFonction1(); -console.log(f1()); // 10 +console.log(f1()); // 10 var f2 = creerFonction2(); -console.log(f2()); // 20 +console.log(f2()); // 20 ``` Bien que ce code fonctionne dans les navigateurs web, `f1()` déclenchera une erreur `ReferenceError` avec Node.js, car `x` ne sera pas trouvé. En effet, la portée de plus haut niveau de Node n'est pas la portée globale et `x` sera local au module. diff --git a/files/fr/web/javascript/reference/global_objects/function/length/index.md b/files/fr/web/javascript/reference/global_objects/function/length/index.md index 52f95383229b23..8db3d61efb90c3 100644 --- a/files/fr/web/javascript/reference/global_objects/function/length/index.md +++ b/files/fr/web/javascript/reference/global_objects/function/length/index.md @@ -27,12 +27,12 @@ La propriété `length` du prototype de {{jsxref("Function")}} vaut 0. ```js console.log(Function.length); /* 1 */ -console.log((function() {}).length); /* 0 */ -console.log((function(a) {}).length); /* 1 */ -console.log((function(a, b) {}).length); /* 2 etc. */ -console.log((function(...args) {}).length); +console.log(function () {}.length); /* 0 */ +console.log(function (a) {}.length); /* 1 */ +console.log(function (a, b) {}.length); /* 2 etc. */ +console.log(function (...args) {}.length); // 0, le paramètre du reste n'est pas compté -console.log((function(a, b = 1, c) {}).length); +console.log(function (a, b = 1, c) {}.length); // 1, seuls les paramètres avant les valeurs par // défaut sont comptés ``` diff --git a/files/fr/web/javascript/reference/global_objects/function/name/index.md b/files/fr/web/javascript/reference/global_objects/function/name/index.md index 1a0fe3e4517bd2..56169c735235df 100644 --- a/files/fr/web/javascript/reference/global_objects/function/name/index.md +++ b/files/fr/web/javascript/reference/global_objects/function/name/index.md @@ -28,7 +28,7 @@ faireUnTruc.name; // "faireUnTruc" Lorsqu'on crée une fonction avec `new Function(...)` ou simplement `Function(...)`, on crée uniquement des objets dont le nom est "anonymous". ```js -(new Function).name; // "anonymous" +new Function().name; // "anonymous" ``` ### Inférence des noms de fonction @@ -36,9 +36,9 @@ Lorsqu'on crée une fonction avec `new Function(...)` ou simplement `Function(.. Les variables et les méthodes permettent d'inférer (c'est-à-dire de « deviner ») le nom des fonctions anonymes en fonction de leur position syntaxique (cette fonctionnalité est apparue avec ECMAScript 2015). ```js -var f = function() {}; +var f = function () {}; var objet = { - uneMéthode: function() {} + uneMéthode: function () {}, }; console.log(f.name); // "f" @@ -49,11 +49,15 @@ On peut définir une fonction avec un nom grâce à une {{jsxref("Opérateurs/L_ ```js var objet = { - uneMéthode: function objet_maMéthode() {} + uneMéthode: function objet_maMéthode() {}, }; console.log(objet.uneMéthode.name); // logs "objet_maMéthode" -try { objet_maMéthode } catch(e) { console.log(e); } +try { + objet_maMéthode; +} catch (e) { + console.log(e); +} // ReferenceError: objet_maMéthode is not defined ``` @@ -62,10 +66,10 @@ On ne peut pas changer le nom d'une fonction, cette propriété est uniquement e ```js var objet = { // anonyme - uneMéthode: function() {} + uneMéthode: function () {}, }; -objet.uneMéthode.name = 'uneMéthode'; +objet.uneMéthode.name = "uneMéthode"; console.log(object.uneMéthode.name); // une chaîne vide, uneMéthode est anonyme ``` @@ -75,7 +79,7 @@ Pour modifier le nom, on pourrait cependant utiliser la méthode {{jsxref("Objec ```js var o = { - toto(){} + toto() {}, }; o.toto.name; // "toto"; ``` @@ -85,7 +89,7 @@ o.toto.name; // "toto"; {{jsxref("Function.bind()")}} produit une fonction dont le nom sera la chaîne "bound " suivi du nom de la fonction. ```js -function toto() {}; +function toto() {} toto.bind({}).name; // "bound toto" ``` @@ -95,8 +99,8 @@ Lorsqu'on utilise les propriétés d'accesseur [`get`](/fr/docs/Web/JavaScript/R ```js var o = { - get toto(){}, - set toto(x){} + get toto() {}, + set toto(x) {}, }; var descripteur = Object.getOwnPropertyDescriptor(o, "toto"); @@ -109,7 +113,7 @@ descripteur.set.name; // "set toto"; On peut utiliser la notation `obj.constructor.name` pour vérifier la « classe » d'un objet (attention aux avertissements ci-après) : ```js -function Toto() {} // Syntaxe ES2015 : class Toto {} +function Toto() {} // Syntaxe ES2015 : class Toto {} var instanceDeToto = new Toto(); console.log(instanceDeToto.constructor.name); // affiche "Toto" dans la console @@ -128,8 +132,8 @@ Avec `static name()`, `Toto.name` ne contient plus le nom de la classe mais une ```js function Toto() {} -Object.defineProperty(Toto, 'name', { writable: true }); -Toto.name = function() {}; +Object.defineProperty(Toto, "name", { writable: true }); +Toto.name = function () {}; ``` Il est donc parfois erroné de penser que `Function.name` pointe toujours vers le nom de la classe. @@ -142,8 +146,8 @@ Si un symbole ({{jsxref("Symbol")}}) est utilisé comme nom d'une fonction et qu var sym1 = Symbol("Toto"); var sym2 = Symbol(); var o = { - [sym1]: function(){}, - [sym2]: function(){} + [sym1]: function () {}, + [sym2]: function () {}, }; o[sym1].name; // "[Toto]" @@ -155,25 +159,25 @@ o[sym2].name; // "" Attention à l'utilisation de `Function.name` lorsque le code source est transformé par certains outils. En effet, ceux-ci réduisent généralement la taille d'un programme en compressant les espaces et en modifiant parfois les noms de variables. Ainsi, un fragment de code comme : ```js -function Toto() {}; +function Toto() {} var toto = new Toto(); -if (Toto.constructor.name === 'Toto') { +if (Toto.constructor.name === "Toto") { console.log("'toto' est une instance de 'Toto'"); } else { - console.log('Oups !'); + console.log("Oups !"); } ``` pourrait être compressé en : ```js -function a() {}; +function a() {} var b = new a(); -if (b.constructor.name === 'Toto') { +if (b.constructor.name === "Toto") { console.log("'toto' est une instance de 'Toto'"); } else { - console.log('Oups !'); + console.log("Oups !"); } ``` diff --git a/files/fr/web/javascript/reference/global_objects/generator/index.md b/files/fr/web/javascript/reference/global_objects/generator/index.md index c174d850c21e23..e43d1b850c2067 100644 --- a/files/fr/web/javascript/reference/global_objects/generator/index.md +++ b/files/fr/web/javascript/reference/global_objects/generator/index.md @@ -34,10 +34,9 @@ var g = gen(); // "Generator { }" ### Un itérateur infini ```js -function* idMaker(){ - var index = 0; - while(true) - yield index++; +function* idMaker() { + var index = 0; + while (true) yield index++; } var gen = idMaker(); // "Generator { }" @@ -72,11 +71,11 @@ function* fibonacci() { } var it = fibonacci(); -console.log(it); // "Generator { }" -console.log(it.next()); // 1 +console.log(it); // "Generator { }" +console.log(it.next()); // 1 console.log(it.send(10)); // 20 -console.log(it.close()); // undefined -console.log(it.next()); // throws StopIteration (le générateur est clôturé) +console.log(it.close()); // undefined +console.log(it.next()); // throws StopIteration (le générateur est clôturé) ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/generator/next/index.md b/files/fr/web/javascript/reference/global_objects/generator/next/index.md index 8bedab4230cf48..fdbe20d90362c4 100644 --- a/files/fr/web/javascript/reference/global_objects/generator/next/index.md +++ b/files/fr/web/javascript/reference/global_objects/generator/next/index.md @@ -11,7 +11,7 @@ La méthode **`next()`** renvoie un objet possédant deux propriétés `done` et ## Syntaxe ```js -gen.next(valeur) +gen.next(valeur); ``` ### Paramètres @@ -44,10 +44,10 @@ function* gen() { } var g = gen(); // "Generator { }" -g.next(); // "Object { value: 1, done: false }" -g.next(); // "Object { value: 2, done: false }" -g.next(); // "Object { value: 3, done: false }" -g.next(); // "Object { value: undefined, done: true }" +g.next(); // "Object { value: 1, done: false }" +g.next(); // "Object { value: 2, done: false }" +g.next(); // "Object { value: 3, done: false }" +g.next(); // "Object { value: undefined, done: true }" ``` ### Envoyer des valeurs à un générateur @@ -56,7 +56,7 @@ Ici, `next` est appelé avec une valeur. On notera ici que le premier appel n'af ```js function* gen() { - while(true) { + while (true) { var value = yield null; console.log(value); } diff --git a/files/fr/web/javascript/reference/global_objects/generator/return/index.md b/files/fr/web/javascript/reference/global_objects/generator/return/index.md index 49442a03ab5d39..6483b5e1a3e44b 100644 --- a/files/fr/web/javascript/reference/global_objects/generator/return/index.md +++ b/files/fr/web/javascript/reference/global_objects/generator/return/index.md @@ -11,7 +11,7 @@ La méthode **`return()`** renvoie la valeur fournie et termine le générateur. ## Syntaxe ```js -gen.return(valeur) +gen.return(valeur); ``` ### Paramètres @@ -38,9 +38,9 @@ function* gen() { var g = gen(); -g.next(); // { value: 1, done: false } +g.next(); // { value: 1, done: false } g.return("toto"); // { value: "toto", done: true } -g.next(); // { value: undefined, done: true } +g.next(); // { value: undefined, done: true } ``` > **Note :** Si `done` vaut `true`, `return(valeur)` renverra la même chose que `next()` : `undefined`. Si aucun argument n'est fourni, la propriété `value` de l'objet renvoyé sera la même qu'avec un appel à `.next()`. Si un argument est fourni, c'est lui qui sera utilisé comme valeur pour l'attribut `value` du résultat. diff --git a/files/fr/web/javascript/reference/global_objects/generator/throw/index.md b/files/fr/web/javascript/reference/global_objects/generator/throw/index.md index 7a00812d79af42..1d6f2385e57f01 100644 --- a/files/fr/web/javascript/reference/global_objects/generator/throw/index.md +++ b/files/fr/web/javascript/reference/global_objects/generator/throw/index.md @@ -11,7 +11,7 @@ La méthode **`throw()`** lève une erreur dans un générateur. ## Syntaxe ```js -gen.throw(exception) +gen.throw(exception); ``` ### Paramètres @@ -38,10 +38,10 @@ Dans l'exemple suivant, on utilise un générateur simple et on génère une exc ```js function* gen() { - while(true) { + while (true) { try { - yield 42; - } catch(e) { + yield 42; + } catch (e) { console.log("Erreur interceptée !"); } } diff --git a/files/fr/web/javascript/reference/global_objects/generatorfunction/index.md b/files/fr/web/javascript/reference/global_objects/generatorfunction/index.md index 31f62324f3ccd9..09cfe7f6923073 100644 --- a/files/fr/web/javascript/reference/global_objects/generatorfunction/index.md +++ b/files/fr/web/javascript/reference/global_objects/generatorfunction/index.md @@ -9,7 +9,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/GeneratorFunction En JavaScript, chaque fonction génératrice est en réalité un objet `GeneratorFunction`. Il n'existe pas d'objet global avec le nom `GeneratorFunction`, mais il est possible de créer un constructeur `GeneratorFunction()` avec le code suivant : ```js -const GeneratorFunction = Object.getPrototypeOf(function*(){}).constructor; +const GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; ``` ## Description @@ -31,8 +31,8 @@ Invoquer un constructeur de fonction génératrice comme une fonction (sans util ### Créer un générateur en utilisant le constructeur `GeneratorFunction()` ```js -const GeneratorFunction = Object.getPrototypeOf(function*(){}).constructor; -const g = new GeneratorFunction('a', 'yield a * 2'); +const GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; +const g = new GeneratorFunction("a", "yield a * 2"); const iterator = g(10); console.log(iterator.next().value); // 20 ``` diff --git a/files/fr/web/javascript/reference/global_objects/globalthis/index.md b/files/fr/web/javascript/reference/global_objects/globalthis/index.md index bdeb09a1d9338a..3317d4d1b9a2d9 100644 --- a/files/fr/web/javascript/reference/global_objects/globalthis/index.md +++ b/files/fr/web/javascript/reference/global_objects/globalthis/index.md @@ -13,7 +13,7 @@ La propriété globale **`globalThis`** renvoie l'objet global de plus haut nive ## Syntaxe ```js -globalThis +globalThis; ``` ## Description @@ -39,15 +39,21 @@ Avant l'introduction de `globalThis`, la seule façon qui permettait d'obtenir l ```js var getGlobal = function () { - if (typeof self !== 'undefined') { return self; } - if (typeof window !== 'undefined') { return window; } - if (typeof global !== 'undefined') { return global; } + if (typeof self !== "undefined") { + return self; + } + if (typeof window !== "undefined") { + return window; + } + if (typeof global !== "undefined") { + return global; + } throw new Error("impossible de trouver l'objet global"); }; var globals = getGlobal(); -if (typeof globals.setTimeout !== 'function') { +if (typeof globals.setTimeout !== "function") { // pas de setTimeout pour cet environnement } ``` @@ -55,7 +61,7 @@ if (typeof globals.setTimeout !== 'function') { Avec `globalThis`, il n'est plus nécessaire de parcourir les différents mots-clés des différents environnements : ```js -if (typeof globalThis.setTimeout !== 'function') { +if (typeof globalThis.setTimeout !== "function") { // pas de setTimeout pour cet environnement } ``` diff --git a/files/fr/web/javascript/reference/global_objects/infinity/index.md b/files/fr/web/javascript/reference/global_objects/infinity/index.md index 23d0b8d49cb2fa..d358e12a99206d 100644 --- a/files/fr/web/javascript/reference/global_objects/infinity/index.md +++ b/files/fr/web/javascript/reference/global_objects/infinity/index.md @@ -15,7 +15,7 @@ La propriété globale **`Infinity`** est une valeur numérique représentant l' ## Syntaxe ```js -Infinity +Infinity; ``` ## Description @@ -29,11 +29,11 @@ D'après la spécification ECMAScript 5, `Infinity` est en lecture seule. ## Exemples ```js -console.log(Infinity); // Infinity -console.log(Infinity + 1); // Infinity +console.log(Infinity); // Infinity +console.log(Infinity + 1); // Infinity console.log(Math.pow(10, 1000)); // Infinity -console.log(Math.log(0)); // -Infinity -console.log(1 / Infinity); // 0 +console.log(Math.log(0)); // -Infinity +console.log(1 / Infinity); // 0 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/int16array/index.md b/files/fr/web/javascript/reference/global_objects/int16array/index.md index 1e6aa0467a457d..c8e13df479ebbe 100644 --- a/files/fr/web/javascript/reference/global_objects/int16array/index.md +++ b/files/fr/web/javascript/reference/global_objects/int16array/index.md @@ -125,7 +125,7 @@ console.log(int16.length); // 2 console.log(int16.BYTES_PER_ELEMENT); // 2 // Construction à partir d'un tableau -var arr = new Int16Array([21,31]); +var arr = new Int16Array([21, 31]); console.log(arr[1]); // 31 // Construction à partir d'un autre TypedArray @@ -138,7 +138,9 @@ var buffer = new ArrayBuffer(8); var z = new Int16Array(buffer, 0, 4); // Construction à partir d'un itérable -var iterable = function*(){ yield* [1,2,3]; }(); +var iterable = (function* () { + yield* [1, 2, 3]; +})(); var int16 = new Int16Array(iterable); // Int16Array[1, 2, 3] ``` diff --git a/files/fr/web/javascript/reference/global_objects/int16array/int16array/index.md b/files/fr/web/javascript/reference/global_objects/int16array/int16array/index.md index 8e9b30e4896cd7..74cf045b925fb9 100644 --- a/files/fr/web/javascript/reference/global_objects/int16array/int16array/index.md +++ b/files/fr/web/javascript/reference/global_objects/int16array/int16array/index.md @@ -45,7 +45,7 @@ console.log(int16.length); // 2 console.log(int16.BYTES_PER_ELEMENT); // 2 // À partir d'un tableau -const arr = new Int16Array([21,31]); +const arr = new Int16Array([21, 31]); console.log(arr[1]); // 31 // À partir d'un autre tableau typé @@ -58,7 +58,9 @@ const buffer = new ArrayBuffer(8); const z = new Int16Array(buffer, 0, 4); // À partir d'un itérable -const iterable = function*(){ yield* [1,2,3]; }(); +const iterable = (function* () { + yield* [1, 2, 3]; +})(); const int16 = new Int16Array(iterable); // Int16Array[1, 2, 3] ``` diff --git a/files/fr/web/javascript/reference/global_objects/int32array/index.md b/files/fr/web/javascript/reference/global_objects/int32array/index.md index 6c27c2077d314e..5c1b72807beac2 100644 --- a/files/fr/web/javascript/reference/global_objects/int32array/index.md +++ b/files/fr/web/javascript/reference/global_objects/int32array/index.md @@ -125,7 +125,7 @@ console.log(int32.length); // 2 console.log(int32.BYTES_PER_ELEMENT); // 4 // Construction à partir d'un tableau -var arr = new Int32Array([21,31]); +var arr = new Int32Array([21, 31]); console.log(arr[1]); // 31 // Construction à partir d'un autre TypedArray @@ -138,7 +138,9 @@ var buffer = new ArrayBuffer(16); var z = new Int32Array(buffer, 0, 4); // Construction à partir d'un itérable -var iterable = function*(){ yield* [1,2,3]; }(); +var iterable = (function* () { + yield* [1, 2, 3]; +})(); var int32 = new Int32Array(iterable); // Int32Array[1, 2, 3] ``` diff --git a/files/fr/web/javascript/reference/global_objects/int32array/int32array/index.md b/files/fr/web/javascript/reference/global_objects/int32array/int32array/index.md index d44851d174d905..b9e1c2983532b0 100644 --- a/files/fr/web/javascript/reference/global_objects/int32array/int32array/index.md +++ b/files/fr/web/javascript/reference/global_objects/int32array/int32array/index.md @@ -1,7 +1,7 @@ --- title: Constructeur Int32Array() slug: Web/JavaScript/Reference/Global_Objects/Int32Array/Int32Array -translation_of: Web/JavaScript/Reference/Global_Objects/Int32Array/Int32Array +translation_of: Web/JavaScript/Reference/Global_Objects/Int32Array/Int32Array --- {{JSRef}} @@ -44,7 +44,7 @@ console.log(int32.length); // 2 console.log(int32.BYTES_PER_ELEMENT); // 4 // À partir d'un tableau -const arr = new Int32Array([21,31]); +const arr = new Int32Array([21, 31]); console.log(arr[1]); // 31 // À partir d'un autre tableau typé @@ -57,7 +57,9 @@ const buffer = new ArrayBuffer(16); const z = new Int32Array(buffer, 0, 4); // À partir d'un itérable -const iterable = function*(){ yield* [1,2,3]; }(); +const iterable = (function* () { + yield* [1, 2, 3]; +})(); const int32_from_iterable = new Int32Array(iterable); // Int32Array[1, 2, 3] ``` diff --git a/files/fr/web/javascript/reference/global_objects/int8array/index.md b/files/fr/web/javascript/reference/global_objects/int8array/index.md index d2cc44dffa6afe..11b1b30b9d2481 100644 --- a/files/fr/web/javascript/reference/global_objects/int8array/index.md +++ b/files/fr/web/javascript/reference/global_objects/int8array/index.md @@ -125,7 +125,7 @@ console.log(int8.length); // 2 console.log(int8.BYTES_PER_ELEMENT); // 1 // Construction à partir d'un tableau -var arr = new Int8Array([21,31]); +var arr = new Int8Array([21, 31]); console.log(arr[1]); // 31 // Construction à partir d'un autre TypedArray @@ -138,7 +138,9 @@ var buffer = new ArrayBuffer(8); var z = new Int8Array(buffer, 1, 4); // Construction à partir d'un itérable -var iterable = function*(){ yield* [1,2,3]; }(); +var iterable = (function* () { + yield* [1, 2, 3]; +})(); var int8 = new Int8Array(iterable); // Int8Array[1, 2, 3] ``` diff --git a/files/fr/web/javascript/reference/global_objects/int8array/int8array/index.md b/files/fr/web/javascript/reference/global_objects/int8array/int8array/index.md index 0107330f1e502a..2080576e2b39fb 100644 --- a/files/fr/web/javascript/reference/global_objects/int8array/int8array/index.md +++ b/files/fr/web/javascript/reference/global_objects/int8array/int8array/index.md @@ -45,7 +45,7 @@ console.log(int8.length); // 2 console.log(int8.BYTES_PER_ELEMENT); // 1 // À partir d'un tableau -const arr = new Int8Array([21,31]); +const arr = new Int8Array([21, 31]); console.log(arr[1]); // 31 // À partir d'un autre tableau typé @@ -58,7 +58,9 @@ const buffer = new ArrayBuffer(8); const z = new Int8Array(buffer, 1, 4); // À partir d'un itérable -const iterable = function*(){ yield* [1,2,3]; }(); +const iterable = (function* () { + yield* [1, 2, 3]; +})(); const int8 = new Int8Array(iterable); // Int8Array[1, 2, 3] ``` diff --git a/files/fr/web/javascript/reference/global_objects/internalerror/index.md b/files/fr/web/javascript/reference/global_objects/internalerror/index.md index f58f5387fd8013..e188f3e0dcaebb 100644 --- a/files/fr/web/javascript/reference/global_objects/internalerror/index.md +++ b/files/fr/web/javascript/reference/global_objects/internalerror/index.md @@ -45,7 +45,7 @@ function boucle(x) { if (x >= 10) { // "x >= 10" représente la condition d'arrêt return; - } + } // faire des trucs boucle(x + 1); // l'appel récursif } diff --git a/files/fr/web/javascript/reference/global_objects/internalerror/internalerror/index.md b/files/fr/web/javascript/reference/global_objects/internalerror/internalerror/index.md index 72bd555f9d9e87..40b67e3ee630ec 100644 --- a/files/fr/web/javascript/reference/global_objects/internalerror/internalerror/index.md +++ b/files/fr/web/javascript/reference/global_objects/internalerror/internalerror/index.md @@ -11,10 +11,10 @@ Le constructeur **`InternalError()`** permet de créer une erreur qui s'est prod ## Syntaxe ```js -new InternalError() -new InternalError(message) -new InternalError(message, nomFichier) -new InternalError(message, nomFichier, numeroLigne) +new InternalError(); +new InternalError(message); +new InternalError(message, nomFichier); +new InternalError(message, nomFichier, numeroLigne); ``` ### Paramètres @@ -31,7 +31,7 @@ new InternalError(message, nomFichier, numeroLigne) ### Créer une nouvelle exception `InternalError` ```js -new InternalError('Échec du moteur'); +new InternalError("Échec du moteur"); ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/intl/collator/collator/index.md b/files/fr/web/javascript/reference/global_objects/intl/collator/collator/index.md index f80919ecb3fef2..c52692d8f53d30 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/collator/collator/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/collator/collator/index.md @@ -12,9 +12,9 @@ Le constructeur **`Intl.Collator()`** crée un objet [`Intl.Collator`](/fr/docs/ ## Syntaxe ```js -new Intl.Collator() -new Intl.Collator(locales) -new Intl.Collator(locales, options) +new Intl.Collator(); +new Intl.Collator(locales); +new Intl.Collator(locales, options); ``` ### Paramètres @@ -45,7 +45,7 @@ new Intl.Collator(locales, options) - `trad` - `unihan` - `zhuyin` - > **Note :** Cette option peut également être définie via la propriété "`collation`" du paramètre `options`. + > **Note :** Cette option peut également être définie via la propriété "`collation`" du paramètre `options`. - `kn` - : Indique si une collation numérique devrait être utilisée (par exemple pour avoir "1" < "2" < "10"). Les valeurs possibles sont "`true`" et "`false`". Cette option peut également être indiquée via la propriété "`numeric`" du paramètre `options`. - `kf` @@ -61,6 +61,7 @@ new Intl.Collator(locales, options) - : Indique si la comparaison est utilisée pour trier ou pour rechercher des correspondances. Les valeurs possibles sont "`sort`" et "`search`", la valeur par défaut est "`sort`". - `sensitivity` + - : Indique les différences dans les chaînes de caractères qui entraînent un résultat non nul. Les valeurs possibles sont : - "`base`" : Seules les chaînes de caractères pour lesquelles les lettres de base sont différentes sont considérées comme différentes. Avec cette option, on a : a ≠ b, a = á, a = A. @@ -102,7 +103,7 @@ new Intl.Collator(locales, options) - `trad` - `unihan` - `zhuyin` - > **Note :** Cette option peut également être définie via la clé d'extension Unicode `co` ; si des valeurs sont fournies aux deux endroits, c'est la propriété d'`options` qui a la priorité. + > **Note :** Cette option peut également être définie via la clé d'extension Unicode `co` ; si des valeurs sont fournies aux deux endroits, c'est la propriété d'`options` qui a la priorité. ## Exemples @@ -111,9 +112,9 @@ new Intl.Collator(locales, options) Dans l'exemple suivant, on illustre la comparaison de deux chaînes de caractères et le résultat obtenu selon que l'une est située avant ou après, ou de façon équivalente selon l'ordre lexicographique de la langue : ```js -console.log(new Intl.Collator().compare('a', 'c')); // → une valeur négative -console.log(new Intl.Collator().compare('c', 'a')); // → une valeur positive -console.log(new Intl.Collator().compare('a', 'a')); // → 0 +console.log(new Intl.Collator().compare("a", "c")); // → une valeur négative +console.log(new Intl.Collator().compare("c", "a")); // → une valeur positive +console.log(new Intl.Collator().compare("a", "a")); // → 0 ``` On notera que les résultats obtenus avec les lignes précédentes peuvent varier d'un navigateur à l'autre et entre les différentes versions. En effet, les valeurs numériques obtenues sont spécifiques aux implémentations et la spécification n'impose que le signe de la valeur obtenue. diff --git a/files/fr/web/javascript/reference/global_objects/intl/collator/compare/index.md b/files/fr/web/javascript/reference/global_objects/intl/collator/compare/index.md index 860adb1fa42f4f..def8b3fb53bd93 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/collator/compare/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/collator/compare/index.md @@ -13,7 +13,7 @@ La méthode **`Intl.Collator.prototype.compare()`** compare deux chaînes de car ## Syntaxe ```js -collator.compare(chaine1, chaine2) +collator.compare(chaine1, chaine2); ``` ### Paramètres @@ -45,10 +45,13 @@ Ici, on utilise la fonction de l'accesseur `compare` pour trouver les chaînes ```js var a = ["Congrès", "congres", "Assemblée", "poisson"]; -var collator = new Intl.Collator("fr", {usage: "search", sensitivity: "base"}); +var collator = new Intl.Collator("fr", { + usage: "search", + sensitivity: "base", +}); var s = "congres"; var matches = a.filter(function (v) { - return collator.compare(v, s) === 0; + return collator.compare(v, s) === 0; }); console.log(matches.join(", ")); // → "Congrès, congres" diff --git a/files/fr/web/javascript/reference/global_objects/intl/collator/index.md b/files/fr/web/javascript/reference/global_objects/intl/collator/index.md index 5a3cd1e8513f87..070cbe8cb498fb 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/collator/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/collator/index.md @@ -34,9 +34,9 @@ L'objet **`Intl.Collator`** permet de comparer des chaînes de caractères en te L'exemple qui suit illustre les différents résultats qu'on peut obtenir en comparant deux chaînes de caractères : ```js -console.log(new Intl.Collator().compare('a', 'c')); // → une valeur négative -console.log(new Intl.Collator().compare('c', 'a')); // → une valeur positive -console.log(new Intl.Collator().compare('a', 'a')); // → 0 +console.log(new Intl.Collator().compare("a", "c")); // → une valeur négative +console.log(new Intl.Collator().compare("c", "a")); // → une valeur positive +console.log(new Intl.Collator().compare("a", "a")); // → 0 ``` Les résultats indiqués ici sont génériques et, en pratique, peuvent varier entre les navigateurs et les versions des navigateurs. En effet les valeurs obtenues dépendent de l'implémentation. Les spécifications indiquent uniquement le signe (positif ou négatif) du résultat. @@ -47,11 +47,11 @@ Les résultats fournis par [`Collator.prototype.compare()`](/fr/docs/Web/JavaScr ```js // en allemand, 'ä' est équivalent à 'a' pour le tri -console.log(new Intl.Collator('de').compare('ä', 'z')); +console.log(new Intl.Collator("de").compare("ä", "z")); // → une valeur négative // en suédois, 'ä' arrive après 'z' -console.log(new Intl.Collator('sv').compare('ä', 'z')); +console.log(new Intl.Collator("sv").compare("ä", "z")); // → une valeur positive ``` @@ -61,11 +61,11 @@ Les résultats fournis par [`Collator.prototype.compare()`](/fr/docs/Web/JavaScr ```js // en allemand, 'ä' est composé de la lettre de base 'a' -console.log(new Intl.Collator('de', {sensitivity: 'base'}).compare('ä', 'a')); +console.log(new Intl.Collator("de", { sensitivity: "base" }).compare("ä", "a")); // → 0 // en suédois, 'ä' et 'a' sont distincts en termes de base -console.log(new Intl.Collator('sv', {sensitivity: 'base'}).compare('ä', 'a')); +console.log(new Intl.Collator("sv", { sensitivity: "base" }).compare("ä", "a")); // → une valeur positive ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/collator/resolvedoptions/index.md b/files/fr/web/javascript/reference/global_objects/intl/collator/resolvedoptions/index.md index 087a437f115a94..0df870c70c55b8 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/collator/resolvedoptions/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/collator/resolvedoptions/index.md @@ -13,7 +13,7 @@ La méthode **`Intl.Collator.prototype.resolvedOptions()`** renvoie un nouvel ob ## Syntaxe ```js -collator.resolvedOptions() +collator.resolvedOptions(); ``` ### Valeur de retour @@ -36,15 +36,15 @@ L'objet renvoyé par cette méthode contient les propriétés suivantes : ## Exemples ```js -var de = new Intl.Collator('de', { sensitivity: 'base' }) +var de = new Intl.Collator("de", { sensitivity: "base" }); var usedOptions = de.resolvedOptions(); -usedOptions.locale; // "de" -usedOptions.usage; // "sort" -usedOptions.sensitivity; // "base" +usedOptions.locale; // "de" +usedOptions.usage; // "sort" +usedOptions.sensitivity; // "base" usedOptions.ignorePunctuation; // false -usedOptions.collation; // "default" -usedOptions.numeric; // false +usedOptions.collation; // "default" +usedOptions.numeric; // false ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/intl/collator/supportedlocalesof/index.md b/files/fr/web/javascript/reference/global_objects/intl/collator/supportedlocalesof/index.md index 968c5d2f500ce9..630e7d55e457f9 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/collator/supportedlocalesof/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/collator/supportedlocalesof/index.md @@ -41,7 +41,7 @@ Si on dispose d'un environnement (un navigateur par exemple) qui supporte la com ```js var locales = ["ban", "id-u-co-pinyin", "de-ID"]; -var options = {localeMatcher: "lookup"}; +var options = { localeMatcher: "lookup" }; console.log(Intl.Collator.supportedLocalesOf(locales, options).join(", ")); // → "id-u-co-pinyin, de-ID" ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/datetimeformat/index.md b/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/datetimeformat/index.md index 0d4fff6d6aa327..1b347c71a82fd6 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/datetimeformat/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/datetimeformat/index.md @@ -12,9 +12,9 @@ Le constructeur **`Intl.DateTimeFormat()`** permet de créer des objets [`Intl.D ## Syntaxe ```js -new Intl.DateTimeFormat() -new Intl.DateTimeFormat(locales) -new Intl.DateTimeFormat(locales, options) +new Intl.DateTimeFormat(); +new Intl.DateTimeFormat(locales); +new Intl.DateTimeFormat(locales, options); ``` ### Paramètres @@ -179,19 +179,19 @@ console.log(new Intl.DateTimeFormat().format(date)); ### Utiliser timeStyle et dateStyle ```js -let o = new Intl.DateTimeFormat("fr" , { - timeStyle: "short" +let o = new Intl.DateTimeFormat("fr", { + timeStyle: "short", }); console.log(o.format(Date.now())); // "09:45" -let o2 = new Intl.DateTimeFormat("fr" , { - dateStyle: "short" +let o2 = new Intl.DateTimeFormat("fr", { + dateStyle: "short", }); console.log(o2.format(Date.now())); // "29/12/2021" -let o3 = new Intl.DateTimeFormat("fr" , { +let o3 = new Intl.DateTimeFormat("fr", { timeStyle: "medium", - dateStyle: "short" + dateStyle: "short", }); console.log(o3.format(Date.now())); // "29/12/2021 09:46:55" ``` @@ -203,16 +203,34 @@ On utilise l'option `dayPeriod` pour produire une chaîne de caractères qui ind ```js let date = Date.UTC(2012, 11, 17, 4, 0, 42); -console.log(new Intl.DateTimeFormat('en-GB', { hour: 'numeric', hourCycle: 'h12', -dayPeriod: 'short', timeZone: 'UTC' }).format(date)); +console.log( + new Intl.DateTimeFormat("en-GB", { + hour: "numeric", + hourCycle: "h12", + dayPeriod: "short", + timeZone: "UTC", + }).format(date), +); // > 4 at night" (même formatage pour en-GB quelle que soit la valeur de dayPeriod) -console.log(new Intl.DateTimeFormat('fr', { hour: 'numeric', hourCycle: 'h12', - dayPeriod: 'narrow', timeZone: 'UTC' }).format(date)); +console.log( + new Intl.DateTimeFormat("fr", { + hour: "numeric", + hourCycle: "h12", + dayPeriod: "narrow", + timeZone: "UTC", + }).format(date), +); // > "4 mat." (même formatage pour fr avec narrow ou short) -console.log(new Intl.DateTimeFormat('fr', { hour: 'numeric', hourCycle: 'h12', - dayPeriod: 'long', timeZone: 'UTC' }).format(date)); +console.log( + new Intl.DateTimeFormat("fr", { + hour: "numeric", + hourCycle: "h12", + dayPeriod: "long", + timeZone: "UTC", + }).format(date), +); // > "4 du matin" ``` @@ -222,17 +240,24 @@ On utilise l'option `timeZoneName` pour produire une chaîne de caractères repr ```js var date = Date.UTC(2021, 11, 17, 3, 0, 42); -const timezoneNames = ['short', 'long', 'shortOffset', 'longOffset', 'shortGeneric', 'longGeneric'] +const timezoneNames = [ + "short", + "long", + "shortOffset", + "longOffset", + "shortGeneric", + "longGeneric", +]; for (const zoneName of timezoneNames) { - var formatter = new Intl.DateTimeFormat('fr', { - timeZone: 'Europe/Paris', + var formatter = new Intl.DateTimeFormat("fr", { + timeZone: "Europe/Paris", timeZoneName: zoneName, }); - console.log(zoneName + " : " + formatter.format(date) ); + console.log(zoneName + " : " + formatter.format(date)); } -// Résultat attendu : +// Résultat attendu : // short : 17/12/2021, UTC+1 // long : 17/12/2021, heure normale d'Europe centrale // shortOffset : 17/12/2021, UTC+1 diff --git a/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/format/index.md b/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/format/index.md index de8d78e3887d3a..98eb8bd7ca17cd 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/format/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/format/index.md @@ -13,7 +13,7 @@ La méthode **`Intl.DateTimeFormat.prototype.format()`** est un accesseur format ## Syntaxe ```js -dateTimeFormat.format(date) +dateTimeFormat.format(date); ``` ### Paramètres @@ -32,7 +32,12 @@ L'accesseur `format` permet de formater une date en une chaîne de caractères e On peut utiliser la fonction renvoyée par l'accesseur `format` pour formater une date. Par exemple selon la locale serbe : ```js -var options = {weekday: "long", year: "numeric", month: "long", day: "numeric"}; +var options = { + weekday: "long", + year: "numeric", + month: "long", + day: "numeric", +}; var dateTimeFormat = new Intl.DateTimeFormat("sr-RS", options); console.log(dateTimeFormat.format(new Date())); // → "недеља, 7. април 2013." @@ -44,7 +49,7 @@ On peut également utiliser la fonction renvoyée par l'accesseur `format` pour ```js var a = [new Date(2012, 08), new Date(2012, 11), new Date(2012, 03)]; -var options = {year: "numeric", month: "long"}; +var options = { year: "numeric", month: "long" }; var dateTimeFormat = new Intl.DateTimeFormat("pt-BR", options); var formatted = a.map(dateTimeFormat.format); console.log(formatted.join("; ")); @@ -60,12 +65,12 @@ Aussi, mieux vaut ne pas comparer un résultat fourni par `format()` avec une va ```js example-bad let d = new Date("2019-01-01T00:00:00.000000Z"); let formattedDate = Intl.DateTimeFormat(undefined, { - year: 'numeric', - month: 'numeric', - day: 'numeric', - hour: 'numeric', - minute: 'numeric', - second: 'numeric' + year: "numeric", + month: "numeric", + day: "numeric", + hour: "numeric", + minute: "numeric", + second: "numeric", }).format(d); "1.1.2019, 01:00:00" === formattedDate; From 0c354000990d8662066f6eb2f6b9e377f25cb355 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 01:43:12 -0700 Subject: [PATCH 09/30] fr: Format /web/javascript using Prettier (part 4) (#14642) --- .../intl/datetimeformat/formatrange/index.md | 18 +-- .../formatrangetoparts/index.md | 6 +- .../datetimeformat/formattoparts/index.md | 67 ++++----- .../intl/datetimeformat/index.md | 63 +++++---- .../datetimeformat/resolvedoptions/index.md | 10 +- .../supportedlocalesof/index.md | 6 +- .../intl/displaynames/displaynames/index.md | 2 +- .../global_objects/intl/displaynames/index.md | 58 ++++---- .../intl/displaynames/of/index.md | 16 +-- .../displaynames/resolvedoptions/index.md | 10 +- .../displaynames/supportedlocalesof/index.md | 10 +- .../intl/getcanonicallocales/index.md | 2 +- .../reference/global_objects/intl/index.md | 6 +- .../intl/listformat/formattoparts/index.md | 9 +- .../global_objects/intl/listformat/index.md | 27 +++- .../intl/listformat/listformat/index.md | 29 ++-- .../intl/listformat/resolvedoptions/index.md | 6 +- .../listformat/supportedlocalesof/index.md | 6 +- .../intl/locale/basename/index.md | 2 +- .../intl/locale/calendar/index.md | 2 +- .../intl/locale/casefirst/index.md | 2 +- .../intl/locale/collation/index.md | 2 +- .../intl/locale/getweekinfo/index.md | 4 +- .../intl/locale/language/index.md | 2 +- .../intl/locale/locale/index.md | 6 +- .../intl/locale/maximize/index.md | 6 +- .../intl/locale/minimize/index.md | 7 +- .../intl/locale/numberingsystem/index.md | 4 +- .../intl/locale/numeric/index.md | 2 +- .../intl/locale/region/index.md | 2 +- .../intl/locale/script/index.md | 2 +- .../intl/locale/tostring/index.md | 7 +- .../intl/numberformat/format/index.md | 4 +- .../intl/numberformat/formatrange/index.md | 3 +- .../numberformat/formatrangetoparts/index.md | 18 +-- .../intl/numberformat/formattoparts/index.md | 27 ++-- .../global_objects/intl/numberformat/index.md | 40 ++++-- .../intl/numberformat/numberformat/index.md | 70 +++++----- .../numberformat/resolvedoptions/index.md | 14 +- .../numberformat/supportedlocalesof/index.md | 2 +- .../global_objects/intl/pluralrules/index.md | 10 +- .../intl/pluralrules/pluralrules/index.md | 32 ++--- .../intl/pluralrules/resolvedoptions/index.md | 12 +- .../intl/pluralrules/select/index.md | 12 +- .../intl/pluralrules/selectrange/index.md | 6 +- .../pluralrules/supportedlocalesof/index.md | 6 +- .../intl/relativetimeformat/format/index.md | 8 +- .../relativetimeformat/formattoparts/index.md | 2 +- .../intl/relativetimeformat/index.md | 6 +- .../relativetimeformat/index.md | 12 +- .../resolvedoptions/index.md | 10 +- .../supportedlocalesof/index.md | 6 +- .../global_objects/intl/segmenter/index.md | 9 +- .../intl/segmenter/resolvedoptions/index.md | 10 +- .../intl/segmenter/segment/index.md | 14 +- .../segment/segments/@@iterator/index.md | 4 +- .../segment/segments/containing/index.md | 6 +- .../intl/segmenter/segmenter/index.md | 13 +- .../segmenter/supportedlocalesof/index.md | 10 +- .../intl/supportedvaluesof/index.md | 28 ++-- .../global_objects/isfinite/index.md | 21 ++- .../reference/global_objects/isnan/index.md | 46 +++--- .../global_objects/json/parse/index.md | 20 +-- .../global_objects/json/stringify/index.md | 131 +++++++++++------- .../global_objects/map/@@iterator/index.md | 2 +- .../global_objects/map/@@species/index.md | 6 +- .../global_objects/map/clear/index.md | 6 +- .../global_objects/map/delete/index.md | 2 +- .../global_objects/map/entries/index.md | 2 +- .../global_objects/map/foreach/index.md | 11 +- .../reference/global_objects/map/get/index.md | 6 +- .../reference/global_objects/map/has/index.md | 4 +- .../reference/global_objects/map/index.md | 76 +++++----- .../global_objects/map/keys/index.md | 2 +- .../reference/global_objects/map/map/index.md | 10 +- .../reference/global_objects/map/set/index.md | 4 +- .../global_objects/map/size/index.md | 2 +- .../global_objects/map/values/index.md | 2 +- .../global_objects/math/abs/index.md | 18 +-- .../global_objects/math/acos/index.md | 12 +- .../global_objects/math/acosh/index.md | 10 +- .../global_objects/math/asin/index.md | 12 +- .../global_objects/math/asinh/index.md | 18 +-- .../global_objects/math/atan/index.md | 6 +- .../global_objects/math/atan2/index.md | 2 +- .../global_objects/math/atanh/index.md | 22 +-- .../global_objects/math/cbrt/index.md | 4 +- .../global_objects/math/ceil/index.md | 44 +++--- .../global_objects/math/clz32/index.md | 31 +++-- .../global_objects/math/cos/index.md | 8 +- .../global_objects/math/cosh/index.md | 18 ++- .../reference/global_objects/math/e/index.md | 2 +- .../global_objects/math/exp/index.md | 6 +- .../global_objects/math/expm1/index.md | 12 +- .../global_objects/math/floor/index.md | 10 +- .../global_objects/math/fround/index.md | 10 +- .../global_objects/math/hypot/index.md | 22 +-- .../global_objects/math/imul/index.md | 28 ++-- .../global_objects/math/ln10/index.md | 2 +- .../global_objects/math/log/index.md | 8 +- 100 files changed, 802 insertions(+), 651 deletions(-) diff --git a/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/formatrange/index.md b/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/formatrange/index.md index dd615dae269091..265b455cf4cad4 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/formatrange/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/formatrange/index.md @@ -13,7 +13,7 @@ La méthode **`Intl.DateTimeFormat.prototype.formatRange()`** permet de formater ## Syntaxe ```js -formatRange(dateDébut, dateFin) +formatRange(dateDébut, dateFin); ``` ## Exemples @@ -31,11 +31,11 @@ let date3 = new Date(Date.UTC(2007, 0, 20, 10, 0, 0)); // > 'Sat, 20 Jan 2007 10:00:00 GMT' let fmt1 = new Intl.DateTimeFormat("en", { - year: '2-digit', - month: 'numeric', - day: 'numeric', - hour: 'numeric', - minute: 'numeric' + year: "2-digit", + month: "numeric", + day: "numeric", + hour: "numeric", + minute: "numeric", }); console.log(fmt1.format(date1)); console.log(fmt1.formatRange(date1, date2)); @@ -45,9 +45,9 @@ console.log(fmt1.formatRange(date1, date3)); // > '1/10/07, 10:00 AM – 1/20/07, 10:00 AM' let fmt2 = new Intl.DateTimeFormat("en", { - year: 'numeric', - month: 'short', - day: 'numeric' + year: "numeric", + month: "short", + day: "numeric", }); console.log(fmt2.format(date1)); console.log(fmt2.formatRange(date1, date2)); diff --git a/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/formatrangetoparts/index.md b/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/formatrangetoparts/index.md index 657402fbb70622..9755d03c7ab4a8 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/formatrangetoparts/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/formatrangetoparts/index.md @@ -11,7 +11,7 @@ La fonction **`Intl.DateTimeFormat.prototype.formatRangeToParts()`** permet, sel ## Syntaxe ```js -Intl.DateTimeFormat.prototype.formatRangeToParts(dateDebut, dateFin) +Intl.DateTimeFormat.prototype.formatRangeToParts(dateDebut, dateFin); ``` ## Exemples @@ -27,8 +27,8 @@ let date2 = new Date(Date.UTC(2007, 0, 10, 11, 0, 0)); // > 'Wed, 10 Jan 2007 11:00:00 GMT' let fmt = new Intl.DateTimeFormat("en", { - hour: 'numeric', - minute: 'numeric' + hour: "numeric", + minute: "numeric", }); console.log(fmt.formatRange(date1, date2)); diff --git a/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/formattoparts/index.md b/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/formattoparts/index.md index a3c94acfca4c83..587ad225f8349a 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/formattoparts/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/formattoparts/index.md @@ -11,7 +11,7 @@ La méthode **`Intl.DateTimeFormat.prototype.formatToParts()`** permet de mettre ## Syntaxe ```js -Intl.DateTimeFormat.prototype.formatToParts(date) +Intl.DateTimeFormat.prototype.formatToParts(date); ``` ### Paramètres @@ -67,15 +67,15 @@ Les types possibles sont : var date = Date.UTC(2012, 11, 17, 3, 0, 42); var formatter = new Intl.DateTimeFormat("en-us", { - weekday: 'long', - year: 'numeric', - month: 'numeric', - day: 'numeric', - hour: 'numeric', - minute: 'numeric', - second: 'numeric', + weekday: "long", + year: "numeric", + month: "numeric", + day: "numeric", + hour: "numeric", + minute: "numeric", + second: "numeric", hour12: true, - timeZone: "UTC" + timeZone: "UTC", }); formatter.format(date); @@ -89,33 +89,38 @@ formatter.formatToParts(date); // return value: [ - { type: 'weekday', value: 'Monday' }, - { type: 'separator', value: ', ' }, - { type: 'month', value: '12' }, - { type: 'literal', value: '/' }, - { type: 'day', value: '17' }, - { type: 'literal', value: '/' }, - { type: 'year', value: '2012' }, - { type: 'literal', value: ', ' }, - { type: 'hour', value: '3' }, - { type: 'literal', value: ':' }, - { type: 'minute', value: '00' }, - { type: 'literal', value: ':' }, - { type: 'second', value: '42' }, - { type: 'literal', value: ' ' }, - { type: 'dayPeriod', value: 'AM' } -] + { type: "weekday", value: "Monday" }, + { type: "separator", value: ", " }, + { type: "month", value: "12" }, + { type: "literal", value: "/" }, + { type: "day", value: "17" }, + { type: "literal", value: "/" }, + { type: "year", value: "2012" }, + { type: "literal", value: ", " }, + { type: "hour", value: "3" }, + { type: "literal", value: ":" }, + { type: "minute", value: "00" }, + { type: "literal", value: ":" }, + { type: "second", value: "42" }, + { type: "literal", value: " " }, + { type: "dayPeriod", value: "AM" }, +]; ``` L'information étant décomposée, on peut alors la mettre en forme et la recomposée de façon adaptée : ```js -var dateString = formatter.formatToParts(date).map(({type, value}) => { - switch (type) { - case 'dayPeriod': return `${value}`; - default : return value; - } -}).reduce((string, part) => string + part); +var dateString = formatter + .formatToParts(date) + .map(({ type, value }) => { + switch (type) { + case "dayPeriod": + return `${value}`; + default: + return value; + } + }) + .reduce((string, part) => string + part); console.log(formatter.format(date)); // "Monday, 12/17/2012, 3:00:42 AM" diff --git a/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/index.md b/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/index.md index 63fc0c13f2aa34..462a991db7bba3 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/index.md @@ -59,30 +59,30 @@ var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0)); // fuseau horaire CEST // l'anglais américain utilise l'ordre mois-jour-année -console.log(new Intl.DateTimeFormat('en-US').format(date)); +console.log(new Intl.DateTimeFormat("en-US").format(date)); // → "12/20/2012" // l'anglais britannique utilise l'ordre jour-mois-année -console.log(new Intl.DateTimeFormat('en-GB').format(date)); +console.log(new Intl.DateTimeFormat("en-GB").format(date)); // → "20/12/2012" // le coréen utilise l'ordre année-mois-jour -console.log(new Intl.DateTimeFormat('ko-KR').format(date)); +console.log(new Intl.DateTimeFormat("ko-KR").format(date)); // → "2012. 12. 20." // l'arabe, dans la plupart des pays arabophones, utilise les chiffres arabes -console.log(new Intl.DateTimeFormat('ar-EG').format(date)); +console.log(new Intl.DateTimeFormat("ar-EG").format(date)); // → "٢٠‏/١٢‏/٢٠١٢" // en ce qui concerne le japonais, les applications peuvent // souhaiter utiliser le calendrier japonais // pour lequel 2012 était l'année 24 de l'ère Heisei -console.log(new Intl.DateTimeFormat('ja-JP-u-ca-japanese').format(date)); +console.log(new Intl.DateTimeFormat("ja-JP-u-ca-japanese").format(date)); // → "24/12/20" // quand une locale non prise en charge est demandée (par exemple le balinais) // il est possible de fournir une locale de recours (ici l'indonésien) -console.log(new Intl.DateTimeFormat(['ban', 'id']).format(date)); +console.log(new Intl.DateTimeFormat(["ban", "id"]).format(date)); // → "20/12/2012" ``` @@ -94,49 +94,64 @@ Les formats de la date et de l'heure peuvent être personnalisés en utilisant l var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0)); // fournir le jour de la semaine avec une date longue -var options = {weekday: "long", year: "numeric", month: "long", day: "numeric"}; -console.log(new Intl.DateTimeFormat('de-DE', options).format(date)); +var options = { + weekday: "long", + year: "numeric", + month: "long", + day: "numeric", +}; +console.log(new Intl.DateTimeFormat("de-DE", options).format(date)); // → "Donnerstag, 20. Dezember 2012" // une application peut vouloir utiliser UTC et le rendre visible -options.timeZone = 'UTC'; -options.timeZoneName = 'short'; -console.log(new Intl.DateTimeFormat('en-US', options).format(date)); +options.timeZone = "UTC"; +options.timeZoneName = "short"; +console.log(new Intl.DateTimeFormat("en-US", options).format(date)); // → "Thursday, December 20, 2012, GMT" // parfois, il faut plus de précision -options = {hour: "numeric", minute: "numeric", second: "numeric", - timeZoneName: "short"}; -console.log(new Intl.DateTimeFormat('en-AU', options).format(date)); +options = { + hour: "numeric", + minute: "numeric", + second: "numeric", + timeZoneName: "short", +}; +console.log(new Intl.DateTimeFormat("en-AU", options).format(date)); // → "2:00:00 pm AEDT" // voire beaucoup plus de précision options.fractionalSecondDigits = 3; // le nombre de chiffres décimaux pour les fractions de secondes -console.log(new Intl.DateTimeFormat('en-AU', options).format(date)); +console.log(new Intl.DateTimeFormat("en-AU", options).format(date)); // → "2:00:00.200 pm AEDT" // parfois, même les USA ont besoin d'afficher une heure sur 24h -options = {year: "numeric", month: "numeric", day: "numeric", - hour: "numeric", minute: "numeric", second: "numeric", - hour12: false}; -console.log(new Intl.DateTimeFormat('en-US', options)); +options = { + year: "numeric", + month: "numeric", + day: "numeric", + hour: "numeric", + minute: "numeric", + second: "numeric", + hour12: false, +}; +console.log(new Intl.DateTimeFormat("en-US", options)); // → "12/19/2012, 19:00:00" // pour utiliser la locale par défaut du navigateur, on utilise default -console.log(new Intl.DateTimeFormat('default', options).format(date)); +console.log(new Intl.DateTimeFormat("default", options).format(date)); // → "12/19/2012, 19:00:00" (peut varier selon la locale du navigateur) // on peut aussi inclure la période du jour -options = {hour: "numeric", dayPeriod: "short"}; -console.log(new Intl.DateTimeFormat('en-US', options).format(date)); +options = { hour: "numeric", dayPeriod: "short" }; +console.log(new Intl.DateTimeFormat("en-US", options).format(date)); // → "4 at night" ``` Le calendrier et la numération utilisés peuvent être choisis indépendamment avec l'argument `options` : ```js -var options = {calendar: 'chinese', numberingSystem: 'arab'}; -var dateFormat = new Intl.DateTimeFormat('default', options); +var options = { calendar: "chinese", numberingSystem: "arab" }; +var dateFormat = new Intl.DateTimeFormat("default", options); var usedOptions = dateFormat.resolvedOptions(); console.log(usedOptions.calendar); diff --git a/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/resolvedoptions/index.md b/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/resolvedoptions/index.md index 10bd960798914f..89ac1969979c28 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/resolvedoptions/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/resolvedoptions/index.md @@ -13,7 +13,7 @@ La méthode **`Intl.DateTimeFormat.prototype.resolvedOptions()`** renvoie un nou ## Syntaxe ```js -resolvedOptions() +resolvedOptions(); ``` ### Valeur de retour @@ -45,11 +45,11 @@ La valeur renvoyée par cette méthode contient les propriétés suivantes : var germanFakeRegion = new Intl.DateTimeFormat("de-XX", { timeZone: "UTC" }); var usedOptions = germanFakeRegion.resolvedOptions(); -usedOptions.locale; // "de" -usedOptions.calendar; // "gregory" +usedOptions.locale; // "de" +usedOptions.calendar; // "gregory" usedOptions.numberingSystem; // "latn" -usedOptions.timeZone; // "UTC" -usedOptions.month; // "numeric" +usedOptions.timeZone; // "UTC" +usedOptions.month; // "numeric" ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/supportedlocalesof/index.md b/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/supportedlocalesof/index.md index 6bfdd16c4945bb..207193e79f6019 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/supportedlocalesof/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/datetimeformat/supportedlocalesof/index.md @@ -43,8 +43,10 @@ Si on dispose d'un environnement qui supporte les locales indonésienne et allem ```js var locales = ["ban", "id-u-co-pinyin", "de-ID"]; -var options = {localeMatcher: "lookup"}; -console.log(Intl.DateTimeFormat.supportedLocalesOf(locales, options).join(", ")); +var options = { localeMatcher: "lookup" }; +console.log( + Intl.DateTimeFormat.supportedLocalesOf(locales, options).join(", "), +); // → "id-u-co-pinyin, de-ID" ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/displaynames/displaynames/index.md b/files/fr/web/javascript/reference/global_objects/intl/displaynames/displaynames/index.md index 1f9f7a63da46f0..baa365af7358ec 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/displaynames/displaynames/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/displaynames/displaynames/index.md @@ -62,7 +62,7 @@ new Intl.DisplayNames([langues[, options]]) Dans son utilisation simple, sans spécifier de langue, une chaine dans la langue locale par défaut et avec les options par défaut sera retournée. ```js -console.log((new Intl.DisplayNames()).of('US')); +console.log(new Intl.DisplayNames().of("US")); // Expected output: 'us' ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/displaynames/index.md b/files/fr/web/javascript/reference/global_objects/intl/displaynames/index.md index 3f9d8b08cd96c9..09f688fbc81065 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/displaynames/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/displaynames/index.md @@ -57,19 +57,19 @@ Pour créer un objet `Intl.DisplayNames` pour une langue et obtenir le nom corre ```js // Obtenir le nom d'une langue en anglais -let nomsLangues= new Intl.DisplayNames(['en'], {type: 'language'}); -nomsLangues.of('fr'); // "French" -nomsLangues.of('de'); // "German" -nomsLangues.of('fr-CA'); // "Canadian French" -nomsLangues.of('zh-Hant'); // "Traditional Chinese" -nomsLangues.of('en-US'); // "American English" -nomsLangues.of('zh-TW'); // "Chinese (Taiwan)" +let nomsLangues = new Intl.DisplayNames(["en"], { type: "language" }); +nomsLangues.of("fr"); // "French" +nomsLangues.of("de"); // "German" +nomsLangues.of("fr-CA"); // "Canadian French" +nomsLangues.of("zh-Hant"); // "Traditional Chinese" +nomsLangues.of("en-US"); // "American English" +nomsLangues.of("zh-TW"); // "Chinese (Taiwan)" // Obtenir le nom d'une langue en chinois traditionnel -nomsLangues = new Intl.DisplayNames(['zh-Hant'], {type: 'language'}); -nomsLangues.of('fr'); // "法文" -nomsLangues.of('zh'); // "中文" -nomsLangues.of('de'); // "德文" +nomsLangues = new Intl.DisplayNames(["zh-Hant"], { type: "language" }); +nomsLangues.of("fr"); // "法文" +nomsLangues.of("zh"); // "中文" +nomsLangues.of("de"); // "德文" ``` ### Affichage des noms de systèmes d'écriture @@ -80,16 +80,16 @@ Pour créer un objet `Intl.DisplayNames` pour une langue et obtenir le nom corre ```js // Obtenir le nom d'un système d'écriture en anglais -let nomsSystèmes = new Intl.DisplayNames(['en'], {type: 'script'}); -nomsSystèmes.of('Latn'); // "Latin" -nomsSystèmes.of('Arab'); // "Arabic" -nomsSystèmes.of('Kana'); // "Katakana" +let nomsSystèmes = new Intl.DisplayNames(["en"], { type: "script" }); +nomsSystèmes.of("Latn"); // "Latin" +nomsSystèmes.of("Arab"); // "Arabic" +nomsSystèmes.of("Kana"); // "Katakana" // Obtenir le nom d'un système d'écriture en chinois traditionnel -nomsSystèmes = new Intl.DisplayNames(['zh-Hant'], {type: 'script'}); -nomsSystèmes.of('Latn'); // "拉丁文" -nomsSystèmes.of('Arab'); // "阿拉伯文" -nomsSystèmes.of('Kana'); // "片假名" +nomsSystèmes = new Intl.DisplayNames(["zh-Hant"], { type: "script" }); +nomsSystèmes.of("Latn"); // "拉丁文" +nomsSystèmes.of("Arab"); // "阿拉伯文" +nomsSystèmes.of("Kana"); // "片假名" ``` ### Affichage des noms de devises @@ -98,18 +98,18 @@ Pour créer un objet `Intl.DisplayNames` pour une langue et obtenir le nom corre ```js // Obtenir le nom d'une devise in English -let nomsDevises = new Intl.DisplayNames(['en'], {type: 'currency'}); -nomsDevises.of('USD'); // "US Dollar" -nomsDevises.of('EUR'); // "Euro" -nomsDevises.of('TWD'); // "New Taiwan Dollar" -nomsDevises.of('CNY'); // "Chinese Yuan" +let nomsDevises = new Intl.DisplayNames(["en"], { type: "currency" }); +nomsDevises.of("USD"); // "US Dollar" +nomsDevises.of("EUR"); // "Euro" +nomsDevises.of("TWD"); // "New Taiwan Dollar" +nomsDevises.of("CNY"); // "Chinese Yuan" // Obtenir le nom d'une devise in Traditional Chinese -nomsDevises = new Intl.DisplayNames(['zh-Hant'], {type: 'currency'}); -nomsDevises.of('USD'); // "美元" -nomsDevises.of('EUR'); // "歐元" -nomsDevises.of('TWD'); // "新台幣" -nomsDevises.of('CNY'); // "人民幣" +nomsDevises = new Intl.DisplayNames(["zh-Hant"], { type: "currency" }); +nomsDevises.of("USD"); // "美元" +nomsDevises.of("EUR"); // "歐元" +nomsDevises.of("TWD"); // "新台幣" +nomsDevises.of("CNY"); // "人民幣" ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/intl/displaynames/of/index.md b/files/fr/web/javascript/reference/global_objects/intl/displaynames/of/index.md index c36251fd5a0b83..888a5061b9d337 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/displaynames/of/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/displaynames/of/index.md @@ -12,7 +12,7 @@ La méthode **`Intl.DisplayNames.prototype.of()`** prend comme argument un code ## Syntaxe ```js -of(code) +of(code); ``` ### Paramètres @@ -23,7 +23,7 @@ of(code) - Si le type est `"region"`, le code sera [un code de région ISO-3166 sur deux lettres](https://www.iso.org/iso-3166-country-codes.html), ou [un code de région géographique sur trois chiffres UN M49](https://unstats.un.org/unsd/methodology/m49/). - Si le type est `"script"`, le code sera [un code de script ISO-15924 sur quatre lettres](https://unicode.org/iso15924/iso15924-codes.html). - - Si le type est `"language"`, le code sera de la forme d'une sous-séquence _languageCode_ \["-"_scriptCode_] \["-" _regionCode_ ] \*("-" _variant_ ) de la grammaire unicode_language_id pour [la grammaire des identifiants de locales et de langues Unicode UTS 35](https://unicode.org/reports/tr35/#Unicode_language_identifier). _languageCode_ est soit un code de langue ISO 639-1 sur deux lettres ou un code de langue ISO 639-2 sur trois lettres. + - Si le type est `"language"`, le code sera de la forme d'une sous-séquence _languageCode_ \["-"_scriptCode_] \["-" _regionCode_ ] ("-" _variant_ ) de la grammaire unicode\_language\_id pour [la grammaire des identifiants de locales et de langues Unicode UTS 35](https://unicode.org/reports/tr35/#Unicode_language_identifier). _languageCode_ est soit un code de langue ISO 639-1 sur deux lettres ou un code de langue ISO 639-2 sur trois lettres. - Si le type est `"currency"`, le code sera [un code à 3 lettres ISO 4217](https://www.iso.org/iso-4217-currency-codes.html). ### Valeur de retour @@ -35,14 +35,14 @@ Une chaîne de caractères formatée spécifique à une locale. ### Utilisation de la méthode of() ```js -let regionNames = new Intl.DisplayNames(['en'], {type: 'region'}); -regionNames.of('419'); // "Latin America" +let regionNames = new Intl.DisplayNames(["en"], { type: "region" }); +regionNames.of("419"); // "Latin America" -let languageNames = new Intl.DisplayNames(['en'], {type: 'language'}); -languageNames.of('fr'); // "French" +let languageNames = new Intl.DisplayNames(["en"], { type: "language" }); +languageNames.of("fr"); // "French" -let currencyNames = new Intl.DisplayNames(['en'], {type: 'currency'}); -currencyNames.of('EUR'); // "Euro" +let currencyNames = new Intl.DisplayNames(["en"], { type: "currency" }); +currencyNames.of("EUR"); // "Euro" ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/intl/displaynames/resolvedoptions/index.md b/files/fr/web/javascript/reference/global_objects/intl/displaynames/resolvedoptions/index.md index 881bfb8b9ff0a5..e4337b79ecbb22 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/displaynames/resolvedoptions/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/displaynames/resolvedoptions/index.md @@ -10,7 +10,7 @@ La méthode **`Intl.DisplayNames.prototype.resolvedOptions()`** renvoie un nouve ## Syntaxe ```js -resolvedOptions() +resolvedOptions(); ``` ### Valeur de retour @@ -35,12 +35,12 @@ L'objet renvoyé par `resolvedOptions()` possède les propriétés suivantes&nbs ### Utiliser resolvedOptions() ```js -const displayNames = new Intl.DisplayNames(['de-DE'], {type: 'region'}); +const displayNames = new Intl.DisplayNames(["de-DE"], { type: "region" }); const usedOptions = displayNames.resolvedOptions(); -console.log(usedOptions.locale); // "de-DE" -console.log(usedOptions.style); // "long" -console.log(usedOptions.type); // "region" +console.log(usedOptions.locale); // "de-DE" +console.log(usedOptions.style); // "long" +console.log(usedOptions.type); // "region" console.log(usedOptions.fallback); // "code" ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/displaynames/supportedlocalesof/index.md b/files/fr/web/javascript/reference/global_objects/intl/displaynames/supportedlocalesof/index.md index 27640d0d9b96d7..438d5bda770a1a 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/displaynames/supportedlocalesof/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/displaynames/supportedlocalesof/index.md @@ -10,8 +10,8 @@ La méthode **`Intl.DisplayNames.supportedLocalesOf()`** renvoie un tableau dont ## Syntaxe ```js -Intl.DisplayNames.supportedLocalesOf(locales) -Intl.DisplayNames.supportedLocalesOf(locales, options) +Intl.DisplayNames.supportedLocalesOf(locales); +Intl.DisplayNames.supportedLocalesOf(locales, options); ``` ### Paramètres @@ -36,9 +36,9 @@ Un tableau de chaînes de caractères qui est un sous-ensemble des balises de la Soit un environnement d'exécution qui prend en charge l'indonésien et l'allemand pour les noms d'affichage mais pas le balinais, `supportedLocalesOf` renverra les balises indonésiennes et germaniques inchangées bien que la collation `pinyin` n'est ni pertinente pour les noms d'affichage ou même utilisée pour l'indonésien et qu'un dialecte germanique pour l'indonésien sera peu probablement pris en charge. On notera que c'est l'algorithme "`lookup`" qui est utilisé ici ("`best fit`" pourrait décider que l'indonésien est une correspondance acceptable pour du balinais vu que les locuteurs balinais comprennent l'indonésien et inclure la balise de langue balinaise également). ```js -const locales = ['ban', 'id-u-co-pinyin', 'de-ID']; -const options = { localeMatcher: 'lookup' }; -console.log(Intl.DisplayNames.supportedLocalesOf(locales, options).join(', ')); +const locales = ["ban", "id-u-co-pinyin", "de-ID"]; +const options = { localeMatcher: "lookup" }; +console.log(Intl.DisplayNames.supportedLocalesOf(locales, options).join(", ")); // → "id-u-co-pinyin, de-ID" ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/getcanonicallocales/index.md b/files/fr/web/javascript/reference/global_objects/intl/getcanonicallocales/index.md index 057e4fc0091f41..420b9c811d7a10 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/getcanonicallocales/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/getcanonicallocales/index.md @@ -13,7 +13,7 @@ La méthode **`Intl.getCanonicalLocales()`** renvoie un tableau contenant les no ## Syntaxe ```js -Intl.getCanonicalLocales(locales) +Intl.getCanonicalLocales(locales); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/intl/index.md b/files/fr/web/javascript/reference/global_objects/intl/index.md index 5b67c07a5b5d78..7c5feadee46f24 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/index.md @@ -79,9 +79,11 @@ Vous pouvez utiliser Intl pour formater des dates et nombres dans un format qui const compte = 26254.39; const date = new Date("2012-05-24"); -function afficher (langue) { +function afficher(langue) { console.log( - `${new Intl.DateTimeFormat(langue).format(date)} ${new Intl.NumberFormat(langue).format(compte)}` + `${new Intl.DateTimeFormat(langue).format(date)} ${new Intl.NumberFormat( + langue, + ).format(compte)}`, ); } diff --git a/files/fr/web/javascript/reference/global_objects/intl/listformat/formattoparts/index.md b/files/fr/web/javascript/reference/global_objects/intl/listformat/formattoparts/index.md index ba9ac6f92a1ef5..88c6c4bdf41339 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/listformat/formattoparts/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/listformat/formattoparts/index.md @@ -11,7 +11,7 @@ La méthode **`Intl.ListFormat.prototype.formatToParts()`** renvoie un tableau ( ## Syntaxe ```js -Intl.ListFormat.prototype.formatToParts(list) +Intl.ListFormat.prototype.formatToParts(list); ``` ### Paramètres @@ -34,8 +34,11 @@ Les options de locale et de style utilisées pour le formatage sont fournies lor ## Exemples ```js -const fruits = ['Apple', 'Orange', 'Pineapple']; -const myListFormat = new Intl.ListFormat('en-GB', { style: 'long', type: 'conjunction' }); +const fruits = ["Apple", "Orange", "Pineapple"]; +const myListFormat = new Intl.ListFormat("en-GB", { + style: "long", + type: "conjunction", +}); console.table(myListFormat.formatToParts(fruits)); // [ diff --git a/files/fr/web/javascript/reference/global_objects/intl/listformat/index.md b/files/fr/web/javascript/reference/global_objects/intl/listformat/index.md index 529a64b8fc95cc..a9bea532b4397d 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/listformat/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/listformat/index.md @@ -34,15 +34,25 @@ L'objet **`Intl.ListFormat`** permet de formater des listes de façon différent Dans l'exemple qui suit, on voit comment créer un formateur de liste pour l'anglais. ```js -const list = ['Motorcycle', 'Bus', 'Car']; +const list = ["Motorcycle", "Bus", "Car"]; - console.log(new Intl.ListFormat('en-GB', { style: 'long', type: 'conjunction' }).format(list)); +console.log( + new Intl.ListFormat("en-GB", { style: "long", type: "conjunction" }).format( + list, + ), +); // > Motorcycle, Bus and Car - console.log(new Intl.ListFormat('en-GB', { style: 'short', type: 'disjunction' }).format(list)); +console.log( + new Intl.ListFormat("en-GB", { style: "short", type: "disjunction" }).format( + list, + ), +); // > Motorcycle, Bus or Car - console.log(new Intl.ListFormat('en-GB', { style: 'narrow', type: 'unit' }).format(list)); +console.log( + new Intl.ListFormat("en-GB", { style: "narrow", type: "unit" }).format(list), +); // > Motorcycle Bus Car ``` @@ -51,8 +61,13 @@ const list = ['Motorcycle', 'Bus', 'Car']; Dans l'exemple qui suit, on voit comment créer un formateur de liste, renvoyant les fragments, pour l'anglais. ```js -const list = ['Motorcycle', 'Bus', 'Car']; -console.log(new Intl.ListFormat('en-GB', { style: 'long', type: 'conjunction' }).formatToParts(list)); +const list = ["Motorcycle", "Bus", "Car"]; +console.log( + new Intl.ListFormat("en-GB", { + style: "long", + type: "conjunction", + }).formatToParts(list), +); // [ { "type": "element", "value": "Motorcycle" }, // { "type": "literal", "value": ", " }, diff --git a/files/fr/web/javascript/reference/global_objects/intl/listformat/listformat/index.md b/files/fr/web/javascript/reference/global_objects/intl/listformat/listformat/index.md index e1b29b766bb444..6400b218131a28 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/listformat/listformat/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/listformat/listformat/index.md @@ -12,9 +12,9 @@ Le constructeur **`Intl.ListFormat()`** permet de créer des objets [`Intl.ListF ## Syntaxe ```js -new Intl.ListFormat() -new Intl.ListFormat(locales) -new Intl.ListFormat(locales, options) +new Intl.ListFormat(); +new Intl.ListFormat(locales); +new Intl.ListFormat(locales, options); ``` ### Paramètres @@ -29,9 +29,8 @@ new Intl.ListFormat(locales, options) - : - : L'algorithme de correspondance des locales à utiliser. Les valeurs possibles sont "`lookup`" et "`best fit`" ; la valeur par défaut est "`best fit`". Pour plus d'information, voir la page [`Intl`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Intl#négociation_de_la_locale). - `type` - : Le format de sortie produit. Les valeurs possibles sont "`conjunction`" qui indique une liste additive (par exemple "`A, B, et C`"), c'est la valeur par défaut, ou "`disjunction`" qui indique une liste d'options distinctes (par exemple, "`A, B, ou C`"), ou "`unit`" qui indique une liste de valeurs avec des unités (par exemple, "`5 kg, 12 L`"). - - `style` - - : La longueur du message formaté. Les valeurs possibles sont "`long`", la valeur par défaut (par exemple "`A, B, et C`") ; "`short`" (par exemple - "`A, B, C`"), ou "`narrow`" (par exemple, "`A B C`"). Lorsque la valeur de `style` est "`short`" ou "`narrow`", seule la valeur "`unit`" est autorisée pour l'option "type". + - `style` - : La longueur du message formaté. Les valeurs possibles sont "`long`", la valeur par défaut (par exemple "`A, B, et C`") ; "`short`" (par exemple + "`A, B, C`"), ou "`narrow`" (par exemple, "`A B C`"). Lorsque la valeur de `style` est "`short`" ou "`narrow`", seule la valeur "`unit`" est autorisée pour l'option "type". ## Exemples @@ -40,15 +39,25 @@ new Intl.ListFormat(locales, options) L'exemple suivant illustre comment créer un formateur de liste basé sur la langue française. ```js -const list = ['Moto', 'Bus', 'Car']; +const list = ["Moto", "Bus", "Car"]; -console.log(new Intl.ListFormat('fr', { style: 'long', type: 'conjunction' }).format(list)); +console.log( + new Intl.ListFormat("fr", { style: "long", type: "conjunction" }).format( + list, + ), +); // > Moto, Bus et Car -console.log(new Intl.ListFormat('fr', { style: 'short', type: 'disjunction' }).format(list)); +console.log( + new Intl.ListFormat("fr", { style: "short", type: "disjunction" }).format( + list, + ), +); // > Moto, Bus ou Car -console.log(new Intl.ListFormat('fr', { style: 'narrow', type: 'unit' }).format(list)); +console.log( + new Intl.ListFormat("fr", { style: "narrow", type: "unit" }).format(list), +); // > Moto Bus Car ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/listformat/resolvedoptions/index.md b/files/fr/web/javascript/reference/global_objects/intl/listformat/resolvedoptions/index.md index d8d7b3d3194323..6f53776d17f518 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/listformat/resolvedoptions/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/listformat/resolvedoptions/index.md @@ -11,7 +11,7 @@ La méthode **`Intl.ListFormat.prototype.resolvedOptions()`** renvoie un nouvel ## Syntaxe ```js -listFormat.resolvedOptions() +listFormat.resolvedOptions(); ``` ### Valeur de retour @@ -36,8 +36,8 @@ const deListFormatter = new Intl.ListFormat("de-DE", { style: "short" }); const usedOptions = de.resolvedOptions(); console.log(usedOptions.locale); // "de-DE" -console.log(usedOptions.style); // "short" -console.log(usedOptions.type); // "conjunction" (la valeur par défaut) +console.log(usedOptions.style); // "short" +console.log(usedOptions.type); // "conjunction" (la valeur par défaut) ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/intl/listformat/supportedlocalesof/index.md b/files/fr/web/javascript/reference/global_objects/intl/listformat/supportedlocalesof/index.md index 1b414e459f6b9b..770b76a3599621 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/listformat/supportedlocalesof/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/listformat/supportedlocalesof/index.md @@ -40,9 +40,9 @@ Cette méthode renvoie un tableau qui est un sous-ensemble des balises de locale Si on dispose d'un environnement (un navigateur par exemple) qui supporte le formatage des listes dans les locales indonésienne, allemande mais pas balinaise, `supportedLocalesOf` renvoie les balises pour l'indonésien et l'allemand quand bien même le formatage des listes pinyin n'est pas utilisée avec l'indonésien et qu'il n'existe pas une version spécifique de l'allemand pour l'Indonésie. On illustre ici l'algorithme `"lookup"`. SI on utilisait `"best fit"` pour trouver les locales correspondantes, on aurait pu avoir une balise supplémentaire pour le balinais en plus car la plupart des balinais comprennent l'indonésien. ```js -const locales = ['ban', 'id-u-co-pinyin', 'de-ID']; -const options = { localeMatcher: 'lookup' }; -console.log(Intl.ListFormat.supportedLocalesOf(locales, options).join(', ')); +const locales = ["ban", "id-u-co-pinyin", "de-ID"]; +const options = { localeMatcher: "lookup" }; +console.log(Intl.ListFormat.supportedLocalesOf(locales, options).join(", ")); // → "id-u-co-pinyin, de-ID" ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/locale/basename/index.md b/files/fr/web/javascript/reference/global_objects/intl/locale/basename/index.md index 2c1b1f6bca4219..8688cf3cb427a2 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/locale/basename/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/locale/basename/index.md @@ -41,7 +41,7 @@ console.log(japan.baseName); // Prints out "ja-JP" // Input string indicates language as Dutch and region as Belgium, // but options object overrides the region and sets it to the Netherlands -let dutch = new Intl.Locale("nl-Latn-BE", {region: "NL"}); +let dutch = new Intl.Locale("nl-Latn-BE", { region: "NL" }); console.log(dutch.baseName); // Prints out "nl-Latn-NL" ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/locale/calendar/index.md b/files/fr/web/javascript/reference/global_objects/intl/locale/calendar/index.md index 44807366372266..3ef24740c97464 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/locale/calendar/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/locale/calendar/index.md @@ -142,7 +142,7 @@ console.log(frBuddhist.calendar); // affiche "buddhist" dans la console Le constructeur {{jsxref("Locale", "Intl.Locale")}} peut utiliser un argument optionnel qui est un objet permettant de configurer la locale via différentes extensions dont les calendriers. En utilisant la propriété `calendar` de cet objet, on définit le calendrier qui sera utilisé : ```js -let frBuddhist = new Intl.Locale("fr-FR", {calendar: "buddhist"}); +let frBuddhist = new Intl.Locale("fr-FR", { calendar: "buddhist" }); console.log(frBuddhist.calendar); // affiche "buddhist" dans la console ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/locale/casefirst/index.md b/files/fr/web/javascript/reference/global_objects/intl/locale/casefirst/index.md index acced63ee259e8..fbfd867816369d 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/locale/casefirst/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/locale/casefirst/index.md @@ -38,7 +38,7 @@ console.log(caseFirstStr.caseFirst); // Prints "upper" Le constructeur [`Intl.Locale`](/fr/docs/Web/JavaScript/Reference/Objets_globaux/Locale) permet d'utiliser un objet de configuration comme deuxième argument. Les propriétés de cet objet seront autant d'extensions Unicode à utiliser pour la locale. Ici, on peut utiliser un objet avec la propriété `caseFirst` pour indiquer l'impact de la casse sur la collation de cette locale : ```js -let caseFirstObj= new Intl.Locale("en-Latn-US", {caseFirst: "lower"}); +let caseFirstObj = new Intl.Locale("en-Latn-US", { caseFirst: "lower" }); console.log(us12hour.caseFirst); // affichera "lower" dans la console. ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/locale/collation/index.md b/files/fr/web/javascript/reference/global_objects/intl/locale/collation/index.md index 0cf9f45758fe73..4907947c4850a8 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/locale/collation/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/locale/collation/index.md @@ -157,7 +157,7 @@ console.log(stringColl.collation); // Affichera "emoji" dans la console Le constructeur [`Intl.Locale`](/fr/docs/Web/JavaScript/Reference/Objets_globaux/Locale) possède un deuxième argument optionnel qui est un objet de configuration. Chaque propriété de cet objet pourra permettre de préciser une extension à la locale, y compris un type de collation. Pour définir le type de collation, on pourra utiliser une propriété `collation` sur cet objet avec une des valeurs indiquées ci-avant : ```js -let configColl = new Intl.Locale("en-Latn-US", {collation: "emoji"}); +let configColl = new Intl.Locale("en-Latn-US", { collation: "emoji" }); console.log(configColl.collation); // Affichera "emoji" dans la console ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/locale/getweekinfo/index.md b/files/fr/web/javascript/reference/global_objects/intl/locale/getweekinfo/index.md index 4e1f4a8e53da09..2f1dd59d63b4e0 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/locale/getweekinfo/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/locale/getweekinfo/index.md @@ -23,10 +23,10 @@ let af = new Intl.Locale("af"); console.log(af.weekInfo); // affiche {firstDay: 7, weekend: [6, 7], minimalDays: 1} let enGB = new Intl.Locale("en-GB"); -console.log(enGB.weekInfo) // affiche {firstDay: 1, weekend: [6, 7], minimalDays: 4} +console.log(enGB.weekInfo); // affiche {firstDay: 1, weekend: [6, 7], minimalDays: 4} let msBN = new Intl.Locale("en-GB"); -console.log(msBN.weekInfo) // affiche {firstDay: 7, weekend: [5, 7], minimalDays: 1} +console.log(msBN.weekInfo); // affiche {firstDay: 7, weekend: [5, 7], minimalDays: 1} // Le week-end à Brunei est sur vendredi et dimanche mais pas sur samedi ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/locale/language/index.md b/files/fr/web/javascript/reference/global_objects/intl/locale/language/index.md index af5133b8c1ea6e..8cc145eac462d2 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/locale/language/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/locale/language/index.md @@ -29,7 +29,7 @@ console.log(langStr.language); // Affichera "en" dans la console Bien que la composante de la langue doive être indiquée dans le premier paramètre, le constructeur {{jsxref("Locale", "Locale")}} prend comme deuxième argument un objet de configuration qui permet de surcharger cette composante. ```js -let langObj = new Intl.Locale("en-Latn-US", {language: "es"}); +let langObj = new Intl.Locale("en-Latn-US", { language: "es" }); console.log(langObj.language); // Affichera "es" dans la console ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/locale/locale/index.md b/files/fr/web/javascript/reference/global_objects/intl/locale/locale/index.md index af3fe249444995..5122bcd0cd17d0 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/locale/locale/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/locale/locale/index.md @@ -12,8 +12,8 @@ Le constructeur **`Intl.Locale`** est une propriété native de l'objet `Intl` q ## Syntaxe ```js -new Intl.Locale(tag) -new Intl.Locale(tag, options) +new Intl.Locale(tag); +new Intl.Locale(tag, options); ``` ### Paramètres @@ -30,7 +30,7 @@ new Intl.Locale(tag, options) Sous sa forme la plus simple, le constructeur [`Intl.Locale`] prend comme argument une chaîne de caractères représentant un identifiant de locale : ```js -let us = new Intl.Locale('en-US'); +let us = new Intl.Locale("en-US"); ``` ### Utiliser le constructeur Locale avec un objet options diff --git a/files/fr/web/javascript/reference/global_objects/intl/locale/maximize/index.md b/files/fr/web/javascript/reference/global_objects/intl/locale/maximize/index.md index d444276766911f..a7ad4989432ef4 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/locale/maximize/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/locale/maximize/index.md @@ -13,7 +13,7 @@ La méthode **`Intl.Locale.prototype.maximize()`** permet d'obtenir les valeurs ## Syntaxe ```js -locale.maximize() +locale.maximize(); ``` ### Valeur de retour @@ -27,7 +27,7 @@ Il est parfois utile d'identifier les composantes les plus probables d'une local ## Exemples ```js -let maLocale = new Intl.Locale("fr", {hourCycle: "h24", calendar: "gregory"}); +let maLocale = new Intl.Locale("fr", { hourCycle: "h24", calendar: "gregory" }); console.log(maLocale.baseName); // Affiche "fr" console.log(maLocale.toString()); // Affiche "fr-u-ca-gregory-hc-h24" let maLocMaximized = maLocale.maximize(); @@ -38,7 +38,7 @@ console.log(maLocMaximized.baseName); // Affiche "fr-Latn-FR-u-ca-gregory-hc-h24". // On notera que les extensions (après "-u") restent inchangées. -console.log(myLocMaximized.toString()); +console.log(myLocMaximized.toString()); ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/intl/locale/minimize/index.md b/files/fr/web/javascript/reference/global_objects/intl/locale/minimize/index.md index 28e512dd8e0149..54755b0c786048 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/locale/minimize/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/locale/minimize/index.md @@ -13,7 +13,7 @@ La méthode **`Intl.Locale.prototype.minimize()`** tente de retirer les informat ## Syntaxe ```js -locale.minimize() +locale.minimize(); ``` ### Valeur de retour @@ -29,7 +29,10 @@ Cette méthode effectue l'opération inverse de {{jsxref("Locale/maximize", "max ## Exemples ```js -let maLocale = new Intl.Locale("fr-Latn-FR", {hourCycle: "h24", calendar: "gregory"}); +let maLocale = new Intl.Locale("fr-Latn-FR", { + hourCycle: "h24", + calendar: "gregory", +}); console.log(maLocale.baseName); // Affiche "fr-Latn-FR" console.log(maLocale.toString()); // Affiche "fr-Latn-FR-u-ca-gregory-hc-h24" let maLocMinimized = maLocale.minimize(); diff --git a/files/fr/web/javascript/reference/global_objects/intl/locale/numberingsystem/index.md b/files/fr/web/javascript/reference/global_objects/intl/locale/numberingsystem/index.md index 6fb597a3b14097..68bce3f91a6d54 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/locale/numberingsystem/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/locale/numberingsystem/index.md @@ -120,7 +120,9 @@ console.log(numberingSystemStr.numberingSystem); Le constructeur [`Intl.Locale`](/fr/docs/Web/JavaScript/Reference/Objets_globaux/Locale) possède un deuxième argument, optionnel, qui est un objet permettant de configurer la locale. Les propriétés de cet objet sont utilisées comme extensions pour la locale ; les clés des propriétés sont les noms des extensions et leurs valeurs sont celles utilisées pour chaque extension. On peut donc utiliser la propriété `numberingSystem` sur cet objet afin de définir le système de numération à utiliser pour cette locale. ```js -let numberingSystemViaObj= new Intl.Locale("en-Latn-US", {numberingSystem: "latn"}); +let numberingSystemViaObj = new Intl.Locale("en-Latn-US", { + numberingSystem: "latn", +}); console.log(us12hour.numberingSystem); // affichera "latn" dans la console ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/locale/numeric/index.md b/files/fr/web/javascript/reference/global_objects/intl/locale/numeric/index.md index 6b94d3b5c4328a..1af3d883baa92b 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/locale/numeric/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/locale/numeric/index.md @@ -29,7 +29,7 @@ console.log(numericStr.numeric); Le constructeur [`Intl.Locale`](/fr/docs/Web/JavaScript/Reference/Objets_globaux/Locale) possède un deuxième argument, optionnel, qui est un objet permettant de configurer la locale. Les propriétés de cet objet sont utilisées comme extensions pour la locale ; les clés des propriétés sont les noms des extensions et leurs valeurs sont celles utilisées pour chaque extension. On peut donc utiliser la propriété `numeric` sur cet objet afin de définir le système de numération à utiliser pour cette locale. ```js -let numericViaObj= new Intl.Locale("en-Latn-US", {numeric: true}); +let numericViaObj = new Intl.Locale("en-Latn-US", { numeric: true }); console.log(us12hour.numeric); // Affichera "true" dans la console ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/locale/region/index.md b/files/fr/web/javascript/reference/global_objects/intl/locale/region/index.md index dec2c5b759b3fa..8f0682014e360e 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/locale/region/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/locale/region/index.md @@ -30,7 +30,7 @@ console.log(regionStr.region); Le constructeur {{jsxref("Locale", "Locale")}} prend comme second argument un objet de paramétrage dont chacune des propriétés permet de définir une extension ou une composante de la locale. ```js -let regionObj = new Intl.Locale("fr-Latn", {region: "FR"}); +let regionObj = new Intl.Locale("fr-Latn", { region: "FR" }); console.log(regionObj.region); // Affichera "FR" dans la console diff --git a/files/fr/web/javascript/reference/global_objects/intl/locale/script/index.md b/files/fr/web/javascript/reference/global_objects/intl/locale/script/index.md index e979bee921d83d..3e0e0724c2e860 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/locale/script/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/locale/script/index.md @@ -29,7 +29,7 @@ console.log(scriptStr.script); // Affichera "Latn" dans la console Le constructeur {{jsxref("Locale", "Locale")}} permet d'utiliser un objet de configuration dont les propriétés définiront les caractéristiques de la locale : ```js -let scriptObj = new Intl.Locale("fr-FR", {script: "Latn"}); +let scriptObj = new Intl.Locale("fr-FR", { script: "Latn" }); console.log(scriptObj.script); // Affichera "Latn" dans la console ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/locale/tostring/index.md b/files/fr/web/javascript/reference/global_objects/intl/locale/tostring/index.md index 758f86d867add8..f95d360b4a10ea 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/locale/tostring/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/locale/tostring/index.md @@ -13,7 +13,7 @@ La méthode **`Intl.Locale.prototype.toString()`** renvoie [l'identifiant de loc ## Syntaxe ```js -locale.toString() +locale.toString(); ``` ### Valeur de retour @@ -27,7 +27,10 @@ Une instance de `Locale` est une représentation JavaScript d'une locale au sens ## Exemples ```js -let maLocale = new Intl.Locale("fr-Latn-FR", {hourCycle: "h24", calendar: "gregory"}); +let maLocale = new Intl.Locale("fr-Latn-FR", { + hourCycle: "h24", + calendar: "gregory", +}); console.log(maLocale.baseName); // Affiche "fr-Latn-FR" console.log(maLocale.toString()); // Affiche "fr-Latn-FR-u-ca-gregory-hc-h24" ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/numberformat/format/index.md b/files/fr/web/javascript/reference/global_objects/intl/numberformat/format/index.md index 61bd3c8a706c6e..59da65516759c0 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/numberformat/format/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/numberformat/format/index.md @@ -13,7 +13,7 @@ La méthode **`Intl.NumberFormat.prototype.format()`** formate un nombre en fonc ## Syntaxe ```js -numberFormat.format(nombre) +numberFormat.format(nombre); ``` ### Paramètres @@ -32,7 +32,7 @@ La fonction d'accesseur `format` permet de formater un nombre donné en une cha On peut utiliser la fonction renvoyée par `format` pour formater une valeur monétaire selon la locale russe : ```js -var options = {style: "currency", currency: "RUB"}; +var options = { style: "currency", currency: "RUB" }; var numberFormat = new Intl.NumberFormat("ru-RU", options); console.log(numberFormat.format(654321.987)); // → "654 321,99 руб." diff --git a/files/fr/web/javascript/reference/global_objects/intl/numberformat/formatrange/index.md b/files/fr/web/javascript/reference/global_objects/intl/numberformat/formatrange/index.md index 75f1db7b599f48..7f35b19e7d6922 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/numberformat/formatrange/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/numberformat/formatrange/index.md @@ -11,12 +11,13 @@ La méthode **`Intl.NumberFormat.prototype.formatRange()`** formate un intervall ## Syntaxe ```js -formatRange(debutIntervalle, finIntervalle) +formatRange(debutIntervalle, finIntervalle); ``` ### Paramètres - `debutIntervalle` + - : Une valeur numérique [`Number`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Number) ou [`BigInt`](/fr/docs/Web/JavaScript/Reference/Global_Objects/BigInt). - `finIntervalle` diff --git a/files/fr/web/javascript/reference/global_objects/intl/numberformat/formatrangetoparts/index.md b/files/fr/web/javascript/reference/global_objects/intl/numberformat/formatrangetoparts/index.md index ecb1ada46b01b1..7ea3a28c3c6836 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/numberformat/formatrangetoparts/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/numberformat/formatrangetoparts/index.md @@ -11,13 +11,14 @@ La méthode **`Intl.Numberformat.prototype.formatRangeToParts()`** permet de for ## Syntaxe ```js -formatRangeToParts() -formatRangeToParts(debutIntervalle, finIntervalle) +formatRangeToParts(); +formatRangeToParts(debutIntervalle, finIntervalle); ``` ### Paramètres - `debutIntervalle` + - : Une valeur numérique [`Number`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Number) ou [`BigInt`](/fr/docs/Web/JavaScript/Reference/Global_Objects/BigInt). - `finIntervalle` @@ -37,9 +38,8 @@ La méthode `formatRangeToParts()` est utile lorsqu'on souhaite construire des c { type: "literal", value: "-", source: "shared" }, { type: "integer", value: "5", source: "endRange" }, { type: "literal", value: " ", source: "shared" }, - { type: "currency", value: "€", source: "shared" } -] - + { type: "currency", value: "€", source: "shared" }, +]; ``` Les types de valeur possibles pour les fragments sont : @@ -79,12 +79,12 @@ Les types de valeur possibles pour les fragments sont : const debutIntervalle = 3500; const finIntervalle = 9500; -const formateur = new Intl.NumberFormat('de-DE', { - style: 'currency', - currency: 'EUR' +const formateur = new Intl.NumberFormat("de-DE", { + style: "currency", + currency: "EUR", }); -formateur.formatRange(debutIntervalle, finIntervalle) +formateur.formatRange(debutIntervalle, finIntervalle); // "3.500,00–9.500,00 €" ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/numberformat/formattoparts/index.md b/files/fr/web/javascript/reference/global_objects/intl/numberformat/formattoparts/index.md index 69c8f8cc3f0570..b598a9b4188b9a 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/numberformat/formattoparts/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/numberformat/formattoparts/index.md @@ -11,7 +11,7 @@ La méthode **`Intl.Numberformat.prototype.formatToParts()`** permet de produire ## Syntaxe ```js -Intl.NumberFormat.prototype.formatToParts(nombre) +Intl.NumberFormat.prototype.formatToParts(nombre); ``` ### Paramètres @@ -38,7 +38,7 @@ La méthode `formatToParts()` est peut être utilisée lorsqu'on met en forme de Les valeurs possibles pour l'attribut `type` sont : - `currency` - - : Le suffixe associé à la devise. Ce peut être le symbole "$", "€" ou bien le nom de la devise "Dollar", "Euro" selon la façon dont `currencyDisplay` est indiquée. + - : Le suffixe associé à la devise. Ce peut être le symbole "$", "€" ou bien le nom de la devise "Dollar", "Euro" selon la façon dont `currencyDisplay` est indiquée. - `decimal` - : Le séparateur décimal utilisé ("."). - `fraction` @@ -67,9 +67,9 @@ Les valeurs possibles pour l'attribut `type` sont : ```js var number = 3500; -var formatter = new Intl.NumberFormat('de-DE', { - style: 'currency', - currency: 'EUR' +var formatter = new Intl.NumberFormat("de-DE", { + style: "currency", + currency: "EUR", }); formatter.format(number); @@ -96,12 +96,17 @@ formatter.formatToParts(number); Maintenant que la chaîne est décomposée, on peut la réassembler d'une façon spécifique. On peut, par exemple utiliser {{jsxref("Array.prototype.map()")}}, [une fonction fléchée](/fr/docs/Web/JavaScript/Reference/Fonctions/Fonctions_fléchées), une [instruction `switch`](/fr/docs/Web/JavaScript/Reference/Instructions/switch), [des littéraux de gabarits](/fr/docs/Web/JavaScript/Reference/Littéraux_gabarits) et {{jsxref("Array.prototype.reduce()")}}. ```js -var numberString = formatter.formatToParts(number).map(({type, value}) => { - switch (type) { - case 'currency': return `${value}`; - default : return value; - } -}).reduce((string, part) => string + part); +var numberString = formatter + .formatToParts(number) + .map(({ type, value }) => { + switch (type) { + case "currency": + return `${value}`; + default: + return value; + } + }) + .reduce((string, part) => string + part); ``` Grâce à cette fonction, on pourra mettre en gras le suffixe associé à la devise : diff --git a/files/fr/web/javascript/reference/global_objects/intl/numberformat/index.md b/files/fr/web/javascript/reference/global_objects/intl/numberformat/index.md index 35bd3b1a841a7e..6b112b759dcef3 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/numberformat/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/numberformat/index.md @@ -87,32 +87,48 @@ Les résultats fournis peuvent être paramétrés grâce à l'argument `options` var nombre = 123456.789; // on affiche une devise avec le style "currency" -console.log(new Intl.NumberFormat("de-DE", {style: "currency", currency: "EUR"}).format(nombre)); +console.log( + new Intl.NumberFormat("de-DE", { style: "currency", currency: "EUR" }).format( + nombre, + ), +); // → 123.456,79 € // Le yen japonais n'a pas de centimes -console.log(new Intl.NumberFormat("ja-JP", {style: "currency", currency: "JPY"}).format(nombre)) +console.log( + new Intl.NumberFormat("ja-JP", { style: "currency", currency: "JPY" }).format( + nombre, + ), +); // → ¥123,457 // On se limite ici à trois chiffres significatifs -console.log(new Intl.NumberFormat("en-IN", {maximumSignificantDigits: 3}).format(nombre)); +console.log( + new Intl.NumberFormat("en-IN", { maximumSignificantDigits: 3 }).format( + nombre, + ), +); // → 1,23,000 ``` ### Utiliser les options `style` et `unit` ```js -console.log(new Intl.NumberFormat('pt-PT', { - style: 'unit', - unit: 'kilometer-per-hour' -}).format(50)); +console.log( + new Intl.NumberFormat("pt-PT", { + style: "unit", + unit: "kilometer-per-hour", + }).format(50), +); // → 50 km/h -console.log((16).toLocaleString('en-GB', { - style: 'unit', - unit: 'liter', - unitDisplay: 'long' -})); +console.log( + (16).toLocaleString("en-GB", { + style: "unit", + unit: "liter", + unitDisplay: "long", + }), +); // → 16 litres ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/numberformat/numberformat/index.md b/files/fr/web/javascript/reference/global_objects/intl/numberformat/numberformat/index.md index ce68acef374240..686fa81bc3b1e3 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/numberformat/numberformat/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/numberformat/numberformat/index.md @@ -12,9 +12,9 @@ Le constructeur **`Intl.NumberFormat()`** permet de créer des objets [`Intl.Num ## Syntaxe ```js -new Intl.NumberFormat() -new Intl.NumberFormat(locales) -new Intl.NumberFormat(locales, options) +new Intl.NumberFormat(); +new Intl.NumberFormat(locales); +new Intl.NumberFormat(locales, options); ``` ### Paramètres @@ -120,9 +120,9 @@ console.log(new Intl.NumberFormat().format(amount)); ```js let amount = 3500; -new Intl.NumberFormat('en-US', {style: 'decimal'}).format(amount); +new Intl.NumberFormat("en-US", { style: "decimal" }).format(amount); // → '3,500' -new Intl.NumberFormat('fr', {style: 'percent'}).format(amount); +new Intl.NumberFormat("fr", { style: "percent" }).format(amount); // → '350 000 %' ``` @@ -133,10 +133,14 @@ Si l'option `style` vaut `'unit'`, une propriété `unit` doit être fournie. Le ```js let amount = 3500; -new Intl.NumberFormat('en-US', {style: 'unit', unit: 'liter'}).format(amount); +new Intl.NumberFormat("en-US", { style: "unit", unit: "liter" }).format(amount); // → '3,500 L' -new Intl.NumberFormat('fr', {style: 'unit', unit: 'liter', unitDisplay: 'long'}).format(amount); +new Intl.NumberFormat("fr", { + style: "unit", + unit: "liter", + unitDisplay: "long", +}).format(amount); // → '3 500 litres' ``` @@ -146,20 +150,22 @@ Si l'option `style` vaut `'currency'`, une propriété `currency` doit être fou ```js let amount = -3500; -new Intl.NumberFormat('en-US', {style: 'currency', currency: 'USD'}).format(amount); +new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }).format( + amount, +); // → '-$3,500.00' -new Intl.NumberFormat('bn', { - style: 'currency', - currency: 'USD', - currencyDisplay: 'name' +new Intl.NumberFormat("bn", { + style: "currency", + currency: "USD", + currencyDisplay: "name", }).format(amount); // → '-3,500.00 US dollars' -new Intl.NumberFormat('fr', { - style: 'currency', - currency: 'EUR', - currencySign: 'accounting' +new Intl.NumberFormat("fr", { + style: "currency", + currency: "EUR", + currencySign: "accounting", }).format(amount); // → "(3 500,00 €)" ``` @@ -169,30 +175,30 @@ new Intl.NumberFormat('fr', { Ces notations sont portées par l'option `notation` et peuvent être formatées ainsi : ```js -new Intl.NumberFormat('en-US', { notation: "scientific" }).format(987654321); +new Intl.NumberFormat("en-US", { notation: "scientific" }).format(987654321); // → 9.877E8 -new Intl.NumberFormat('pt-PT', { notation: "scientific" }).format(987654321); +new Intl.NumberFormat("pt-PT", { notation: "scientific" }).format(987654321); // → 9,877E8 -new Intl.NumberFormat('en-GB', { notation: "engineering" }).format(987654321); +new Intl.NumberFormat("en-GB", { notation: "engineering" }).format(987654321); // → 987.654E6 -new Intl.NumberFormat('de', { notation: "engineering" }).format(987654321); +new Intl.NumberFormat("de", { notation: "engineering" }).format(987654321); // → 987,654E6 -new Intl.NumberFormat('zh-CN', { notation: "compact" }).format(987654321); +new Intl.NumberFormat("zh-CN", { notation: "compact" }).format(987654321); // → 9.9亿 -new Intl.NumberFormat('fr', { +new Intl.NumberFormat("fr", { notation: "compact", - compactDisplay: "long" + compactDisplay: "long", }).format(987654321); // → 988 millions -new Intl.NumberFormat('en-GB', { +new Intl.NumberFormat("en-GB", { notation: "compact", - compactDisplay: "short" + compactDisplay: "short", }).format(987654321); // → 988M ``` @@ -203,8 +209,8 @@ Dans l'exemple qui suit, on affiche toujours le signe sauf si la valeur est zér ```js new Intl.NumberFormat("en-US", { - style: "percent", - signDisplay: "exceptZero" + style: "percent", + signDisplay: "exceptZero", }).format(0.55); // → '+55%' ``` @@ -212,11 +218,11 @@ new Intl.NumberFormat("en-US", { On notera que lorsque le style porte sur les devises et que le style de signe vaut "`accounting`", des parenthèses pourront être utilisées plutôt qu'un signe moins : ```js -new Intl.NumberFormat('bn', { - style: 'currency', - currency: 'USD', - currencySign: 'accounting', - signDisplay: 'always' +new Intl.NumberFormat("bn", { + style: "currency", + currency: "USD", + currencySign: "accounting", + signDisplay: "always", }).format(-3500); // → '($3,500.00)' diff --git a/files/fr/web/javascript/reference/global_objects/intl/numberformat/resolvedoptions/index.md b/files/fr/web/javascript/reference/global_objects/intl/numberformat/resolvedoptions/index.md index d0c2f8c9487eb5..2d08316eb1b215 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/numberformat/resolvedoptions/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/numberformat/resolvedoptions/index.md @@ -13,7 +13,7 @@ La méthode **`Intl.NumberFormat.prototype.resolvedOptions()`** renvoie un nouve ## Syntaxe ```js -numberFormat.resolvedOptions() +numberFormat.resolvedOptions(); ``` ### Valeur de retour @@ -45,16 +45,16 @@ Un seul des deux groupes suivants est inclus dans les propriétés : ### Utiliser la méthode `resolvedOptions()` ```js -var de = new Intl.NumberFormat('de-DE'); +var de = new Intl.NumberFormat("de-DE"); var usedOptions = de.resolvedOptions(); -usedOptions.locale; // "de-DE" -usedOptions.numberingSystem; // "latn" -usedOption.style; // "decimal" -usedOptions.minimumIntegerDigits; // 1 +usedOptions.locale; // "de-DE" +usedOptions.numberingSystem; // "latn" +usedOption.style; // "decimal" +usedOptions.minimumIntegerDigits; // 1 usedOptions.minimumFractionDigits; // 0 usedOptions.maximumFractionDigits; // 3 -usedOptions.useGrouping; // true +usedOptions.useGrouping; // true ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/intl/numberformat/supportedlocalesof/index.md b/files/fr/web/javascript/reference/global_objects/intl/numberformat/supportedlocalesof/index.md index 86b376f500481c..be22a83b3fb2d2 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/numberformat/supportedlocalesof/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/numberformat/supportedlocalesof/index.md @@ -43,7 +43,7 @@ Si on dispose d'un environnement qui supporte les locales indonésienne et allem ```js var locales = ["ban", "id-u-co-pinyin", "de-ID"]; -var options = {localeMatcher: "lookup"}; +var options = { localeMatcher: "lookup" }; console.log(Intl.NumberFormat.supportedLocalesOf(locales, options).join(", ")); // → "id-u-co-pinyin, de-ID" ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/pluralrules/index.md b/files/fr/web/javascript/reference/global_objects/intl/pluralrules/index.md index 31bddf964d5ff3..f15d5dcae7dd19 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/pluralrules/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/pluralrules/index.md @@ -37,15 +37,15 @@ Dans cet exemple, on voit l'impact de la locale sur les règles de nombre. Afin // L'arabe possède plusieurs règles // de nombre -new Intl.PluralRules('ar-EG').select(0); +new Intl.PluralRules("ar-EG").select(0); // → 'zero' -new Intl.PluralRules('ar-EG').select(1); +new Intl.PluralRules("ar-EG").select(1); // → 'one' -new Intl.PluralRules('ar-EG').select(2); +new Intl.PluralRules("ar-EG").select(2); // → 'two' -new Intl.PluralRules('ar-EG').select(6); +new Intl.PluralRules("ar-EG").select(6); // → 'few' -new Intl.PluralRules('ar-EG').select(18); +new Intl.PluralRules("ar-EG").select(18); // → 'many' ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/pluralrules/pluralrules/index.md b/files/fr/web/javascript/reference/global_objects/intl/pluralrules/pluralrules/index.md index b4f19846d6113c..cab7711aca42eb 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/pluralrules/pluralrules/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/pluralrules/pluralrules/index.md @@ -10,9 +10,9 @@ Le constructeur **`Intl.PluralRules()`** permet de créer des objets [`Intl.Plur ## Syntaxe ```js -new Intl.PluralRules() -new Intl.PluralRules(locales) -new Intl.PluralRules(locales, options) +new Intl.PluralRules(); +new Intl.PluralRules(locales); +new Intl.PluralRules(locales, options); ``` ### Parameters @@ -66,13 +66,13 @@ pr.select(2); Les résultats peuvent être personnalisés avec l'argument `options` qui possède une propriété `type` qu'on peut fixer à `ordinal`. Cela s'avère utile pour déterminer l'indicateur ordinal (par exemple en anglais où il y a des variations entre "1st", "2nd", "3rd", "4th", "42nd" et ainsi de suite). ```js -var pr = new Intl.PluralRules('en-US', { type: 'ordinal' }); +var pr = new Intl.PluralRules("en-US", { type: "ordinal" }); const suffixes = new Map([ - ['one', 'st'], - ['two', 'nd'], - ['few', 'rd'], - ['other', 'th'], + ["one", "st"], + ["two", "nd"], + ["few", "rd"], + ["other", "th"], ]); const formatOrdinals = (n) => { const rule = pr.select(n); @@ -80,14 +80,14 @@ const formatOrdinals = (n) => { return `${n}${suffix}`; }; -formatOrdinals(0); // '0th' -formatOrdinals(1); // '1st' -formatOrdinals(2); // '2nd' -formatOrdinals(3); // '3rd' -formatOrdinals(4); // '4th' -formatOrdinals(11); // '11th' -formatOrdinals(21); // '21st' -formatOrdinals(42); // '42nd' +formatOrdinals(0); // '0th' +formatOrdinals(1); // '1st' +formatOrdinals(2); // '2nd' +formatOrdinals(3); // '3rd' +formatOrdinals(4); // '4th' +formatOrdinals(11); // '11th' +formatOrdinals(21); // '21st' +formatOrdinals(42); // '42nd' formatOrdinals(103); // '103rd' ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/pluralrules/resolvedoptions/index.md b/files/fr/web/javascript/reference/global_objects/intl/pluralrules/resolvedoptions/index.md index 7d62e1a57c469b..b0f7d2375f2132 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/pluralrules/resolvedoptions/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/pluralrules/resolvedoptions/index.md @@ -11,7 +11,7 @@ La méthode **`Intl.PluralRules.prototype.resolvedOptions()`** renvoie un nouvel ## Syntaxe ```js -pluralRule.resolvedOptions() +pluralRule.resolvedOptions(); ``` ### Valeur de retour @@ -41,15 +41,15 @@ Seul l'un de ces deux groupes de propriétés est inclus : ### Utiliser `resolvedOptions()` ```js -var de = new Intl.PluralRules('de-DE'); +var de = new Intl.PluralRules("de-DE"); var usedOptions = de.resolvedOptions(); -usedOptions.locale; // "de-DE" +usedOptions.locale; // "de-DE" usedOptions.maximumFractionDigits; // 3 usedOptions.minimumFractionDigits; // 0 -usedOptions.minimumIntegerDigits; // 1 -usedOptions.pluralCategories; // Array [ "one", "other" ] -usedOptions.type; // "cardinal" +usedOptions.minimumIntegerDigits; // 1 +usedOptions.pluralCategories; // Array [ "one", "other" ] +usedOptions.type; // "cardinal" ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/intl/pluralrules/select/index.md b/files/fr/web/javascript/reference/global_objects/intl/pluralrules/select/index.md index 6f129efb1cde65..dc446fdc64b5a4 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/pluralrules/select/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/pluralrules/select/index.md @@ -11,7 +11,7 @@ La méthode **`Intl.PluralRules.prototype.select`** renvoie une chaîne de carac ## Syntaxe ```js -pluralRule.select(nombre) +pluralRule.select(nombre); ``` ### Paramètres @@ -26,19 +26,19 @@ Cette fonction permet de sélectionner une règle de nombre en fonction de la lo ## Exemples ```js - new Intl.PluralRules('ar-EG').select(0); +new Intl.PluralRules("ar-EG").select(0); // → 'zero' -new Intl.PluralRules('ar-EG').select(1); +new Intl.PluralRules("ar-EG").select(1); // → 'one' -new Intl.PluralRules('ar-EG').select(2); +new Intl.PluralRules("ar-EG").select(2); // → 'two' -new Intl.PluralRules('ar-EG').select(6); +new Intl.PluralRules("ar-EG").select(6); // → 'few' -new Intl.PluralRules('ar-EG').select(18); +new Intl.PluralRules("ar-EG").select(18); // → 'many' ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/pluralrules/selectrange/index.md b/files/fr/web/javascript/reference/global_objects/intl/pluralrules/selectrange/index.md index d09a4e9ad1dbfa..e90352d2f7db67 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/pluralrules/selectrange/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/pluralrules/selectrange/index.md @@ -11,7 +11,7 @@ La méthode **`Intl.PluralRules.prototype.selectRange()`** reçoit deux valeurs ## Syntaxe ```js -selectRange(debutIntervalle, finIntervalle) +selectRange(debutIntervalle, finIntervalle); ``` ### Valeur de retour @@ -27,10 +27,10 @@ Cette fonction sélectionne une catégorie de nombre selon les options de locale ### Utiliser `selectRange()` ```js - new Intl.PluralRules('sl').selectRange(102, 201); +new Intl.PluralRules("sl").selectRange(102, 201); // → 'few' - new Intl.PluralRules('pt').selectRange(102, 102); +new Intl.PluralRules("pt").selectRange(102, 102); // → 'other' ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/pluralrules/supportedlocalesof/index.md b/files/fr/web/javascript/reference/global_objects/intl/pluralrules/supportedlocalesof/index.md index a924fb38f83a44..115f7ff07b447b 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/pluralrules/supportedlocalesof/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/pluralrules/supportedlocalesof/index.md @@ -38,9 +38,9 @@ Cette méthode renvoie un tableau contenant un sous-ensemble des balises de lang Dans l'hypothèse où on utilise un système prenant en charge l'indonésien, l'allemand mais pas le balinais pour le formatage avec les règles de nombre, `supportedLocalesOf` renvoie les balises de langue indonésienne et allemande inchangées bien que la collation `pinyin` ne soit pas pertinente ni utilisée avec l'indonésien (et qu'il est peu probable qu'une variante indonésienne pour l'allemand soit prise en charge). On notera que l'algorithme de correspondance `"lookup"` est utilisé ici. L'algorithme `"best fit"` aurait pu déterminer que l'indonésien aurait pu remplacer le balinais car la plupart des personnes parlant le balinais comprend également l'indonésien, la fonction aurait alors pu remplacer la balise de langue balinaise. ```js -var locales = ['ban', 'id-u-co-pinyin', 'de-ID']; -var options = { localeMatcher: 'lookup' }; -console.log(Intl.PluralRules.supportedLocalesOf(locales, options).join(', ')); +var locales = ["ban", "id-u-co-pinyin", "de-ID"]; +var options = { localeMatcher: "lookup" }; +console.log(Intl.PluralRules.supportedLocalesOf(locales, options).join(", ")); // → "id-u-co-pinyin, de-ID" ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/format/index.md b/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/format/index.md index 380840827698a3..be2df5d98fb2f1 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/format/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/format/index.md @@ -9,7 +9,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/ ## Syntaxe ```js -RelativeTimeFormat.format(valeur, unite) +RelativeTimeFormat.format(valeur, unite); ``` ### Paramètres @@ -34,9 +34,9 @@ L'exemple suivant illustre comment créer un outil de formatage pour les valeurs // les temps relatifs en anglais, avec les valeurs par défaut // utilisées explicitement. const rtf = new Intl.RelativeTimeFormat("en", { - localeMatcher: "best fit", // autre valeur possible : "lookup" - numeric: "always", // autre valeur possible : "auto" - style: "long", // autres valeurs possibles : "short" ou "narrow" + localeMatcher: "best fit", // autre valeur possible : "lookup" + numeric: "always", // autre valeur possible : "auto" + style: "long", // autres valeurs possibles : "short" ou "narrow" }); // Formatage d'une valeur relative négative. diff --git a/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/formattoparts/index.md b/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/formattoparts/index.md index 7ab944ca1ad6e5..61d4959507792d 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/formattoparts/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/formattoparts/index.md @@ -13,7 +13,7 @@ La méthode **`Intl.RelativeTimeFormat.prototype.formatToParts()`** est une mét ## Syntaxe ```js -RelativeTimeFormat.formatToParts(valeur, unite) +RelativeTimeFormat.formatToParts(valeur, unite); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/index.md b/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/index.md index d328bdd387baf8..2eb7fe1b2041b9 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/index.md @@ -39,9 +39,9 @@ L'exemple suivant illustre comment créer un formateur de temps relatif en angla // On crée un formateur en anglais en utilisant explicitement // les valeurs par défaut. const rtf = new Intl.RelativeTimeFormat("en", { - localeMatcher: "best fit", // autre valeur possible : "lookup" - numeric: "always", // autre valeur possible : "auto" - style: "long", // autre valeur possible : "short" ou "narrow" + localeMatcher: "best fit", // autre valeur possible : "lookup" + numeric: "always", // autre valeur possible : "auto" + style: "long", // autre valeur possible : "short" ou "narrow" }); // On formate un temps relatif avec une valeur négative (-1). diff --git a/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/relativetimeformat/index.md b/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/relativetimeformat/index.md index e9866a8ccf557b..8685d08a692895 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/relativetimeformat/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/relativetimeformat/index.md @@ -10,9 +10,9 @@ Le constructeur **`Intl.RelativeTimeFormat()`** permet de créer des objets [`In ## Syntaxe ```js -new Intl.RelativeTimeFormat() -new Intl.RelativeTimeFormat(locales) -new Intl.RelativeTimeFormat(locales, options) +new Intl.RelativeTimeFormat(); +new Intl.RelativeTimeFormat(locales); +new Intl.RelativeTimeFormat(locales, options); ``` ### Paramètres @@ -50,9 +50,9 @@ Dans l'exemple suivant, on crée un formateur de temps relatif utilisant la loca // On crée un formateur de temps relatif dans la locale // avec les valeurs par défaut passées explicitement. const rtf = new Intl.RelativeTimeFormat("fr", { - localeMatcher: "best fit", // autres valeurs possibles : "lookup" - numeric: "always", // autres valeurs possibles : "auto" - style: "long", // autres valeurs possibles : "short" ou "narrow" + localeMatcher: "best fit", // autres valeurs possibles : "lookup" + numeric: "always", // autres valeurs possibles : "auto" + style: "long", // autres valeurs possibles : "short" ou "narrow" }); // On formate un temps relatif un jour dans le passé. diff --git a/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/resolvedoptions/index.md b/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/resolvedoptions/index.md index e626ef9c7a9c30..31ac4b3452bbbd 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/resolvedoptions/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/resolvedoptions/index.md @@ -15,7 +15,7 @@ La méthode **`Intl.RelativeTimeFormat.prototype.resolvedOptions()`** renvoie un ## Syntaxe ```js -relativeTimeFormat.resolvedOptions() +relativeTimeFormat.resolvedOptions(); ``` ### Valeur de retour @@ -49,12 +49,12 @@ L'objet renvoyé par cette méthode possèdera les propriétés suivantes : ## Exemples ```js -var de = new Intl.RelativeTimeFormat('de-DE'); +var de = new Intl.RelativeTimeFormat("de-DE"); var usedOptions = de.resolvedOptions(); -usedOptions.locale; // "de-DE" -usedOptions.style; // "long" -usedOptions.numeric; // "always" +usedOptions.locale; // "de-DE" +usedOptions.style; // "long" +usedOptions.numeric; // "always" usedOptions.numberingSystem; // "latn" ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/supportedlocalesof/index.md b/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/supportedlocalesof/index.md index c50301cb26612f..b5907bcb333e2f 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/supportedlocalesof/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/relativetimeformat/supportedlocalesof/index.md @@ -44,7 +44,11 @@ Cette méthode renvoie un tableau qui est un sous-ensemble de `locales`. Les bal Si on dispose d'un environnement qui supporte les locales indonésienne et allemande mais pas balinaise pour le formatage des temps relatifs, `supportedLocalesOf` renverra les balises BCP 47 pour l'indonésien et l'allemand (bien que la collation pinyin ne soit pas pertinente pour les dates ni pour l'indonésien et qu'il soit peu probable qu'une variante indonésienne existe pour l'allemand). Pour l'exemple, on l'utilise l'algorithme `"lookup"`. Si on utilisait `"best fit"`, on pourrait considérer que l'indonésien est adéquat pour la locale balinaise (sachant que la plupart des balinais comprend l'indonésien) et donc également renvoyer la balise balinaise. ```js -var locales = ['ban', 'id-u-co-pinyin', 'de-ID'];var options = { localeMatcher: 'lookup' };console.log(Intl.RelativeTimeFormat.supportedLocalesOf(locales, options).join(', '));// → "id-u-co-pinyin, de-ID" +var locales = ["ban", "id-u-co-pinyin", "de-ID"]; +var options = { localeMatcher: "lookup" }; +console.log( + Intl.RelativeTimeFormat.supportedLocalesOf(locales, options).join(", "), +); // → "id-u-co-pinyin, de-ID" ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/intl/segmenter/index.md b/files/fr/web/javascript/reference/global_objects/intl/segmenter/index.md index 86d2e2ae77e2ab..cb765cf2666110 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/segmenter/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/segmenter/index.md @@ -34,16 +34,15 @@ L'objet **`Intl.Segmenter`** permet de segmenter un texte en tenant compte de la En utilisant [`String.prototype.split(" ")`](/fr/docs/Web/JavaScript/Reference/Global_Objects/String/split) pour segmenter un texte en mots, on n'obtient pas le bon résultat si la locale du texte n'utilise pas d'espace entre les mots (ce qui est le cas pour le japonais, le chinois, le thaïlandais, le laotien, le khmer, le birman, etc.). ```js example-bad -const str = '吾輩は猫である。名前はたぬき。'; -console.table(str.split(' ')); +const str = "吾輩は猫である。名前はたぬき。"; +console.table(str.split(" ")); // ['吾輩は猫である。名前はたぬき。'] // Les deux phrases ne sont pas segmentées correctement. - ``` ```js example-good -const str = '吾輩は猫である。名前はたぬき。'; -const segmenterJa = new Intl.Segmenter('ja-JP', { granularity: 'word' }); +const str = "吾輩は猫である。名前はたぬき。"; +const segmenterJa = new Intl.Segmenter("ja-JP", { granularity: "word" }); const segments = segmenterJa.segment(str); console.table(Array.from(segments)); diff --git a/files/fr/web/javascript/reference/global_objects/intl/segmenter/resolvedoptions/index.md b/files/fr/web/javascript/reference/global_objects/intl/segmenter/resolvedoptions/index.md index 0c84991e25d687..3af2dc21ecb807 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/segmenter/resolvedoptions/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/segmenter/resolvedoptions/index.md @@ -13,7 +13,7 @@ La méthode **`Intl.Segmenter.prototype.resolvedOptions()`** renvoie un nouvel o ## Syntaxe ```js -resolvedOptions() +resolvedOptions(); ``` ### Paramètres @@ -38,7 +38,7 @@ L'objet renvoyé par la méthode possède les propriétés suivantes : ### Utilisation simple ```js -const spanishSegmenter = new Intl.Segmenter('es', {granularity: 'sentence'}); +const spanishSegmenter = new Intl.Segmenter("es", { granularity: "sentence" }); const options = spanishSegmenter.resolvedOptions(); console.log(options.locale); // "es" console.log(options.granularity); // "sentence" @@ -47,7 +47,7 @@ console.log(options.granularity); // "sentence" ### Granularité par défaut ```js -const spanishSegmenter = new Intl.Segmenter('es'); +const spanishSegmenter = new Intl.Segmenter("es"); const options = spanishSegmenter.resolvedOptions(); console.log(options.locale); // "es" console.log(options.granularity); // "grapheme" @@ -56,11 +56,11 @@ console.log(options.granularity); // "grapheme" ### Locale de recours locale ```js -const banSegmenter = new Intl.Segmenter('ban'); +const banSegmenter = new Intl.Segmenter("ban"); const options = banSegmenter.resolvedOptions(); console.log(options.locale); // "fr" sur un environnement d'exécution où la locale -// balinaise n'est pas prise en charge et où le +// balinaise n'est pas prise en charge et où le // français est la locale par défaut console.log(options.granularity); // "grapheme" ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/segmenter/segment/index.md b/files/fr/web/javascript/reference/global_objects/intl/segmenter/segment/index.md index ca0045d3a4647b..e50bdf5c187f07 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/segmenter/segment/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/segmenter/segment/index.md @@ -13,7 +13,7 @@ La méthode **`Intl.Segmenter.prototype.segment()`** segmente une chaîne de car ## Syntaxe ```js -segment(input) +segment(input); ``` ### Paramètres @@ -29,7 +29,7 @@ Un nouvel objet itérable [`Segments`](/fr/docs/Web/JavaScript/Reference/Global_ ```js // On crée un segmenteur propre à une locale -const segmenter = new Intl.Segmenter('fr', {granularity: 'word'}); +const segmenter = new Intl.Segmenter("fr", { granularity: "word" }); // On l'utilise pour obtenir un itérateur sur les segments // d'une chaîne de caractères @@ -37,11 +37,13 @@ const input = "Moi ? N'est-ce pas ?"; const segments = segmenter.segment(input); // Et on parcourt cet ensemble -for (const {segment, index, isWordLike} of segments) { - console.log('segment situé aux unités [%d, %d]: «%s»%s', - index, index + segment.length, +for (const { segment, index, isWordLike } of segments) { + console.log( + "segment situé aux unités [%d, %d]: «%s»%s", + index, + index + segment.length, segment, - isWordLike ? ' (type mot)' : '' + isWordLike ? " (type mot)" : "", ); } // Affiche dans la console diff --git a/files/fr/web/javascript/reference/global_objects/intl/segmenter/segment/segments/@@iterator/index.md b/files/fr/web/javascript/reference/global_objects/intl/segmenter/segment/segments/@@iterator/index.md index f2eb7da9b39dfc..513a63ea0a18c5 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/segmenter/segment/segments/@@iterator/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/segmenter/segment/segments/@@iterator/index.md @@ -14,7 +14,7 @@ La méthode **`Intl.Segments.@@iterator`** fait partie de l'implémentation [du ## Syntaxe ```js -segments[Symbol.iterator] +segments[Symbol.iterator]; ``` La fonction disponible sur cet itérateur est `.next()`, elle est décrite dans [la page du protocole itérateur](/fr/docs/Web/JavaScript/Reference/Iteration_protocols#le_protocole_«_itérateur_»). @@ -26,7 +26,7 @@ Un nouvel objet itérateur. ## Exemples ```js -const segmenter = new Intl.Segmenter('fr', {granularity: 'word'}); +const segmenter = new Intl.Segmenter("fr", { granularity: "word" }); const input = "Moi ? N'est-ce pas ?"; const segments = segmenter.segment(input); const iterator = segments[Symbol.iterator](); diff --git a/files/fr/web/javascript/reference/global_objects/intl/segmenter/segment/segments/containing/index.md b/files/fr/web/javascript/reference/global_objects/intl/segmenter/segment/segments/containing/index.md index 5442ca018be67f..2a5080e14d74c4 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/segmenter/segment/segments/containing/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/segmenter/segment/segments/containing/index.md @@ -14,7 +14,7 @@ La méthode **`Intl.Segments.containing()`** renvoie un objet décrivant le segm ## Syntaxe ```js -containing(codeUnitIndex) +containing(codeUnitIndex); ``` ### Paramètres @@ -40,9 +40,9 @@ Un objet qui décrit le segment faisant partie de la chaîne de caractères orig ```js // ┃0 1 2 3 4 5┃6┃7┃8┃9 ← Indice des codets // ┃A l l o n s┃-┃y┃!┃ ← Codets -const input = 'Allons-y!'; +const input = "Allons-y!"; -const segmenter = new Intl.Segmenter('fr', {granularity: 'word'}); +const segmenter = new Intl.Segmenter("fr", { granularity: "word" }); const segments = segmenter.segment(input); let current = undefined; diff --git a/files/fr/web/javascript/reference/global_objects/intl/segmenter/segmenter/index.md b/files/fr/web/javascript/reference/global_objects/intl/segmenter/segmenter/index.md index ec23bb4b96aebf..d2fd9312bbf86e 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/segmenter/segmenter/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/segmenter/segmenter/index.md @@ -13,9 +13,9 @@ Le constructeur **`Intl.Segmenter()`** crée un objet [`Intl.Segmenter`](/fr/doc ## Syntaxe ```js -new Intl.Segmenter() -new Intl.Segmenter(locales) -new Intl.Segmenter(locales, options) +new Intl.Segmenter(); +new Intl.Segmenter(locales); +new Intl.Segmenter(locales, options); ``` ### Paramètres @@ -51,8 +51,11 @@ Dans l'exemple suivant, on compte les mots d'une chaîne en japonais (où le dé ```js const text = "吾輩は猫である。名前はたぬき。"; -const japaneseSegmenter = new Intl.Segmenter('ja-JP', {granularity: 'word'}); -console.log([...japaneseSegmenter.segment(text)].filter(segment => segment.isWordLike).length); +const japaneseSegmenter = new Intl.Segmenter("ja-JP", { granularity: "word" }); +console.log( + [...japaneseSegmenter.segment(text)].filter((segment) => segment.isWordLike) + .length, +); // affiche 8 car le texte est segmenté en '吾輩'|'は'|'猫'|'で'|'ある'|'。'|'名前'|'は'|'たぬき'|'。' ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/segmenter/supportedlocalesof/index.md b/files/fr/web/javascript/reference/global_objects/intl/segmenter/supportedlocalesof/index.md index 006f6cce8550b9..9a79f9db3b7a57 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/segmenter/supportedlocalesof/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/segmenter/supportedlocalesof/index.md @@ -13,8 +13,8 @@ La méthode **`Intl.Segmenter.supportedLocalesOf()`** renvoie un tableau contena ## Syntaxe ```js -supportedLocalesOf(locales) -supportedLocalesOf(locales, options) +supportedLocalesOf(locales); +supportedLocalesOf(locales, options); ``` ### Paramètres @@ -41,9 +41,9 @@ Un tableau de chaînes de caractères représentant le sous-ensemble de locales Soit un environnement d'exécution qui prend en charge l'indonésien et l'allemand mais pas le balinais pour la segmentation, `supportedLocalesOf` renvoie les balises de langue indonésienne et allemande inchangées, même si la collation `pinyin` n'est pas pertinente pour la segmentation indonésienne et qu'un dialecte allemand pour l'Indonésie a peu de chances d'être pris en charge. On notera que l'exemple utilise l'algorithme "`lookup`" et que "`best fit`" aurait pu décider que l'indonésien est une correspondance valable pour le balinais, car la plupart des personnes qui parlent balinais comprennent aussi l'indonésien. En utilisant l'algorithme `"best fit"`, on aurait donc pu avoir la balise balinaise dans les résultats. ```js -const locales = ['ban', 'id-u-co-pinyin', 'de-ID']; -const options = { localeMatcher: 'lookup' }; -console.log(Intl.Segmenter.supportedLocalesOf(locales, options).join(', ')); +const locales = ["ban", "id-u-co-pinyin", "de-ID"]; +const options = { localeMatcher: "lookup" }; +console.log(Intl.Segmenter.supportedLocalesOf(locales, options).join(", ")); // → "id-u-co-pinyin, de-ID" ``` diff --git a/files/fr/web/javascript/reference/global_objects/intl/supportedvaluesof/index.md b/files/fr/web/javascript/reference/global_objects/intl/supportedvaluesof/index.md index c236e7f0b70d5b..539eb374b54989 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/supportedvaluesof/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/supportedvaluesof/index.md @@ -17,7 +17,7 @@ Elle peut également être utilisée pour construire des interfaces utilisateur ## Syntaxe ```js -Intl.supportedValuesOf(cle) +Intl.supportedValuesOf(cle); ``` ### Paramètres @@ -41,7 +41,7 @@ Un tableau trié, contenant des chaînes de caractères uniques indiquant les va On peut vérifier que la méthode est prise en charge en la comparant à `undefined` : ```js -if (typeof Intl.supportedValuesOf !== 'undefined') { +if (typeof Intl.supportedValuesOf !== "undefined") { // la méthode est prise en charge } ``` @@ -51,8 +51,8 @@ if (typeof Intl.supportedValuesOf !== 'undefined') { Pour obtenir les valeurs prises en charge pour les représentations calendaires, on pourra appeler la méthode avec la clé `"calendar"` et parcourir le tableau obtenu : ```js -Intl.supportedValuesOf("calendar").forEach(function(calendar) { - // "buddhist", "chinese", "coptic", "dangi", ... +Intl.supportedValuesOf("calendar").forEach(function (calendar) { + // "buddhist", "chinese", "coptic", "dangi", ... }); ``` @@ -61,24 +61,24 @@ Intl.supportedValuesOf("calendar").forEach(function(calendar) { Les autres valeurs peuvent être obtenues de la même façon : ```js -Intl.supportedValuesOf("collation").forEach(function(collation) { - // "big5han", "compat", "dict", "emoji", ... +Intl.supportedValuesOf("collation").forEach(function (collation) { + // "big5han", "compat", "dict", "emoji", ... }); -Intl.supportedValuesOf("currency").forEach(function(currency) { - // "ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", ... +Intl.supportedValuesOf("currency").forEach(function (currency) { + // "ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", ... }); -Intl.supportedValuesOf("numberingSystem").forEach(function(numberingSystem) { - // "adlm", "ahom", "arab", "arabext", "bali", ... +Intl.supportedValuesOf("numberingSystem").forEach(function (numberingSystem) { + // "adlm", "ahom", "arab", "arabext", "bali", ... }); -Intl.supportedValuesOf("timeZone").forEach(function(timeZone) { - // "Africa/Abidjan", "Africa/Accra", "Africa/Addis_Ababa", "Africa/Algiers", ... +Intl.supportedValuesOf("timeZone").forEach(function (timeZone) { + // "Africa/Abidjan", "Africa/Accra", "Africa/Addis_Ababa", "Africa/Algiers", ... }); -Intl.supportedValuesOf("unit").forEach(function(unit) { - // "acre", "bit", "byte", "celsius", "centimeter", ... +Intl.supportedValuesOf("unit").forEach(function (unit) { + // "acre", "bit", "byte", "celsius", "centimeter", ... }); ``` diff --git a/files/fr/web/javascript/reference/global_objects/isfinite/index.md b/files/fr/web/javascript/reference/global_objects/isfinite/index.md index 4a640ff6657eb3..2965438d7a9bcb 100644 --- a/files/fr/web/javascript/reference/global_objects/isfinite/index.md +++ b/files/fr/web/javascript/reference/global_objects/isfinite/index.md @@ -13,7 +13,7 @@ La fonction globale **`isFinite()`** détermine si la valeur passée en argument ## Syntaxe ```js -isFinite(valeurÀTester) +isFinite(valeurÀTester); ``` ### Paramètres @@ -34,19 +34,18 @@ Cette fonction peut être utilisée pour déterminer si un nombre est fini ou no ## Exemples ```js -isFinite(Infinity); // false -isFinite(NaN); // false +isFinite(Infinity); // false +isFinite(NaN); // false isFinite(-Infinity); // false -isFinite(0); // true -isFinite(2e64); // true -isFinite(910); // true -isFinite(null); // true, ce qui aurait été false - // avec la méthode Number.isFinite(null) +isFinite(0); // true +isFinite(2e64); // true +isFinite(910); // true +isFinite(null); // true, ce qui aurait été false +// avec la méthode Number.isFinite(null) - -isFinite("0"); // true ce qui aurait été false - // avec la méthode Number.isFinite("0") +isFinite("0"); // true ce qui aurait été false +// avec la méthode Number.isFinite("0") ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/isnan/index.md b/files/fr/web/javascript/reference/global_objects/isnan/index.md index 6656201c5e8e43..18269209dc8999 100644 --- a/files/fr/web/javascript/reference/global_objects/isnan/index.md +++ b/files/fr/web/javascript/reference/global_objects/isnan/index.md @@ -13,7 +13,7 @@ La fonction **`isNaN()`** permet de déterminer si une valeur est {{jsxref("NaN" ## Syntaxe ```js -isNaN(valeurÀTester) +isNaN(valeurÀTester); ``` ### Paramètres @@ -44,7 +44,7 @@ Depuis les premières spécifications pour `isNaN()`, son comportement sur les a La version ECMAScript ES2015 ajoute la méthode {{jsxref("Number.isNaN()")}}. `Number.isNaN(x)` permettra de tester de façon plus fiable si `x` vaut `NaN` ou non. Si on ne dispose pas de cette méthode, on peut également utiliser l'expression `(x != x)` afin de tester de façon plus certaine si `x` vaut `NaN` ou non (en effet le résultat de cette expression n'aura pas les faux positifs de `isNaN`). Sous cet angle, `isNaN()` peut être vu comme : ```js -var isNaN = function(valeur) { +var isNaN = function (valeur) { return Number.isNaN(Number(valeur)); }; ``` @@ -52,7 +52,7 @@ var isNaN = function(valeur) { Ou encore, en utilisant le fait que `NaN` est la seule valeur différente d'elle-même : ```js -var isNaN = function(valeur) { +var isNaN = function (valeur) { var n = Number(valeur); return n !== n; }; @@ -66,7 +66,7 @@ On peut par exemple construire une fonction dont on souhaite qu'elle incrémente ```js function incrément(x) { - if (isNaN(x)){ + if (isNaN(x)) { x = 0; } return x + 1; @@ -78,38 +78,38 @@ function incrémentCourt(x) { isNaN(x) ? 1 : x + 1; } -incrément("blabla"); // 1 -incrément(1); // 2 -incrément(NaN); // 1 +incrément("blabla"); // 1 +incrément(1); // 2 +incrément(NaN); // 1 ``` ## Exemples ```js -isNaN(NaN); // true +isNaN(NaN); // true isNaN(undefined); // true -isNaN({}); // true +isNaN({}); // true -isNaN(true); // false -isNaN(null); // false -isNaN(37); // false +isNaN(true); // false +isNaN(null); // false +isNaN(37); // false // strings -isNaN("37"); // false : "37" est converti vers le nombre 37 qui n'est pas NaN -isNaN("37.37"); // false : "37.37" est converti vers le nombre 37.37 qui n'est pas NaN -isNaN("37,25"); // true : la virgule n'est pas considérée comme un séparateur décimal -isNaN("123ABC"); // true : "123ABC" converti en 123 par parseInt mais en NaN par Number -isNaN(""); // false : la chaîne vide est convertie en 0 qui n'est pas NaN -isNaN(" "); // false : une chaîne de blancs est convertie en 0 qui n'est pas NaN +isNaN("37"); // false : "37" est converti vers le nombre 37 qui n'est pas NaN +isNaN("37.37"); // false : "37.37" est converti vers le nombre 37.37 qui n'est pas NaN +isNaN("37,25"); // true : la virgule n'est pas considérée comme un séparateur décimal +isNaN("123ABC"); // true : "123ABC" converti en 123 par parseInt mais en NaN par Number +isNaN(""); // false : la chaîne vide est convertie en 0 qui n'est pas NaN +isNaN(" "); // false : une chaîne de blancs est convertie en 0 qui n'est pas NaN // dates -isNaN(new Date()); // false -isNaN(new Date().toString()); // true +isNaN(new Date()); // false +isNaN(new Date().toString()); // true // Voici le résultat « faux-positif » qui fait que isNaN n'est pas entièrement fiable -isNaN("blabla") // true : "blabla" est converti en un nombre - // Si on souhaite convertir cette valeur en nombre, cela échoue - // et on obtient NaN +isNaN("blabla"); // true : "blabla" est converti en un nombre +// Si on souhaite convertir cette valeur en nombre, cela échoue +// et on obtient NaN ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/json/parse/index.md b/files/fr/web/javascript/reference/global_objects/json/parse/index.md index f495a065759c0c..8639c03a925857 100644 --- a/files/fr/web/javascript/reference/global_objects/json/parse/index.md +++ b/files/fr/web/javascript/reference/global_objects/json/parse/index.md @@ -37,11 +37,11 @@ Lève une exception {{jsxref("SyntaxError")}} si la chaine de caractère à anal ```js try { - JSON.parse('{}'); // {} - JSON.parse('true'); // true - JSON.parse('"toto"'); // "toto" + JSON.parse("{}"); // {} + JSON.parse("true"); // true + JSON.parse('"toto"'); // "toto" JSON.parse('[1, 5, "false"]'); // [1, 5, "false"] - JSON.parse('null'); // null + JSON.parse("null"); // null } catch (e) { console.error("Parsing error:", e); } @@ -55,17 +55,17 @@ Si le _reviver_ ne transforme que certaines valeurs et pas d'autres, assurez-vou ```js JSON.parse('{"p": 5}', (key, value) => { - if (typeof value === 'number') { - return value * 2; // renvoie value * 2 pour les nombres + if (typeof value === "number") { + return value * 2; // renvoie value * 2 pour les nombres } - return value; // pour le reste, la valeur est inchangée + return value; // pour le reste, la valeur est inchangée }); // { p: 10 } JSON.parse('{"1": 1, "2": 2,"3": {"4": 4, "5": {"6": 6}}}', (key, value) => { - console.log(key); // on affiche le nom de la propriété dans la console - return value; // et on renvoie la valeur inchangée. + console.log(key); // on affiche le nom de la propriété dans la console + return value; // et on renvoie la valeur inchangée. }); // 1 @@ -81,7 +81,7 @@ JSON.parse('{"1": 1, "2": 2,"3": {"4": 4, "5": {"6": 6}}}', (key, value) => { ```js example-bad // les deux instructions qui suivent lèveront une SyntaxError -JSON.parse('[1, 2, 3, 4, ]'); +JSON.parse("[1, 2, 3, 4, ]"); JSON.parse('{ "toto" : 1, }'); ``` diff --git a/files/fr/web/javascript/reference/global_objects/json/stringify/index.md b/files/fr/web/javascript/reference/global_objects/json/stringify/index.md index a67aea37c0404e..fe9e36c095d49e 100644 --- a/files/fr/web/javascript/reference/global_objects/json/stringify/index.md +++ b/files/fr/web/javascript/reference/global_objects/json/stringify/index.md @@ -54,18 +54,18 @@ La fonction `JSON.stringify()` convertit un objet en JSON : - Pour les autres instances d'objets tels que {{jsxref("Map")}}, {{jsxref("Set")}}, {{jsxref("WeakMap")}} et {{jsxref("WeakSet")}}, seules les propriétés énumérables sont sérialisées. ```js -JSON.stringify({}); // '{}' -JSON.stringify(true); // 'true' -JSON.stringify("toto"); // '"toto"' -JSON.stringify([1, "false", false]); // '[1,"false",false]' -JSON.stringify([NaN, null, Infinity]); // '[null,null,null]' -JSON.stringify({ x: 5 }); // '{"x":5}' +JSON.stringify({}); // '{}' +JSON.stringify(true); // 'true' +JSON.stringify("toto"); // '"toto"' +JSON.stringify([1, "false", false]); // '[1,"false",false]' +JSON.stringify([NaN, null, Infinity]); // '[null,null,null]' +JSON.stringify({ x: 5 }); // '{"x":5}' JSON.stringify(new Date(2006, 0, 2, 15, 4, 5)); // '"2006-01-02T23:04:05.000Z"' // Exemples -JSON.stringify({x: 5, y: 6}); +JSON.stringify({ x: 5, y: 6 }); // '{"x":5,"y":6}' JSON.stringify([new Number(3), new String("false"), new Boolean(false)]); // '[3,"false",false]' @@ -78,57 +78,78 @@ JSON.stringify(a); // '["toto","truc"]' // Symboles -JSON.stringify({x: undefined, y: Object, z: Symbol("")}); +JSON.stringify({ x: undefined, y: Object, z: Symbol("") }); // '{}' -JSON.stringify({[Symbol("toto")]: "toto"}); +JSON.stringify({ [Symbol("toto")]: "toto" }); // '{}' -JSON.stringify({[Symbol.for("toto")]: "toto"}, [Symbol.for("toto")]); +JSON.stringify({ [Symbol.for("toto")]: "toto" }, [Symbol.for("toto")]); // '{}' -JSON.stringify({[Symbol.for("toto")]: "toto"}, function (k, v) { - if (typeof k === "symbol"){ +JSON.stringify({ [Symbol.for("toto")]: "toto" }, function (k, v) { + if (typeof k === "symbol") { return "a symbol"; } }); // '{}' -JSON.stringify({ x: [10, undefined, function(){}, Symbol('')] }); +JSON.stringify({ x: [10, undefined, function () {}, Symbol("")] }); // '{"x":[10,null,null,null]}' // Structures de données classiques -JSON.stringify([new Set([1]), new Map([[1, 2]]), new WeakSet([{a: 1}]), new WeakMap([[{a: 1}, 2]])]); +JSON.stringify([ + new Set([1]), + new Map([[1, 2]]), + new WeakSet([{ a: 1 }]), + new WeakMap([[{ a: 1 }, 2]]), +]); // '[{},{},{},{}]' // TypedArray JSON.stringify([new Int8Array([1]), new Int16Array([1]), new Int32Array([1])]); // '[{"0":1},{"0":1},{"0":1}]' -JSON.stringify([new Uint8Array([1]), new Uint8ClampedArray([1]), new Uint16Array([1]), new Uint32Array([1])]); +JSON.stringify([ + new Uint8Array([1]), + new Uint8ClampedArray([1]), + new Uint16Array([1]), + new Uint32Array([1]), +]); // '[{"0":1},{"0":1},{"0":1},{"0":1}]' JSON.stringify([new Float32Array([1]), new Float64Array([1])]); // '[{"0":1},{"0":1}]' // toJSON() -JSON.stringify({ x: 5, y: 6, toJSON(){ return this.x + this.y; } }); +JSON.stringify({ + x: 5, + y: 6, + toJSON() { + return this.x + this.y; + }, +}); // '11' // Symbols: -JSON.stringify({ x: undefined, y: Object, z: Symbol('') }); +JSON.stringify({ x: undefined, y: Object, z: Symbol("") }); // '{}' -JSON.stringify({ [Symbol('foo')]: 'foo' }); +JSON.stringify({ [Symbol("foo")]: "foo" }); // '{}' -JSON.stringify({ [Symbol.for('foo')]: 'foo' }, [Symbol.for('foo')]); +JSON.stringify({ [Symbol.for("foo")]: "foo" }, [Symbol.for("foo")]); // '{}' -JSON.stringify({ [Symbol.for('foo')]: 'foo' }, function(k, v) { - if (typeof k === 'symbol') { - return 'a symbol'; +JSON.stringify({ [Symbol.for("foo")]: "foo" }, function (k, v) { + if (typeof k === "symbol") { + return "a symbol"; } }); // undefined // Propriétés non énumérables -JSON.stringify(Object.create(null, { x: { value: 'x', enumerable: false }, y: { value: 'y', enumerable: true } }) ); +JSON.stringify( + Object.create(null, { + x: { value: "x", enumerable: false }, + y: { value: "y", enumerable: true }, + }), +); // '{"y":"y"}' // Échec avec BigInt -JSON.stringify({x: 2n}); +JSON.stringify({ x: 2n }); // TypeError: BigInt value can't be serialized in JSON ``` @@ -157,7 +178,13 @@ function remplaçant(clé, valeur) { return valeur; } -var toto = {fondation: "Mozilla", modèle: "boîte", semaine: 45, transport: "bus", mois: 7}; +var toto = { + fondation: "Mozilla", + modèle: "boîte", + semaine: 45, + transport: "bus", + mois: 7, +}; console.log(JSON.stringify(toto, remplaçant)); // {"semaine":45, "mois":7} ``` @@ -166,7 +193,7 @@ console.log(JSON.stringify(toto, remplaçant)); // {"semaine":45, "mois":7} Si `remplaçant` est un tableau, les valeurs du tableau indiquent les propriétés de l'objet à inclure dans la chaîne JSON. ```js -JSON.stringify(toto, ['semaine', 'mois']); +JSON.stringify(toto, ["semaine", "mois"]); // '{"semaine":45,"mois":7}', on ne garde que "semaines" et "mois" ``` @@ -178,7 +205,7 @@ L'argument `espace` est utilisé pour contrôler les espacements utilisés dans - Si c'est une chaîne, les dix premiers caractères (ou la chaîne complète si elle est plus courte) ```js -JSON.stringify({ a: 2 }, null, ' '); +JSON.stringify({ a: 2 }, null, " "); // '{ // "a": 2 // }' @@ -187,7 +214,7 @@ JSON.stringify({ a: 2 }, null, ' '); Dans l'exemple suivant on utilise la tabulation pour rendre lisible le résultat : ```js -JSON.stringify({ uno: 1, dos: 2 }, null, '\t'); +JSON.stringify({ uno: 1, dos: 2 }, null, "\t"); // renverra // '{ // "uno": 1, @@ -207,23 +234,23 @@ Ainsi : ```js var obj = { - data: 'data', - toJSON(clef){ - if(clef) { + data: "data", + toJSON(clef) { + if (clef) { return `Un objet imbriqué sous la clef '${clef}'`; } else { return this; } - } + }, }; JSON.stringify(obj); // '{"data":"data"}' -JSON.stringify({ obj }) +JSON.stringify({ obj }); // '{"obj":"Un objet imbriqué sous la clef 'obj'"}' -JSON.stringify([ obj ]) +JSON.stringify([obj]); // '["Un objet imbriqué sous la clef '0'"]' ``` @@ -248,15 +275,15 @@ Par le passé, JSON n'était pas un sous-ensemble strict de JavaScript. En effet Ainsi, si on souhaite avoir une compatibilité avec les anciens moteurs JavaScript, on pourra évaluer ou utiliser les données JSON avec [JSONP](https://fr.wikipedia.org/wiki/JSONP) et la fonction utilitaire suivante : ```js -function jsFriendlyJSONStringify (s) { - return JSON.stringify(s). - replace(/\u2028/g, '\\u2028'). - replace(/\u2029/g, '\\u2029'); +function jsFriendlyJSONStringify(s) { + return JSON.stringify(s) + .replace(/\u2028/g, "\\u2028") + .replace(/\u2029/g, "\\u2029"); } var s = { - a: String.fromCharCode(0x2028), - b: String.fromCharCode(0x2029) + a: String.fromCharCode(0x2028), + b: String.fromCharCode(0x2029), }; // dans Firefox, console.log enlève les échappements @@ -267,9 +294,9 @@ alert(jsFriendlyJSONStringify(s)); // {"a":"\u2028","b":"\u2029"} > **Note :** Les propriétés des objets qui ne sont pas des tableaux ne sont pas transformées en chaînes de caractères selon un ordre particulier. Aussi, l'ordre des données en JSON ne saurait constituer une information utile. ```js -var a = JSON.stringify({toto: "truc", bidule: "machin"}); +var a = JSON.stringify({ toto: "truc", bidule: "machin" }); // '{"toto":"truc","bidule":"machin"}' -var b = JSON.stringify({bidule: "machin", toto: "truc"}); +var b = JSON.stringify({ bidule: "machin", toto: "truc" }); // '{"bidule":"machin","toto":"truc"}' console.log(a !== b); // true ``` @@ -283,23 +310,23 @@ Dans le cas où on souhaite enregistrer un objet créé par l'utilisateur afin d ```js // On crée un objet pour l'exemple var session = { - 'screens' : [], - 'state' : true + screens: [], + state: true, }; -session.screens.push({"name":"screenA", "width":450, "height":250}); -session.screens.push({"name":"screenB", "width":650, "height":350}); -session.screens.push({"name":"screenC", "width":750, "height":120}); -session.screens.push({"name":"screenD", "width":250, "height":60}); -session.screens.push({"name":"screenE", "width":390, "height":120}); -session.screens.push({"name":"screenF", "width":1240, "height":650}); +session.screens.push({ name: "screenA", width: 450, height: 250 }); +session.screens.push({ name: "screenB", width: 650, height: 350 }); +session.screens.push({ name: "screenC", width: 750, height: 120 }); +session.screens.push({ name: "screenD", width: 250, height: 60 }); +session.screens.push({ name: "screenE", width: 390, height: 120 }); +session.screens.push({ name: "screenF", width: 1240, height: 650 }); // On convertit l'objet en une chaîne JSON // et on enregistre cette valeur avec le nom 'session' -localStorage.setItem('session', JSON.stringify(session)); +localStorage.setItem("session", JSON.stringify(session)); // Ici, on reconvertit la chaîne en un objet // JSON.stringify and saved in localStorage in JSON object again -var sessionRestaurée = JSON.parse(localStorage.getItem('session')); +var sessionRestaurée = JSON.parse(localStorage.getItem("session")); // La variable sessionRestaurée contient désormais l'objet précédent // qui avait été sauvegardé dans localStorage diff --git a/files/fr/web/javascript/reference/global_objects/map/@@iterator/index.md b/files/fr/web/javascript/reference/global_objects/map/@@iterator/index.md index 5e3b3127481024..a14988b4e9a818 100644 --- a/files/fr/web/javascript/reference/global_objects/map/@@iterator/index.md +++ b/files/fr/web/javascript/reference/global_objects/map/@@iterator/index.md @@ -13,7 +13,7 @@ La valeur initiale de la propriété **`@@iterator`** est la même fonction que ## Syntaxe ```js -maMap[Symbol.iterator] +maMap[Symbol.iterator]; ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/map/@@species/index.md b/files/fr/web/javascript/reference/global_objects/map/@@species/index.md index 84939015890205..fe9fd31404f8da 100644 --- a/files/fr/web/javascript/reference/global_objects/map/@@species/index.md +++ b/files/fr/web/javascript/reference/global_objects/map/@@species/index.md @@ -11,7 +11,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Map/@@species ## Syntaxe ```js -Map[Symbol.species] +Map[Symbol.species]; ``` ## Description @@ -32,7 +32,9 @@ Pour des objets dérivés (par exemple un dictionnaire `MaMap` que vous auriez c class MaMap extends Map { // On surcharge le symbole species de MaMap // avec le constructeur Map parent - static get [Symbol.species]() { return Map; } + static get [Symbol.species]() { + return Map; + } } ``` diff --git a/files/fr/web/javascript/reference/global_objects/map/clear/index.md b/files/fr/web/javascript/reference/global_objects/map/clear/index.md index 3bea46d3aeb9d9..7cedda796d07f1 100644 --- a/files/fr/web/javascript/reference/global_objects/map/clear/index.md +++ b/files/fr/web/javascript/reference/global_objects/map/clear/index.md @@ -29,13 +29,13 @@ var maMap = new Map(); maMap.set("truc", "bidule"); maMap.set(1, "toto"); -maMap.size; // 2 +maMap.size; // 2 maMap.has("truc"); // true maMap.clear(); -maMap.size; // 0 -maMap.has("truc") // false +maMap.size; // 0 +maMap.has("truc"); // false ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/map/delete/index.md b/files/fr/web/javascript/reference/global_objects/map/delete/index.md index 31b62f00d9562e..c58e9541042dce 100644 --- a/files/fr/web/javascript/reference/global_objects/map/delete/index.md +++ b/files/fr/web/javascript/reference/global_objects/map/delete/index.md @@ -32,7 +32,7 @@ var maMap = new Map(); maMap.set("truc", "toto"); maMap.delete("truc"); // Renvoie true. La suppression est OK. -maMap.has("truc"); // Renvoie false. "truc" n'est plus présent. +maMap.has("truc"); // Renvoie false. "truc" n'est plus présent. ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/map/entries/index.md b/files/fr/web/javascript/reference/global_objects/map/entries/index.md index 10053107433cb2..bb93870d270463 100644 --- a/files/fr/web/javascript/reference/global_objects/map/entries/index.md +++ b/files/fr/web/javascript/reference/global_objects/map/entries/index.md @@ -13,7 +13,7 @@ La méthode **`entries()`** renvoie un objet [`Iterator`](/fr/docs/Web/JavaScrip ## Syntaxe ```js -maMap.entries() +maMap.entries(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/map/foreach/index.md b/files/fr/web/javascript/reference/global_objects/map/foreach/index.md index b924d55ecf4733..d3dc75406cb585 100644 --- a/files/fr/web/javascript/reference/global_objects/map/foreach/index.md +++ b/files/fr/web/javascript/reference/global_objects/map/foreach/index.md @@ -45,15 +45,18 @@ Chacune des valeurs sera traitée une fois sauf si celle-ci a été supprimée p ## Exemples -Le fragment de code suivant enregistre une ligne pour chaque élément d'un objet` Map `: +Le fragment de code suivant enregistre une ligne pour chaque élément d'un objet`Map`: ```js function logMapElements(valeur, clé, map) { - console.log(`map.get('${clé}') = ${value}`); + console.log(`map.get('${clé}') = ${value}`); } - -new Map([["toto", 3], ["truc", {}], ["bidule", undefined]]).forEach(logMapElements); +new Map([ + ["toto", 3], + ["truc", {}], + ["bidule", undefined], +]).forEach(logMapElements); // affichera dans la console : // "map.get('toto') = 3" // "map.get('truc') = [object Object]" diff --git a/files/fr/web/javascript/reference/global_objects/map/get/index.md b/files/fr/web/javascript/reference/global_objects/map/get/index.md index caf3cbbff9dfa1..092bc603ed5b93 100644 --- a/files/fr/web/javascript/reference/global_objects/map/get/index.md +++ b/files/fr/web/javascript/reference/global_objects/map/get/index.md @@ -13,7 +13,7 @@ La méthode **`get()`** renvoie un élément précisé d'un objet `Map`. Si la v ## Syntaxe ```js -maMap.get(clé) +maMap.get(clé); ``` ### Paramètres @@ -31,8 +31,8 @@ L'élément associée à la clé donnée ou {{jsxref("undefined")}} si la clé n var maMap = new Map(); maMap.set("truc", "toto"); -maMap.get("truc"); // Renvoie "toto". -maMap.get("machin"); // Renvoie undefined. +maMap.get("truc"); // Renvoie "toto". +maMap.get("machin"); // Renvoie undefined. ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/map/has/index.md b/files/fr/web/javascript/reference/global_objects/map/has/index.md index 760baa530dda50..15ec5b998ffe77 100644 --- a/files/fr/web/javascript/reference/global_objects/map/has/index.md +++ b/files/fr/web/javascript/reference/global_objects/map/has/index.md @@ -31,8 +31,8 @@ Cette méthode renvoie un booléen : `true` si un élément avec cette clé exis var maMap = new Map(); maMap.set("truc", "toto"); -maMap.has("truc"); // renvoie true -maMap.has("machin");// renvoie false +maMap.has("truc"); // renvoie true +maMap.has("machin"); // renvoie false ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/map/index.md b/files/fr/web/javascript/reference/global_objects/map/index.md index 1b41ffc8f9858f..70c05e5b20fcb2 100644 --- a/files/fr/web/javascript/reference/global_objects/map/index.md +++ b/files/fr/web/javascript/reference/global_objects/map/index.md @@ -115,10 +115,10 @@ Ainsi, on pourra faire : ```js example-bad const mauvaiseMap = new Map(); -mauvaiseMap['bla'] = 'blaa'; -mauvaiseMap['bla2'] = 'blaaa2'; +mauvaiseMap["bla"] = "blaa"; +mauvaiseMap["bla2"] = "blaaa2"; -console.log(mauvaiseMap); // Map { bla: 'blaa', bla2: 'blaaa2' } +console.log(mauvaiseMap); // Map { bla: 'blaa', bla2: 'blaaa2' } ``` Mais ces instructions n'interagissent pas avec la structure `Map`, elles ne font qu'ajouter des propriétés objet. La valeur associée à la clé `"bla"` n'est pas stockée dans la `Map`. Ainsi, si on utilise les méthodes de `Map`, cela échouera : @@ -133,13 +133,16 @@ Pour stocker des données dans une structure `Map`, on utilisera plutôt la mét ```js example-good const contacts = new Map(); -contacts.set('Jessie', {phone: "01 99 00 12 34", address: "1 Rue de l'avenue"}); -contacts.has('Jessie'); // true -contacts.get('James'); // undefined -contacts.set('James', {phone: "06 39 98 78 89", address: "3 Chemin du Parc"}); -contacts.get('Jessie'); // {phone: "01 99 00 12 34", address: "1 Rue de l'avenue"} -contacts.delete('Miaouss'); // false -contacts.delete('Jessie'); // true +contacts.set("Jessie", { + phone: "01 99 00 12 34", + address: "1 Rue de l'avenue", +}); +contacts.has("Jessie"); // true +contacts.get("James"); // undefined +contacts.set("James", { phone: "06 39 98 78 89", address: "3 Chemin du Parc" }); +contacts.get("Jessie"); // {phone: "01 99 00 12 34", address: "1 Rue de l'avenue"} +contacts.delete("Miaouss"); // false +contacts.delete("Jessie"); // true console.log(contacts.size); // 1 ``` @@ -192,8 +195,8 @@ console.log(contacts.size); // 1 const maMap = new Map(); const objectKey = {}, - functionKey = function () {}, - stringKey = "une chaîne"; + functionKey = function () {}, + stringKey = "une chaîne"; // définir les valeurs maMap.set(stringKey, "valeur associée à 'une chaîne'"); @@ -203,14 +206,14 @@ maMap.set(functionKey, "valeur associée à functionKey"); maMap.size; // 3 // récupérer les valeurs -maMap.get(stringKey); // "valeur associée à 'une chaîne'" -maMap.get(objectKey); // "valeur associée à objetClé" -maMap.get(functionKey); // "valeur associée à fonctionClé" - -maMap.get("une chaîne"); // "valeur associée à 'une chaîne'" - // car chaineClé === 'une chaîne' -maMap.get({}); // indéfini car objetClé !== {} -maMap.get(function() {}); // indéfini car fonctionClé !== function () {} +maMap.get(stringKey); // "valeur associée à 'une chaîne'" +maMap.get(objectKey); // "valeur associée à objetClé" +maMap.get(functionKey); // "valeur associée à fonctionClé" + +maMap.get("une chaîne"); // "valeur associée à 'une chaîne'" +// car chaineClé === 'une chaîne' +maMap.get({}); // indéfini car objetClé !== {} +maMap.get(function () {}); // indéfini car fonctionClé !== function () {} ``` ### Utiliser `NaN` comme clé @@ -266,7 +269,7 @@ for (const [key, value] of maMap.entries()) { Il est aussi possible de parcourir des objets `Map` avec la méthode [`forEach()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach) : ```js -maMap.forEach(function(value, key) { +maMap.forEach(function (value, key) { console.log(`${key} = ${value}`); }); // 0 = zéro @@ -276,7 +279,10 @@ maMap.forEach(function(value, key) { ### Relation avec les objets `Array` ```js -const keyValuePair = [["clé1", "valeur1"], ["clé2", "valeur2"]]; +const keyValuePair = [ + ["clé1", "valeur1"], + ["clé2", "valeur2"], +]; // On utilise le constructeur Map // pour transformer un tableau de clés/valeurs @@ -302,9 +308,7 @@ console.log(Array.from(maMap.keys())); // affichera ["clé1", "clé2"] Il est possible de cloner des `Map` comme on clone des tableaux : ```js -const original = new Map([ - [1, 'un'] -]); +const original = new Map([[1, "un"]]); const clone = new Map(original); @@ -318,14 +322,14 @@ Il est également possible de fusionner deux `Map` en conservant le critère d'u ```js const premier = new Map([ - [1, 'un'], - [2, 'deux'], - [3, 'trois'], + [1, "un"], + [2, "deux"], + [3, "trois"], ]); const second = new Map([ - [1, 'uno'], - [2, 'dos'] + [1, "uno"], + [2, "dos"], ]); // On fusionne les deux maps. C'est la "dernière" version @@ -343,19 +347,19 @@ Il est également possible de fusionner des objets `Map` avec des objets `Array` ```js const premier = new Map([ - [1, 'un'], - [2, 'deux'], - [3, 'trois'], + [1, "un"], + [2, "deux"], + [3, "trois"], ]); const second = new Map([ - [1, 'uno'], - [2, 'dos'] + [1, "uno"], + [2, "dos"], ]); // On peut fusionner des Maps avec un tableau // Là encore c'est le dernier exemplaire de la clé qui l'emporte -const fusion = new Map([...premier, ...second, [1, 'eins']]); +const fusion = new Map([...premier, ...second, [1, "eins"]]); console.log(fusion.get(1)); // eins console.log(fusion.get(2)); // dos diff --git a/files/fr/web/javascript/reference/global_objects/map/keys/index.md b/files/fr/web/javascript/reference/global_objects/map/keys/index.md index 486e47299864dd..0a28d94888b763 100644 --- a/files/fr/web/javascript/reference/global_objects/map/keys/index.md +++ b/files/fr/web/javascript/reference/global_objects/map/keys/index.md @@ -13,7 +13,7 @@ La méthode **`keys()`** renvoie un objet [`Iterator`](/fr/docs/Web/JavaScript/G ## Syntaxe ```js -maMap.keys() +maMap.keys(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/map/map/index.md b/files/fr/web/javascript/reference/global_objects/map/map/index.md index a7c73116c04713..54555981cf34b3 100644 --- a/files/fr/web/javascript/reference/global_objects/map/map/index.md +++ b/files/fr/web/javascript/reference/global_objects/map/map/index.md @@ -11,8 +11,8 @@ Le **constructeur `Map()`** permet de créer des objets [`Map`](/fr/docs/Web/Jav ## Syntaxe ```js -new Map() -new Map(iterable) +new Map(); +new Map(iterable); ``` ### Paramètres @@ -26,9 +26,9 @@ new Map(iterable) ```js let maMap = new Map([ - [1, 'un'], - [2, 'deux'], - [3, 'trois'], + [1, "un"], + [2, "deux"], + [3, "trois"], ]); ``` diff --git a/files/fr/web/javascript/reference/global_objects/map/set/index.md b/files/fr/web/javascript/reference/global_objects/map/set/index.md index 1ed96d98fca18e..c6c917e4de7f8a 100644 --- a/files/fr/web/javascript/reference/global_objects/map/set/index.md +++ b/files/fr/web/javascript/reference/global_objects/map/set/index.md @@ -49,9 +49,7 @@ La méthode `set()` renvoie le même objet `Map` et on peut donc la « chaîner ```js // On ajoute de nouveaux éléments // en enchaînant les appels à set() -maMap.set('truc', 'toto') - .set(1, 'tototruc') - .set(2, 'bidule'); +maMap.set("truc", "toto").set(1, "tototruc").set(2, "bidule"); ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/map/size/index.md b/files/fr/web/javascript/reference/global_objects/map/size/index.md index cbfc1f0fee210c..63c2dac7a42133 100644 --- a/files/fr/web/javascript/reference/global_objects/map/size/index.md +++ b/files/fr/web/javascript/reference/global_objects/map/size/index.md @@ -24,7 +24,7 @@ maMap.set("a", "alpha"); maMap.set("b", "beta"); maMap.set("g", "gamma"); -maMap.size // 3 +maMap.size; // 3 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/map/values/index.md b/files/fr/web/javascript/reference/global_objects/map/values/index.md index 16702836007a78..41c52122fe8df5 100644 --- a/files/fr/web/javascript/reference/global_objects/map/values/index.md +++ b/files/fr/web/javascript/reference/global_objects/map/values/index.md @@ -13,7 +13,7 @@ La méthode **`values()`** renvoie un objet [`Iterator`](/fr/docs/Web/JavaScript ## Syntaxe ```js -maMap.values() +maMap.values(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/math/abs/index.md b/files/fr/web/javascript/reference/global_objects/math/abs/index.md index cd7583ad12ee03..598647c3891ba2 100644 --- a/files/fr/web/javascript/reference/global_objects/math/abs/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/abs/index.md @@ -38,16 +38,16 @@ La valeur absolue du nombre passé en argument. Si la méthode est utilisée avec une chaîne de caractères non numérique, avec un tableau à plus d'un élément, sans paramètre ou avec {{jsxref("undefined")}}, la valeur retournée sera {{jsxref("NaN")}}. Si elle est utilisée avec {{jsxref("null")}}, la fonction renverra 0. ```js -Math.abs('-1'); // 1 -Math.abs(-2); // 2 -Math.abs(null); // 0 -Math.abs(''); // 0 -Math.abs([]); // 0 -Math.abs([2]); // 2 -Math.abs([1,2]); // NaN -Math.abs({}); // NaN +Math.abs("-1"); // 1 +Math.abs(-2); // 2 +Math.abs(null); // 0 +Math.abs(""); // 0 +Math.abs([]); // 0 +Math.abs([2]); // 2 +Math.abs([1, 2]); // NaN +Math.abs({}); // NaN Math.abs("string"); // NaN -Math.abs(); // NaN +Math.abs(); // NaN ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/math/acos/index.md b/files/fr/web/javascript/reference/global_objects/math/acos/index.md index 30c9096c5c668c..b705230e3b08f7 100644 --- a/files/fr/web/javascript/reference/global_objects/math/acos/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/acos/index.md @@ -15,7 +15,7 @@ La fonction **`Math.acos()`** renvoie l'arc cosinus d'une valeur exprimée en ra ## Syntaxe ```js -Math.acos(x) +Math.acos(x); ``` ### Paramètres @@ -38,12 +38,12 @@ La méthode `acos` renvoie une valeur numérique comprise entre 0 et Pi pour x c ### Utiliser `Math.acos()` ```js -Math.acos(-2); // NaN -Math.acos(-1); // 3.141592653589793 -Math.acos(0); // 1.5707963267948966 +Math.acos(-2); // NaN +Math.acos(-1); // 3.141592653589793 +Math.acos(0); // 1.5707963267948966 Math.acos(0.5); // 1.0471975511965979 -Math.acos(1); // 0 -Math.acos(2); // NaN +Math.acos(1); // 0 +Math.acos(2); // NaN ``` Pour les valeurs (strictement) inférieures à -1 ou supérieures à 1, `Math.acos` renvoie `NaN`. diff --git a/files/fr/web/javascript/reference/global_objects/math/acosh/index.md b/files/fr/web/javascript/reference/global_objects/math/acosh/index.md index 9fa3769faf6a1c..b6c2365cbdd97f 100644 --- a/files/fr/web/javascript/reference/global_objects/math/acosh/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/acosh/index.md @@ -15,7 +15,7 @@ La fonction **`Math.acosh()`** renvoie l'arc cosinus hyperbolique d'un nombre.El ## Syntaxe ```js -Math.acosh(x) +Math.acosh(x); ``` ### Paramètres @@ -36,11 +36,11 @@ L'arc cosinus hyperbolique du nombre en argument. Si le nombre est inférieur à ### Utiliser `Math.acosh()` ```js -Math.acosh(-1); // NaN -Math.acosh(0); // NaN +Math.acosh(-1); // NaN +Math.acosh(0); // NaN Math.acosh(0.5); // NaN -Math.acosh(1); // 0 -Math.acosh(2); // 1.3169578969248166 +Math.acosh(1); // 0 +Math.acosh(2); // 1.3169578969248166 ``` Pour les valeurs strictement inférieures à 1 `Math.acosh` renvoie {{jsxref("NaN")}}. diff --git a/files/fr/web/javascript/reference/global_objects/math/asin/index.md b/files/fr/web/javascript/reference/global_objects/math/asin/index.md index c4d1377c08069d..7ea7b54a3baa75 100644 --- a/files/fr/web/javascript/reference/global_objects/math/asin/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/asin/index.md @@ -15,7 +15,7 @@ La fonction **`Math.asin()`** renvoie l'arc sinus d'un nombre (en radians). Elle ## Syntaxe ```js -Math.asin(x) +Math.asin(x); ``` ### Paramètres @@ -38,12 +38,12 @@ La méthode `Math.asin()` renvoie une valeur numérique comprise entre x(-1,1),Math.atanh(x)=arctanh(x)= le seul y tel quetanh(y)=x\forall x \in \left( -1, 1 \right), \mathtt{\operatorname{Math.atanh}(x)} = \operatorname{arctanh}(x) = \text{ the unique } \; y \; \text{such that} \; \tanh(y) = x +x(-1,1),Math.atanh(x)=arctanh(x)= le seul y tel quetanh(y)=x\forall x \in \left( -1, 1 \right), \mathtt{\operatorname{Math.atanh}(x)} = \operatorname{arctanh}(x) = \text{ the unique } \; y \; \text{such that} \; \tanh(y) = x {{EmbedInteractiveExample("pages/js/math-atanh.html")}} ## Syntaxe ```js -Math.atanh(x) +Math.atanh(x); ``` ### Paramètres @@ -36,12 +36,12 @@ L'arc tangente hyperbolique du nombre passé en argument. ### Utiliser `Math.atanh()` ```js -Math.atanh(-2); // NaN -Math.atanh(-1); // -Infinity -Math.atanh(0); // 0 +Math.atanh(-2); // NaN +Math.atanh(-1); // -Infinity +Math.atanh(0); // 0 Math.atanh(0.5); // 0.5493061443340548 -Math.atanh(1); // Infinity -Math.atanh(2); // NaN +Math.atanh(1); // Infinity +Math.atanh(2); // NaN ``` Pour les valeurs strictement inférieures à -1 ou strictement supérieures à 1, {{jsxref("NaN")}} sera renvoyé. @@ -51,9 +51,11 @@ Pour les valeurs strictement inférieures à -1 ou strictement supérieures à 1 Pour |x|<1\left|x\right| < 1, on a la formule suivante : artanh(x)=12ln(1+x1-x)\operatorname {artanh} (x) = \frac{1}{2}\ln \left( \frac{1 + x}{1 - x} \right)et on peut donc émuler la fonction avec : ```js -Math.atanh = Math.atanh || function(x) { - return Math.log((1+x)/(1-x)) / 2; -}; +Math.atanh = + Math.atanh || + function (x) { + return Math.log((1 + x) / (1 - x)) / 2; + }; ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/math/cbrt/index.md b/files/fr/web/javascript/reference/global_objects/math/cbrt/index.md index f56f9787e4fde2..637c2f24b5a100 100644 --- a/files/fr/web/javascript/reference/global_objects/math/cbrt/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/cbrt/index.md @@ -15,7 +15,7 @@ La fonction **`Math.cbrt()`** renvoie la racine cubique (le nom anglais étant _ ## Syntaxe ```js -Math.cbrt(x) +Math.cbrt(x); ``` ### Paramètres @@ -44,7 +44,7 @@ Math.cbrt(0); // 0 Math.cbrt(1); // 1 Math.cbrt(Infinity); // Infinity Math.cbrt(null); // 0 -Math.cbrt(2); // 1.2599210498948732 +Math.cbrt(2); // 1.2599210498948732 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/math/ceil/index.md b/files/fr/web/javascript/reference/global_objects/math/ceil/index.md index 62a6ddb3e60f68..1c93b0d9588038 100644 --- a/files/fr/web/javascript/reference/global_objects/math/ceil/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/ceil/index.md @@ -13,7 +13,7 @@ La fonction **`Math.ceil()`** retourne le plus petit entier supérieur ou égal ## Syntaxe ```js -Math.ceil(x) +Math.ceil(x); ``` ### Paramètres @@ -38,21 +38,20 @@ Le plus petit entier qui est supérieur ou égal au nombre donné. Voici un exemple d'utilisation de `Math.ceil()`. ```js -Math.ceil(.95); // 1 -Math.ceil(4); // 4 -Math.ceil(7.004); // 8 -Math.ceil(-0.95); // -0 -Math.ceil(-4); // -4 +Math.ceil(0.95); // 1 +Math.ceil(4); // 4 +Math.ceil(7.004); // 8 +Math.ceil(-0.95); // -0 +Math.ceil(-4); // -4 Math.ceil(-7.004); // -7 -Math.ceil(null); // 0 +Math.ceil(null); // 0 ``` ### Arrondi décimal ```js // Fermeture -(function(){ - +(function () { /** * Fonction pour arrondir un nombre. * @@ -63,43 +62,42 @@ Math.ceil(null); // 0 */ function decimalAdjust(type, value, exp) { // Si l'exposant vaut undefined ou zero... - if (typeof exp === 'undefined' || +exp === 0) { + if (typeof exp === "undefined" || +exp === 0) { return Math[type](value); } value = +value; exp = +exp; // Si value n'est pas un nombre - // ou si l'exposant n'est pas entier - if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0)) { + // ou si l'exposant n'est pas entier + if (isNaN(value) || !(typeof exp === "number" && exp % 1 === 0)) { return NaN; } // Décalage - value = value.toString().split('e'); - value = Math[type](+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp))); + value = value.toString().split("e"); + value = Math[type](+(value[0] + "e" + (value[1] ? +value[1] - exp : -exp))); // Re "calage" - value = value.toString().split('e'); - return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp)); + value = value.toString().split("e"); + return +(value[0] + "e" + (value[1] ? +value[1] + exp : exp)); } // Arrondi décimal if (!Math.round10) { - Math.round10 = function(value, exp) { - return decimalAdjust('round', value, exp); + Math.round10 = function (value, exp) { + return decimalAdjust("round", value, exp); }; } // Arrondi décimal inférieur if (!Math.floor10) { - Math.floor10 = function(value, exp) { - return decimalAdjust('floor', value, exp); + Math.floor10 = function (value, exp) { + return decimalAdjust("floor", value, exp); }; } // Arrondi décimal supérieur if (!Math.ceil10) { - Math.ceil10 = function(value, exp) { - return decimalAdjust('ceil', value, exp); + Math.ceil10 = function (value, exp) { + return decimalAdjust("ceil", value, exp); }; } - })(); // Arrondi décimal diff --git a/files/fr/web/javascript/reference/global_objects/math/clz32/index.md b/files/fr/web/javascript/reference/global_objects/math/clz32/index.md index fb6a61eac3bd62..ed35eb1f29a894 100644 --- a/files/fr/web/javascript/reference/global_objects/math/clz32/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/clz32/index.md @@ -13,7 +13,7 @@ La fonction **`Math.clz32()`** renvoie le nombre de zéros de tête dans la repr ## Syntaxe ```js -Math.clz32(x) +Math.clz32(x); ``` ### Paramètres @@ -38,15 +38,26 @@ Cette fonction est particulièrement utile aux systèmes qui compilent du code J ## Exemples ```js -Math.clz32(1) // 31 -Math.clz32(1000) // 22 -Math.clz32() // 32 - -var liste = [NaN, Infinity, -Infinity, 0, -0, null, undefined, 'machin', {}, []]; -liste.every(n => Math.clz32(n) == 32); // true - -Math.clz32(true) // 31 -Math.clz32(3.5) // 30 +Math.clz32(1); // 31 +Math.clz32(1000); // 22 +Math.clz32(); // 32 + +var liste = [ + NaN, + Infinity, + -Infinity, + 0, + -0, + null, + undefined, + "machin", + {}, + [], +]; +liste.every((n) => Math.clz32(n) == 32); // true + +Math.clz32(true); // 31 +Math.clz32(3.5); // 30 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/math/cos/index.md b/files/fr/web/javascript/reference/global_objects/math/cos/index.md index b8830c10551967..9cc5ef7dbfc965 100644 --- a/files/fr/web/javascript/reference/global_objects/math/cos/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/cos/index.md @@ -13,7 +13,7 @@ La fonction **`Math.cos()`** retourne le [cosinus](https://fr.wikipedia.org/wiki ## Syntaxe ```js -Math.cos(x) +Math.cos(x); ``` ### Paramètres @@ -36,10 +36,10 @@ La méthode `Math.cos()` renvoie une valeur numérique comprise entre -1 et 1. C ### Utiliser `Math.cos()` ```js -Math.cos(0); // 1 -Math.cos(1); // 0.5403023058681398 +Math.cos(0); // 1 +Math.cos(1); // 0.5403023058681398 -Math.cos(Math.PI); // -1 +Math.cos(Math.PI); // -1 Math.cos(2 * Math.PI); // 1 ``` diff --git a/files/fr/web/javascript/reference/global_objects/math/cosh/index.md b/files/fr/web/javascript/reference/global_objects/math/cosh/index.md index c14173983e86c4..ab76487284a04c 100644 --- a/files/fr/web/javascript/reference/global_objects/math/cosh/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/cosh/index.md @@ -17,7 +17,7 @@ La fonction **`Math.cosh()`** renvoie le cosinus hyperbolique d'un nombre, défi ## Syntaxe ```js -Math.cosh(x) +Math.cosh(x); ``` ### Paramètres @@ -38,8 +38,8 @@ Le cosinus hyperbolique du nombre passé en argument. ### Utiliser `Math.cosh()` ```js -Math.cosh(0); // 1 -Math.cosh(1); // 1.5430806348152437 +Math.cosh(0); // 1 +Math.cosh(1); // 1.5430806348152437 Math.cosh(-1); // 1.5430806348152437 ``` @@ -48,18 +48,22 @@ Math.cosh(-1); // 1.5430806348152437 Cette fonction peut être émulée grâce à la fonction {{jsxref("Objets_globaux/Math/exp", "Math.exp()")}} : ```js -Math.cosh = Math.cosh || function(x) { +Math.cosh = + Math.cosh || + function (x) { return (Math.exp(x) + Math.exp(-x)) / 2; -} + }; ``` On peut également utiliser un unique appel à {{jsxref("Objets_globaux/Math/exp", "exp()")}} : ```js -Math.cosh = Math.cosh || function(x) { +Math.cosh = + Math.cosh || + function (x) { var y = Math.exp(x); return (y + 1 / y) / 2; -} + }; ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/math/e/index.md b/files/fr/web/javascript/reference/global_objects/math/e/index.md index 2975b0bc705612..8c7d949d57972a 100644 --- a/files/fr/web/javascript/reference/global_objects/math/e/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/e/index.md @@ -24,7 +24,7 @@ La fonction suivante renvoie la valeur de e : ```js function getNapier() { - return Math.E; + return Math.E; } getNapier(); // 2.718281828459045 diff --git a/files/fr/web/javascript/reference/global_objects/math/exp/index.md b/files/fr/web/javascript/reference/global_objects/math/exp/index.md index 458acc71925903..8305233908f14c 100644 --- a/files/fr/web/javascript/reference/global_objects/math/exp/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/exp/index.md @@ -13,7 +13,7 @@ La fonction **`Math.exp()`** renvoie l'exponentielle d'un nombre (donnée par `e ## Syntaxe ```js -Math.exp(x) +Math.exp(x); ``` ### Paramètres @@ -35,8 +35,8 @@ L'exponentielle du nombre passé en argument (`e^x`). ```js Math.exp(-1); // 0.36787944117144233 -Math.exp(0); // 1 -Math.exp(1); // 2.718281828459045 +Math.exp(0); // 1 +Math.exp(1); // 2.718281828459045 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/math/expm1/index.md b/files/fr/web/javascript/reference/global_objects/math/expm1/index.md index c062a6bef3ab8a..f596049e0573c2 100644 --- a/files/fr/web/javascript/reference/global_objects/math/expm1/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/expm1/index.md @@ -13,7 +13,7 @@ La fonction **`Math.expm1()`** renvoie `e^x` - 1, avec `x` l'argument donné et ## Syntaxe ```js -Math.expm1(x) +Math.expm1(x); ``` ### Paramètres @@ -35,8 +35,8 @@ Un nombre qui représente `e^x- 1` où `x` est la valeur passée en argument et ```js Math.expm1(-1); // -0.6321205588285577 -Math.expm1(0); // 0 -Math.expm1(1); // 1.718281828459045 +Math.expm1(0); // 0 +Math.expm1(1); // 1.718281828459045 ``` ## Prothèse d'émulation (_polyfill_) @@ -44,9 +44,11 @@ Math.expm1(1); // 1.718281828459045 Cette fonction peut être émulée en utilisant la fonction {{jsxref("Objets_globaux/Math/exp", "Math.exp()")}} : ```js -Math.expm1 = Math.expm1 || function(x) { +Math.expm1 = + Math.expm1 || + function (x) { return Math.exp(x) - 1; -}; + }; ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/math/floor/index.md b/files/fr/web/javascript/reference/global_objects/math/floor/index.md index 2cacbfeda44289..b2626071528007 100644 --- a/files/fr/web/javascript/reference/global_objects/math/floor/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/floor/index.md @@ -13,7 +13,7 @@ La fonction **`Math.floor(x)`** renvoie le plus grand entier qui est inférieur ## Syntaxe ```js -Math.floor(x) +Math.floor(x); ``` ### Paramètres @@ -36,12 +36,12 @@ Un nombre qui représente le plus grand entier inférieur ou égal à la valeur ### Utiliser `Math.floor` ```js -Math.floor( 45.95); // 45 -Math.floor( 45.05); // 45 -Math.floor( 4 ); // 4 +Math.floor(45.95); // 45 +Math.floor(45.05); // 45 +Math.floor(4); // 4 Math.floor(-45.05); // -46 Math.floor(-45.95); // -46 -Math.floor(null); // 0 +Math.floor(null); // 0 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/math/fround/index.md b/files/fr/web/javascript/reference/global_objects/math/fround/index.md index 5b6bbab94e7d40..107ca7b54c4794 100644 --- a/files/fr/web/javascript/reference/global_objects/math/fround/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/fround/index.md @@ -13,7 +13,7 @@ La fonction **`Math.fround()`** renvoie le nombre flottant à [précision simple ## Syntaxe ```js -Math.fround(x) +Math.fround(x); ``` ### Paramètres @@ -38,15 +38,15 @@ Pour résoudre ce problème, on peut utiliser `Math.fround()` afin de transforme ### Utiliser `Math.fround()` ```js -Math.fround(0); // 0 -Math.fround(1); // 1 +Math.fround(0); // 0 +Math.fround(1); // 1 // 1.337 ne peut pas être représenté correctement // sur 32 bits Math.fround(1.337); // 1.3370000123977661 -Math.fround(1.5); // 1.5 -Math.fround(NaN); // NaN +Math.fround(1.5); // 1.5 +Math.fround(NaN); // NaN ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/math/hypot/index.md b/files/fr/web/javascript/reference/global_objects/math/hypot/index.md index 6f44f2864e2374..811fb8cf14b47e 100644 --- a/files/fr/web/javascript/reference/global_objects/math/hypot/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/hypot/index.md @@ -40,13 +40,13 @@ Cette fonction permet entre autres de gérer certains cas où, pour les grands n ### Utiliser `Math.hypot()` ```js -Math.hypot(3, 4) // 5 -Math.hypot(3, 4, 5) // 7.0710678118654755 -Math.hypot() // 0 -Math.hypot(NaN) // NaN -Math.hypot(3, 4, "toto") // NaN, +"toto" => NaN -Math.hypot(3, 4, "5") // 7.0710678118654755, +"5" => 5 -Math.hypot(-3) // 3, the same as Math.abs(-3) +Math.hypot(3, 4); // 5 +Math.hypot(3, 4, 5); // 7.0710678118654755 +Math.hypot(); // 0 +Math.hypot(NaN); // NaN +Math.hypot(3, 4, "toto"); // NaN, +"toto" => NaN +Math.hypot(3, 4, "5"); // 7.0710678118654755, +"5" => 5 +Math.hypot(-3); // 3, the same as Math.abs(-3) ``` ## Prothèse d'émulation (_polyfill_) @@ -54,18 +54,20 @@ Math.hypot(-3) // 3, the same as Math.abs(-3) Si elle n'est pas disponible, cette fonction peut être émulée de la façon suivante : ```js -Math.hypot = Math.hypot || function() { +Math.hypot = + Math.hypot || + function () { var y = 0; var length = arguments.length; for (var i = 0; i < length; i++) { - if(arguments[i] === Infinity || arguments[i] === -Infinity) { + if (arguments[i] === Infinity || arguments[i] === -Infinity) { return Infinity; } y += arguments[i] * arguments[i]; } return Math.sqrt(y); -}; + }; ``` Voici une seconde version qui évite les dépassements : diff --git a/files/fr/web/javascript/reference/global_objects/math/imul/index.md b/files/fr/web/javascript/reference/global_objects/math/imul/index.md index bda445db123742..269ac7ead79558 100644 --- a/files/fr/web/javascript/reference/global_objects/math/imul/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/imul/index.md @@ -13,7 +13,7 @@ La fonction **`Math.imul()`** renvoie le résultat de la multiplication de deux ## Syntaxe ```js -Math.imul(a, b) +Math.imul(a, b); ``` ### Paramètres @@ -36,9 +36,9 @@ Le résultat de la multiplication sur 32 bits des valeurs passées en argument ( ### Utiliser `Math.imul()` ```js -Math.imul(2, 4); // 8 -Math.imul(-1, 8); //-8 -Math.imul(-2, -2); // 4 +Math.imul(2, 4); // 8 +Math.imul(-1, 8); //-8 +Math.imul(-2, -2); // 4 Math.imul(0xffffffff, 5); //-5 Math.imul(0xfffffffe, 5); //-10 ``` @@ -48,15 +48,17 @@ Math.imul(0xfffffffe, 5); //-10 Si elle n'est pas disponible, cette fonction peut être émulée de la façon suivante : ```js -Math.imul = Math.imul || function(a, b) { - var ah = (a >>> 16) & 0xffff; - var al = a & 0xffff; - var bh = (b >>> 16) & 0xffff; - var bl = b & 0xffff; - // Le décalage par 0 rétablit le signe de la partie haute - // le |0 final convertit la valeur non-signée en une valeur signée - return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0); -}; +Math.imul = + Math.imul || + function (a, b) { + var ah = (a >>> 16) & 0xffff; + var al = a & 0xffff; + var bh = (b >>> 16) & 0xffff; + var bl = b & 0xffff; + // Le décalage par 0 rétablit le signe de la partie haute + // le |0 final convertit la valeur non-signée en une valeur signée + return (al * bl + (((ah * bl + al * bh) << 16) >>> 0)) | 0; + }; ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/math/ln10/index.md b/files/fr/web/javascript/reference/global_objects/math/ln10/index.md index 33181d830020fc..e9f71bfd48e6bc 100644 --- a/files/fr/web/javascript/reference/global_objects/math/ln10/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/ln10/index.md @@ -24,7 +24,7 @@ La fonction suivante renvoie le logarithme naturel de 10 : ```js function getNatLog10() { - return Math.LN10; + return Math.LN10; } getNatLog10(); // 2.302585092994046 diff --git a/files/fr/web/javascript/reference/global_objects/math/log/index.md b/files/fr/web/javascript/reference/global_objects/math/log/index.md index 9d05dc5f67f088..dc7163d21d50ee 100644 --- a/files/fr/web/javascript/reference/global_objects/math/log/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/log/index.md @@ -15,7 +15,7 @@ La fonction **`Math.log()`** renvoie le logarithme naturel (aussi appelé logari ## Syntaxe ```js -Math.log(x) +Math.log(x); ``` ### Paramètres @@ -39,8 +39,8 @@ Si la valeur de l'argument est négative, la valeur renvoyée sera {{jsxref("NaN ```js Math.log(-1); // NaN, valeur en dehors de l'intervalle de définition -Math.log(0); // -Infinity -Math.log(1); // 0 +Math.log(0); // -Infinity +Math.log(1); // 0 Math.log(10); // 2.302585092994046 ``` @@ -50,7 +50,7 @@ La fonction suivante renvoie le logarithme de `y` en base `x` (c'est-à-dire log ```js function getBaseLog(x, y) { - return Math.log(y) / Math.log(x); + return Math.log(y) / Math.log(x); } ``` From 618b92196dbf55ead65be1edf5086baf80a7d49e Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 01:44:16 -0700 Subject: [PATCH 10/30] fr: Format /web/javascript using Prettier (part 5) (#14643) From fca90a8dfe2408df46ccb8c7ce5abbc1d255cba8 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 01:46:33 -0700 Subject: [PATCH 11/30] fr: Format /web/javascript using Prettier (part 7) (#14645) --- .../global_objects/math/log10/index.md | 18 +- .../global_objects/math/log10e/index.md | 2 +- .../global_objects/math/log1p/index.md | 14 +- .../global_objects/math/log2/index.md | 12 +- .../global_objects/math/log2e/index.md | 2 +- .../global_objects/math/min/index.md | 3 +- .../reference/global_objects/math/pi/index.md | 2 +- .../global_objects/math/pow/index.md | 4 +- .../global_objects/math/random/index.md | 4 +- .../global_objects/math/round/index.md | 8 +- .../global_objects/math/sign/index.md | 18 +- .../global_objects/math/sin/index.md | 6 +- .../global_objects/math/sinh/index.md | 20 +- .../global_objects/math/sqrt/index.md | 10 +- .../global_objects/math/sqrt1_2/index.md | 2 +- .../global_objects/math/sqrt2/index.md | 2 +- .../global_objects/math/tan/index.md | 6 +- .../global_objects/math/tanh/index.md | 39 ++- .../global_objects/math/trunc/index.md | 18 +- .../reference/global_objects/nan/index.md | 12 +- .../global_objects/number/epsilon/index.md | 4 +- .../reference/global_objects/number/index.md | 26 +- .../global_objects/number/isfinite/index.md | 47 +-- .../global_objects/number/isinteger/index.md | 38 ++- .../global_objects/number/isnan/index.md | 8 +- .../number/issafeinteger/index.md | 18 +- .../number/max_safe_integer/index.md | 4 +- .../global_objects/number/max_value/index.md | 4 +- .../number/min_safe_integer/index.md | 5 +- .../global_objects/number/min_value/index.md | 4 +- .../global_objects/number/nan/index.md | 2 +- .../number/negative_infinity/index.md | 4 +- .../global_objects/number/number/index.md | 10 +- .../global_objects/number/parsefloat/index.md | 4 +- .../global_objects/number/parseint/index.md | 2 +- .../number/positive_infinity/index.md | 4 +- .../number/toexponential/index.md | 8 +- .../global_objects/number/tofixed/index.md | 24 +- .../number/tolocalestring/index.md | 29 +- .../number/toprecision/index.md | 12 +- .../global_objects/number/tostring/index.md | 15 +- .../global_objects/number/valueof/index.md | 6 +- .../object/__definegetter__/index.md | 19 +- .../object/__definesetter__/index.md | 23 +- .../object/__lookupgetter__/index.md | 10 +- .../object/__lookupsetter__/index.md | 8 +- .../global_objects/object/assign/index.md | 53 ++-- .../object/constructor/index.md | 53 ++-- .../global_objects/object/create/index.md | 53 ++-- .../object/defineproperties/index.md | 31 +- .../object/defineproperty/index.md | 193 +++++++----- .../global_objects/object/entries/index.md | 40 ++- .../global_objects/object/freeze/index.md | 42 ++- .../object/fromentries/index.md | 14 +- .../object/getownpropertydescriptor/index.md | 15 +- .../object/getownpropertydescriptors/index.md | 15 +- .../object/getownpropertynames/index.md | 39 +-- .../object/getownpropertysymbols/index.md | 6 +- .../object/getprototypeof/index.md | 2 +- .../global_objects/object/hasown/index.md | 44 +-- .../object/hasownproperty/index.md | 46 ++- .../reference/global_objects/object/index.md | 2 +- .../global_objects/object/is/index.md | 29 +- .../object/isextensible/index.md | 2 +- .../global_objects/object/isfrozen/index.md | 2 +- .../object/isprototypeof/index.md | 2 +- .../global_objects/object/issealed/index.md | 10 +- .../global_objects/object/keys/index.md | 22 +- .../global_objects/object/object/index.md | 4 +- .../object/preventextensions/index.md | 2 +- .../object/propertyisenumerable/index.md | 50 +-- .../global_objects/object/proto/index.md | 21 +- .../global_objects/object/seal/index.md | 14 +- .../object/setprototypeof/index.md | 86 ++--- .../object/tolocalestring/index.md | 2 +- .../global_objects/object/tostring/index.md | 28 +- .../global_objects/object/valueof/index.md | 14 +- .../global_objects/object/values/index.md | 17 +- .../global_objects/parsefloat/index.md | 31 +- .../global_objects/parseint/index.md | 31 +- .../global_objects/promise/all/index.md | 75 +++-- .../global_objects/promise/any/index.md | 37 ++- .../global_objects/promise/catch/index.md | 85 ++--- .../global_objects/promise/finally/index.md | 22 +- .../reference/global_objects/promise/index.md | 167 ++++++---- .../global_objects/promise/promise/index.md | 2 +- .../global_objects/promise/race/index.md | 78 ++--- .../global_objects/promise/reject/index.md | 13 +- .../global_objects/promise/resolve/index.md | 80 +++-- .../global_objects/promise/then/index.md | 20 +- .../reference/global_objects/proxy/index.md | 297 +++++++++--------- .../global_objects/proxy/proxy/apply/index.md | 11 +- .../proxy/proxy/construct/index.md | 30 +- .../proxy/proxy/defineproperty/index.md | 16 +- .../proxy/proxy/deleteproperty/index.md | 18 +- .../global_objects/proxy/proxy/get/index.md | 26 +- .../proxy/getownpropertydescriptor/index.md | 24 +- .../proxy/proxy/getprototypeof/index.md | 40 +-- .../global_objects/proxy/proxy/has/index.md | 24 +- .../proxy/proxy/isextensible/index.md | 33 +- 100 files changed, 1455 insertions(+), 1198 deletions(-) diff --git a/files/fr/web/javascript/reference/global_objects/math/log10/index.md b/files/fr/web/javascript/reference/global_objects/math/log10/index.md index a9c5f3901523ff..f0b406e6475ae1 100644 --- a/files/fr/web/javascript/reference/global_objects/math/log10/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/log10/index.md @@ -15,7 +15,7 @@ La fonction **`Math.log10()`** renvoie le logarithme en base 10 d'un nombre, don ## Syntaxe ```js -Math.log10(x) +Math.log10(x); ``` ### Paramètres @@ -38,10 +38,10 @@ Si la valeur de l'argument est strictement inférieure à 0, la valeur renvoyée ### Utiliser `Math.log10()` ```js -Math.log10(2); // 0.3010299956639812 -Math.log10(1); // 0 -Math.log10(0); // -Infinity -Math.log10(-2); // NaN +Math.log10(2); // 0.3010299956639812 +Math.log10(1); // 0 +Math.log10(0); // -Infinity +Math.log10(-2); // NaN Math.log10(100000); // 5 ``` @@ -50,9 +50,11 @@ Math.log10(100000); // 5 Il est possible d'avoir un résultat approximatif avec la fonction suivante : ```js -Math.log10 = Math.log10 || function(x) { - return Math.log(x) * Math.LOG10E; -}; +Math.log10 = + Math.log10 || + function (x) { + return Math.log(x) * Math.LOG10E; + }; ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/math/log10e/index.md b/files/fr/web/javascript/reference/global_objects/math/log10e/index.md index 0456dd9d3d985e..95c415f05f586d 100644 --- a/files/fr/web/javascript/reference/global_objects/math/log10e/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/log10e/index.md @@ -24,7 +24,7 @@ La fonction suivante renvoie le logarithme en base 10 de e : ```js function getLog10e() { - return Math.LOG10E; + return Math.LOG10E; } getLog10e(); // 0.4342944819032518 diff --git a/files/fr/web/javascript/reference/global_objects/math/log1p/index.md b/files/fr/web/javascript/reference/global_objects/math/log1p/index.md index a9bb67b65480dd..3cdc5ac368834b 100644 --- a/files/fr/web/javascript/reference/global_objects/math/log1p/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/log1p/index.md @@ -15,7 +15,7 @@ La fonction **`Math.log1p()`** renvoie le logarithme népérien (en base {{jsxre ## Syntaxe ```js -Math.log1p(x) +Math.log1p(x); ``` ### Paramètres @@ -38,8 +38,8 @@ Si `x` est strictement inférieur à -1, la valeur renvoyée est {{jsxref("NaN") ### Utiliser `Math.log1p()` ```js -Math.log1p(1); // 0.6931471805599453 -Math.log1p(0); // 0 +Math.log1p(1); // 0.6931471805599453 +Math.log1p(0); // 0 Math.log1p(-1); // -Infinity Math.log1p(-2); // NaN ``` @@ -49,9 +49,11 @@ Math.log1p(-2); // NaN Si cette fonction n'est pas disponible, elle peut être définie grâce au code suivant : ```js -Math.log1p = Math.log1p || function(x) { - return Math.log(1 + x); -}; +Math.log1p = + Math.log1p || + function (x) { + return Math.log(1 + x); + }; ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/math/log2/index.md b/files/fr/web/javascript/reference/global_objects/math/log2/index.md index b895cf0ffddb92..681ef2abd49ae8 100644 --- a/files/fr/web/javascript/reference/global_objects/math/log2/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/log2/index.md @@ -15,7 +15,7 @@ La fonction **`Math.log2()`** renvoie le logarithme en base 2 d'un nombre : ## Syntaxe ```js -Math.log2(x) +Math.log2(x); ``` ### Paramètres @@ -38,11 +38,11 @@ Si `x` est strictement inférieur à 0, la valeur renvoyée sera {{jsxref("NaN") ### Utiliser `Math.log2()` ```js -Math.log2(3); // 1.584962500721156 -Math.log2(2); // 1 -Math.log2(1); // 0 -Math.log2(0); // -Infinity -Math.log2(-2); // NaN +Math.log2(3); // 1.584962500721156 +Math.log2(2); // 1 +Math.log2(1); // 0 +Math.log2(0); // -Infinity +Math.log2(-2); // NaN Math.log2(1024); // 10 ``` diff --git a/files/fr/web/javascript/reference/global_objects/math/log2e/index.md b/files/fr/web/javascript/reference/global_objects/math/log2e/index.md index 92321754c5525b..c1e56c2ea4e242 100644 --- a/files/fr/web/javascript/reference/global_objects/math/log2e/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/log2e/index.md @@ -24,7 +24,7 @@ La fonction suivante renvoie la valeur du logarithme en base 2 de e : ```js function getLog2e() { - return Math.LOG2E; + return Math.LOG2E; } getLog2e(); // 1.4426950408889634 diff --git a/files/fr/web/javascript/reference/global_objects/math/min/index.md b/files/fr/web/javascript/reference/global_objects/math/min/index.md index c3927c55aa604b..55c86e3db603ca 100644 --- a/files/fr/web/javascript/reference/global_objects/math/min/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/min/index.md @@ -40,7 +40,8 @@ Si au moins un des arguments ne peut pas être converti en un nombre, le résult Dans cet exemple, on trouve le minimum de x et y et on affecte cette valeur à z : ```js -var x = 10, y = -20; +var x = 10, + y = -20; var z = Math.min(x, y); ``` diff --git a/files/fr/web/javascript/reference/global_objects/math/pi/index.md b/files/fr/web/javascript/reference/global_objects/math/pi/index.md index d8c8535905e636..487377bbc09c7a 100644 --- a/files/fr/web/javascript/reference/global_objects/math/pi/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/pi/index.md @@ -27,7 +27,7 @@ function calculPérimètre(rayon) { return 2 * Math.PI * rayon; } -calculPérimètre(1); // 6.283185307179586 +calculPérimètre(1); // 6.283185307179586 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/math/pow/index.md b/files/fr/web/javascript/reference/global_objects/math/pow/index.md index a7331eeab2e4a6..3e3430f7372d4b 100644 --- a/files/fr/web/javascript/reference/global_objects/math/pow/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/pow/index.md @@ -43,12 +43,12 @@ Math.pow(7, 2); // 49 Math.pow(7, -2); // 0.02040816326530612 (1/49) // Exposants fractionnaires -Math.pow(2, 1/2); // 1.4142135623730951 (racine carrée de 2) +Math.pow(2, 1 / 2); // 1.4142135623730951 (racine carrée de 2) // Cas aux limites Math.pow(-7, 0.5); // NaN // (les nombres négatifs n'ont pas de racine carrée) -Math.pow(-7, 1/3); // NaN +Math.pow(-7, 1 / 3); // NaN // Nombre négatif avec une base décimale ``` diff --git a/files/fr/web/javascript/reference/global_objects/math/random/index.md b/files/fr/web/javascript/reference/global_objects/math/random/index.md index fe084f9aa242b4..fa70b7efe7a217 100644 --- a/files/fr/web/javascript/reference/global_objects/math/random/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/random/index.md @@ -15,7 +15,7 @@ La fonction **`Math.random()`** renvoie un nombre flottant pseudo-aléatoire com ## Syntaxe ```js -Math.random() +Math.random(); ``` ### Valeur de retour @@ -71,7 +71,7 @@ function getRandomInt(min, max) { function getRandomIntInclusive(min, max) { min = Math.ceil(min); max = Math.floor(max); - return Math.floor(Math.random() * (max - min +1)) + min; + return Math.floor(Math.random() * (max - min + 1)) + min; } ``` diff --git a/files/fr/web/javascript/reference/global_objects/math/round/index.md b/files/fr/web/javascript/reference/global_objects/math/round/index.md index 9ce761734d3029..a57253225fab04 100644 --- a/files/fr/web/javascript/reference/global_objects/math/round/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/round/index.md @@ -13,7 +13,7 @@ La fonction **`Math.round()`** retourne la valeur d'un nombre arrondi à l'entie ## Syntaxe ```js -Math.round(x) +Math.round(x); ``` ### Paramètres @@ -35,10 +35,10 @@ Si la partie décimale du nombre est plus grande que 0.5, l'argument est arrondi ```js Math.round(20.49); // 20 -Math.round(20.5); // 21 -Math.round(42); // 42 +Math.round(20.5); // 21 +Math.round(42); // 42 Math.round(-20.5); // -20 -Math.round(-20.51);// -21 +Math.round(-20.51); // -21 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/math/sign/index.md b/files/fr/web/javascript/reference/global_objects/math/sign/index.md index c56848eea1a340..31139df4cb27b9 100644 --- a/files/fr/web/javascript/reference/global_objects/math/sign/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/sign/index.md @@ -13,7 +13,7 @@ La fonction **`Math.sign()`** renvoie le signe d'un nombre et permet de savoir s ## Syntaxe ```js -Math.sign(x) +Math.sign(x); ``` ### Paramètres @@ -36,14 +36,14 @@ L'argument passé à cette fonction sera implicitement converti au type `number` ## Exemples ```js -Math.sign(3) // 1 -Math.sign(-3) // -1 -Math.sign("-3") // -1 -Math.sign(0) // 0 -Math.sign(-0) // -0 -Math.sign(NaN) // NaN -Math.sign("foo") // NaN -Math.sign() // NaN +Math.sign(3); // 1 +Math.sign(-3); // -1 +Math.sign("-3"); // -1 +Math.sign(0); // 0 +Math.sign(-0); // -0 +Math.sign(NaN); // NaN +Math.sign("foo"); // NaN +Math.sign(); // NaN ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/math/sin/index.md b/files/fr/web/javascript/reference/global_objects/math/sin/index.md index e948186ac70c70..4a0a16a817f6a4 100644 --- a/files/fr/web/javascript/reference/global_objects/math/sin/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/sin/index.md @@ -13,7 +13,7 @@ La fonction **`Math.sin()`** renvoie le sinus d'un nombre. ## Syntaxe ```js -Math.sin(x) +Math.sin(x); ``` ### Paramètres @@ -34,8 +34,8 @@ La méthode `sin()` renvoie une valeur numérique comprise (au sens large) entre ## Exemples ```js -Math.sin(0); // 0 -Math.sin(1); // 0.8414709848078965 +Math.sin(0); // 0 +Math.sin(1); // 0.8414709848078965 Math.sin(Math.PI / 2); // 1 ``` diff --git a/files/fr/web/javascript/reference/global_objects/math/sinh/index.md b/files/fr/web/javascript/reference/global_objects/math/sinh/index.md index 1524b4e44d7d21..5ec0bff22d8a69 100644 --- a/files/fr/web/javascript/reference/global_objects/math/sinh/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/sinh/index.md @@ -15,7 +15,7 @@ La fonction **`Math.sinh()`** renvoie le sinus hyperbolique d'un nombre, dont la ## Syntaxe ```js -Math.sinh(x) +Math.sinh(x); ``` ### Paramètres @@ -34,8 +34,8 @@ Le sinus hyperbolique de la valeur passée en argument. ## Exemples ```js -Math.sinh(0) // 0 -Math.sinh(1) // 1.1752011936438014 +Math.sinh(0); // 0 +Math.sinh(1); // 1.1752011936438014 ``` ## Prothèse d'émulation (_polyfill_) @@ -43,18 +43,22 @@ Math.sinh(1) // 1.1752011936438014 Si cette fonction n'est pas disponible, elle peut être émulée en utilisant la fonction {{jsxref("Math.exp()")}} : ```js -Math.sinh = Math.sinh || function(x){ +Math.sinh = + Math.sinh || + function (x) { return (Math.exp(x) - Math.exp(-x)) / 2; -}; + }; ``` ou encore, si on n'utilise qu'une fois {{jsxref("Math.exp()")}}, avec : ```js -Math.sinh = Math.sinh || function(x){ +Math.sinh = + Math.sinh || + function (x) { var y = Math.exp(x); - return (y - 1/y) / 2; -}; + return (y - 1 / y) / 2; + }; ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/math/sqrt/index.md b/files/fr/web/javascript/reference/global_objects/math/sqrt/index.md index 3806d072afc9ed..37791e181aa1c1 100644 --- a/files/fr/web/javascript/reference/global_objects/math/sqrt/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/sqrt/index.md @@ -15,7 +15,7 @@ La fonction **`Math.sqrt()`** renvoie la racine carrée d'un nombre. Cette fonct ## Syntaxe ```js -Math.sqrt(x) +Math.sqrt(x); ``` ### Paramètres @@ -36,11 +36,11 @@ Si la valeur de `x` est négative, `sqrt` renverra {{jsxref("NaN")}}. ## Exemples ```js -Math.sqrt(9); // 3 -Math.sqrt(2); // 1.414213562373095 +Math.sqrt(9); // 3 +Math.sqrt(2); // 1.414213562373095 -Math.sqrt(1); // 1 -Math.sqrt(0); // 0 +Math.sqrt(1); // 1 +Math.sqrt(0); // 0 Math.sqrt(-1); // NaN Math.sqrt(-0); // -0 ``` diff --git a/files/fr/web/javascript/reference/global_objects/math/sqrt1_2/index.md b/files/fr/web/javascript/reference/global_objects/math/sqrt1_2/index.md index 2cfcc1448d2732..c2e81737ff2f26 100644 --- a/files/fr/web/javascript/reference/global_objects/math/sqrt1_2/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/sqrt1_2/index.md @@ -22,7 +22,7 @@ La fonction suivante renvoie la valeur de cette constante : ```js function getRoot1_2() { - return Math.SQRT1_2; + return Math.SQRT1_2; } getRoot1_2(); // 0.7071067811865476 diff --git a/files/fr/web/javascript/reference/global_objects/math/sqrt2/index.md b/files/fr/web/javascript/reference/global_objects/math/sqrt2/index.md index 6cc3ffc189e8ab..b64763679ea920 100644 --- a/files/fr/web/javascript/reference/global_objects/math/sqrt2/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/sqrt2/index.md @@ -22,7 +22,7 @@ La fonction suivante renvoie la valeur de la racine carrée de 2 : ```js function getRoot2() { - return Math.SQRT2; + return Math.SQRT2; } getRoot2(); // 1.4142135623730951 diff --git a/files/fr/web/javascript/reference/global_objects/math/tan/index.md b/files/fr/web/javascript/reference/global_objects/math/tan/index.md index 7b261b4bb548d8..5ff8d3ee401f52 100644 --- a/files/fr/web/javascript/reference/global_objects/math/tan/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/tan/index.md @@ -13,7 +13,7 @@ La fonction **`Math.tan()`** renvoie la tangente d'un nombre exprimant un angle ## Syntaxe ```js -Math.tan(x) +Math.tan(x); ``` ### Paramètres @@ -43,8 +43,8 @@ Math.tan(1); // 1.5574077246549023 ```js function getTanDeg(deg) { - var rad = deg * Math.PI/180; - return Math.tan(rad); + var rad = (deg * Math.PI) / 180; + return Math.tan(rad); } ``` diff --git a/files/fr/web/javascript/reference/global_objects/math/tanh/index.md b/files/fr/web/javascript/reference/global_objects/math/tanh/index.md index cbf3994befbe5e..56cd4e356d7861 100644 --- a/files/fr/web/javascript/reference/global_objects/math/tanh/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/tanh/index.md @@ -15,7 +15,7 @@ La fonction **`Math.tanh()`** renvoie la tangente hyperbolique d'un nombre défi ## Syntaxe ```js -Math.tanh(x) +Math.tanh(x); ``` ### Paramètres @@ -36,9 +36,9 @@ La tangente hyperbolique du nombre fourni en argument. ### Utiliser `Math.tanh()` ```js -Math.tanh(0); // 0 +Math.tanh(0); // 0 Math.tanh(Infinity); // 1 -Math.tanh(1); // 0.7615941559557649 +Math.tanh(1); // 0.7615941559557649 ``` ## Prothèse d'émulation (_polyfill_) @@ -46,25 +46,30 @@ Math.tanh(1); // 0.7615941559557649 Cette méthode peut être émulée grâce à la fonction {{jsxref("Objets_globaux/Math/exp", "Math.exp()")}} : ```js -Math.tanh = Math.tanh || function(x){ - var a = Math.exp(+x), b = Math.exp(-x); - return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (a + b); -} +Math.tanh = + Math.tanh || + function (x) { + var a = Math.exp(+x), + b = Math.exp(-x); + return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (a + b); + }; ``` et si on souhaite n'utiliser qu'un seul appel à {{jsxref("Objets_globaux/Math/exp", "Math.exp()")}} : ```js -Math.tanhx = Math.tanhx || function(x) { - if(x === Infinity) { - return 1; - } else if(x === -Infinity) { - return -1; - } else { - var y = Math.exp(2 * x); - return (y - 1) / (y + 1); - } -}; +Math.tanhx = + Math.tanhx || + function (x) { + if (x === Infinity) { + return 1; + } else if (x === -Infinity) { + return -1; + } else { + var y = Math.exp(2 * x); + return (y - 1) / (y + 1); + } + }; ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/math/trunc/index.md b/files/fr/web/javascript/reference/global_objects/math/trunc/index.md index 54246d80e085fc..647218a0142d48 100644 --- a/files/fr/web/javascript/reference/global_objects/math/trunc/index.md +++ b/files/fr/web/javascript/reference/global_objects/math/trunc/index.md @@ -15,7 +15,7 @@ La fonction **`Math.trunc()`** retourne la troncature entière d'un nombre en re ## Syntaxe ```js -Math.trunc(x) +Math.trunc(x); ``` ### Paramètres @@ -42,14 +42,14 @@ On notera que l'argument passé à la méthode est converti en nombre de façon ### Utiliser `Math.trunc()` ```js -Math.trunc(13.37); // 13 -Math.trunc(42.84); // 42 -Math.trunc(0.123); // 0 -Math.trunc(-0.123); // -0 -Math.trunc("-1.123");// -1 -Math.trunc(NaN); // NaN -Math.trunc("toto"); // NaN -Math.trunc(); // NaN +Math.trunc(13.37); // 13 +Math.trunc(42.84); // 42 +Math.trunc(0.123); // 0 +Math.trunc(-0.123); // -0 +Math.trunc("-1.123"); // -1 +Math.trunc(NaN); // NaN +Math.trunc("toto"); // NaN +Math.trunc(); // NaN ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/nan/index.md b/files/fr/web/javascript/reference/global_objects/nan/index.md index 157202d88fe26b..f7ac7369586616 100644 --- a/files/fr/web/javascript/reference/global_objects/nan/index.md +++ b/files/fr/web/javascript/reference/global_objects/nan/index.md @@ -15,7 +15,7 @@ La propriété globale **`NaN`** est une valeur utilisée pour représenter une ## Syntaxe ```js -NaN +NaN; ``` ## Description @@ -31,17 +31,17 @@ Il est rare d'utiliser expressément `NaN` dans un programme. On récupère gén Les [opérateurs d'égalité](/fr/docs/Web/JavaScript/Les_différents_tests_d_égalité_comment_les_utiliser) (`==` et `===`) ne peuvent pas être utilisé pour tester une valeur par rapport à `NaN`. Il faut utiliser {{jsxref("Number.isNaN()")}} ou {{jsxref("isNaN", "isNaN()")}} à la place. ```js -NaN === NaN; // false +NaN === NaN; // false Number.NaN === NaN; // false -isNaN(NaN); // true -isNaN(Number.NaN); // true +isNaN(NaN); // true +isNaN(Number.NaN); // true ``` La différence entre `isNaN()` et `Number.isNaN()` est la façon dont les valeurs sont, ou non, converties en nombre avant de vérifier si la valeur est `NaN` : `isNaN()` convertira l'argument en nombre avant de vérifier alors que `Number.isNaN()` ne renverra `true` que si l'opérande vaut `NaN`. ```js -isNaN('coucou monde'); // renvoie true -Number.isNaN('coucou monde'); // renvoie false +isNaN("coucou monde"); // renvoie true +Number.isNaN("coucou monde"); // renvoie false ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/number/epsilon/index.md b/files/fr/web/javascript/reference/global_objects/number/epsilon/index.md index 6139ccfa2cc7e6..781d19e955eee0 100644 --- a/files/fr/web/javascript/reference/global_objects/number/epsilon/index.md +++ b/files/fr/web/javascript/reference/global_objects/number/epsilon/index.md @@ -23,14 +23,14 @@ La propriété `EPSILON` vaut environ `2.2204460492503130808472633361816E-16` (c ```js x = 0.2; y = 0.3; -equal = (Math.abs(x - y) < Number.EPSILON); +equal = Math.abs(x - y) < Number.EPSILON; ``` ## Prothèse d'émulation (_polyfill_) ```js if (Number.EPSILON === undefined) { - Number.EPSILON = Math.pow(2, -52); + Number.EPSILON = Math.pow(2, -52); } ``` diff --git a/files/fr/web/javascript/reference/global_objects/number/index.md b/files/fr/web/javascript/reference/global_objects/number/index.md index a80e01618c817c..7949d1522c3a07 100644 --- a/files/fr/web/javascript/reference/global_objects/number/index.md +++ b/files/fr/web/javascript/reference/global_objects/number/index.md @@ -14,8 +14,8 @@ Le type JavaScript `Number` utilise [une représentation binaire à précision d ```js new Number(valeur); -var a = new Number('123'); // a === 123 donnera false -var b = Number('123'); // b === 123 donnera true +var a = new Number("123"); // a === 123 donnera false +var b = Number("123"); // b === 123 donnera true a instanceof Number; // donnera true b instanceof Number; // donnera false ``` @@ -119,7 +119,7 @@ Lorsqu'on analyse et convertit des données JSON, les valeurs en dehors de cet i Dans l'exemple suivant, on convertit un objet {{jsxref("Date")}} en une valeur numérique grâce à la fonction `Number` : ```js -var d = new Date('December 17, 1995 03:24:00'); +var d = new Date("December 17, 1995 03:24:00"); console.log(Number(d)); ``` @@ -128,16 +128,16 @@ Ceci affichera "819167040000". ### Convertir une chaîne représentant une valeur numérique en un nombre ```js -Number("123"); // 123 -Number("12.3"); // 12.3 -Number("12.00"); // 12 -Number("123e-1"); // 12.3 -Number(""); // 0 -Number("0x11"); // 17 -Number("0b11"); // 3 -Number("0o11"); // 9 -Number("toto"); // NaN -Number("100a"); // NaN +Number("123"); // 123 +Number("12.3"); // 12.3 +Number("12.00"); // 12 +Number("123e-1"); // 12.3 +Number(""); // 0 +Number("0x11"); // 17 +Number("0b11"); // 3 +Number("0o11"); // 9 +Number("toto"); // NaN +Number("100a"); // NaN Number("-Infinity"); // -Infinity ``` diff --git a/files/fr/web/javascript/reference/global_objects/number/isfinite/index.md b/files/fr/web/javascript/reference/global_objects/number/isfinite/index.md index 23a5d743097d85..02a5b349aa1936 100644 --- a/files/fr/web/javascript/reference/global_objects/number/isfinite/index.md +++ b/files/fr/web/javascript/reference/global_objects/number/isfinite/index.md @@ -32,18 +32,18 @@ Par rapport à la fonction de l'objet global {{jsxref("isFinite","isFinite()")}} ## Exemples ```js -Number.isFinite(Infinity); // false -Number.isFinite(NaN); // false +Number.isFinite(Infinity); // false +Number.isFinite(NaN); // false Number.isFinite(-Infinity); // false -Number.isFinite(0); // true -Number.isFinite(2e64); // true +Number.isFinite(0); // true +Number.isFinite(2e64); // true -Number.isFinite("0"); // false, ce qui aurait - // renvoyé true avec isFinite("0") +Number.isFinite("0"); // false, ce qui aurait +// renvoyé true avec isFinite("0") -Number.isFinite(null); // false, ce qui aurait - // renvoyé true avc isFinite(null) +Number.isFinite(null); // false, ce qui aurait +// renvoyé true avc isFinite(null) ``` ## Prothèse d'émulation (_polyfill_) @@ -51,28 +51,29 @@ Number.isFinite(null); // false, ce qui aurait ```js // Number.isFinite polyfill // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite -if (typeof Number.isFinite !== 'function') { - Number.isFinite = function isFinite(value) { - // 1. Si Type(number) n'est pas Number, on renvoie false. - if (typeof value !== 'number') { - return false; - } - // 2. Si le nombre est NaN, +∞, ou −∞, on renvoie false. - if (value !== value || value === Infinity || value === -Infinity) { - return false; - } - // 3. Sinon on renvoie true. - return true; - }; +if (typeof Number.isFinite !== "function") { + Number.isFinite = function isFinite(value) { + // 1. Si Type(number) n'est pas Number, on renvoie false. + if (typeof value !== "number") { + return false; + } + // 2. Si le nombre est NaN, +∞, ou −∞, on renvoie false. + if (value !== value || value === Infinity || value === -Infinity) { + return false; + } + // 3. Sinon on renvoie true. + return true; + }; } ``` Deuxième version plus concise qui utilise la méthode globale `isFinite` ```js -if (Number.isFinite === undefined) Number.isFinite = function(value) { +if (Number.isFinite === undefined) + Number.isFinite = function (value) { return typeof value === "number" && isFinite(value); -} + }; ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/number/isinteger/index.md b/files/fr/web/javascript/reference/global_objects/number/isinteger/index.md index 6512cf17f0fb02..a42b8423eb2e0a 100644 --- a/files/fr/web/javascript/reference/global_objects/number/isinteger/index.md +++ b/files/fr/web/javascript/reference/global_objects/number/isinteger/index.md @@ -13,7 +13,7 @@ La méthode **`Number.isInteger()`** permet de déterminer si l'argument est un ## Syntaxe ```js -Number.isInteger(valeurÀTester) +Number.isInteger(valeurÀTester); ``` ### Paramètres @@ -32,33 +32,37 @@ Si la valeur à tester est un entier, cette méthode renvoie `true`, `false` sin ## Exemples ```js -Number.isInteger(1); // true -Number.isInteger(-100000); // true -Number.isInteger(0); // true -Number.isInteger(1.000) // true +Number.isInteger(1); // true +Number.isInteger(-100000); // true +Number.isInteger(0); // true +Number.isInteger(1.0); // true // Number.isInteger(9…9999); // true, même si le nombre dépasse 32 bits -Number.isInteger(0.1); // false -Number.isInteger(Math.PI); // false +Number.isInteger(0.1); // false +Number.isInteger(Math.PI); // false Number.isInteger(-Infinity); // false -Number.isInteger(true); // false -Number.isInteger(NaN); // false -Number.isInteger("10"); // false +Number.isInteger(true); // false +Number.isInteger(NaN); // false +Number.isInteger("10"); // false -Number.isInteger(5.0); // true -Number.isInteger(5.000000000000001);// false +Number.isInteger(5.0); // true +Number.isInteger(5.000000000000001); // false Number.isInteger(5.0000000000000001); // true ``` ## Prothèse d'émulation (_polyfill_) ```js -Number.isInteger = Number.isInteger || function(value) { - return typeof value === "number" && - isFinite(value) && - Math.floor(value) === value; -}; +Number.isInteger = + Number.isInteger || + function (value) { + return ( + typeof value === "number" && + isFinite(value) && + Math.floor(value) === value + ); + }; ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/number/isnan/index.md b/files/fr/web/javascript/reference/global_objects/number/isnan/index.md index 1ad8ba34a16154..9324d615dc1c79 100644 --- a/files/fr/web/javascript/reference/global_objects/number/isnan/index.md +++ b/files/fr/web/javascript/reference/global_objects/number/isnan/index.md @@ -13,7 +13,7 @@ La méthode **`Number.isNaN()`** permet de déterminer si la valeur passée en a ## Syntaxe ```js -Number.isNaN(valeurÀTester) +Number.isNaN(valeurÀTester); ``` ### Paramètres @@ -59,9 +59,11 @@ Number.isNaN("blabla"); // ex : cette valeur aurait rendu true avec la méthode La fonction suivant fonctionne car `NaN` est la seule valeur JavaScript qui n'est pas égale à elle-même. ```js -Number.isNaN = Number.isNaN || function(value) { +Number.isNaN = + Number.isNaN || + function (value) { return typeof value === "number" && isNaN(value); -} + }; ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/number/issafeinteger/index.md b/files/fr/web/javascript/reference/global_objects/number/issafeinteger/index.md index 36480757502652..e96c9624dcb0b4 100644 --- a/files/fr/web/javascript/reference/global_objects/number/issafeinteger/index.md +++ b/files/fr/web/javascript/reference/global_objects/number/issafeinteger/index.md @@ -15,7 +15,7 @@ La méthode **`Number.isSafeInteger()`** permet de déterminer si la valeur, pas ## Syntaxe ```js -Number.isSafeInteger(valeurÀTester) +Number.isSafeInteger(valeurÀTester); ``` ### Paramètres @@ -41,14 +41,14 @@ L'intervalle des entiers qui peuvent être correctement représentés est `[-(2^ ## Exemples ```js -Number.isSafeInteger(3); // true -Number.isSafeInteger(Math.pow(2, 53)) // false -Number.isSafeInteger(Math.pow(2, 53) - 1) // true -Number.isSafeInteger(NaN); // false -Number.isSafeInteger(Infinity); // false -Number.isSafeInteger("3"); // false -Number.isSafeInteger(3.1); // false -Number.isSafeInteger(3.0); // true +Number.isSafeInteger(3); // true +Number.isSafeInteger(Math.pow(2, 53)); // false +Number.isSafeInteger(Math.pow(2, 53) - 1); // true +Number.isSafeInteger(NaN); // false +Number.isSafeInteger(Infinity); // false +Number.isSafeInteger("3"); // false +Number.isSafeInteger(3.1); // false +Number.isSafeInteger(3.0); // true ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/number/max_safe_integer/index.md b/files/fr/web/javascript/reference/global_objects/number/max_safe_integer/index.md index 043fdc0c6f22e6..b3d4c7b0b4e332 100644 --- a/files/fr/web/javascript/reference/global_objects/number/max_safe_integer/index.md +++ b/files/fr/web/javascript/reference/global_objects/number/max_safe_integer/index.md @@ -25,8 +25,8 @@ Dans ce contexte, « sûr » fait référence à la capacité à représenter ex ## Exemples ```js -Number.MAX_SAFE_INTEGER // 9007199254740991 -Math.pow(2, 53) -1 // 9007199254740991 +Number.MAX_SAFE_INTEGER; // 9007199254740991 +Math.pow(2, 53) - 1; // 9007199254740991 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/number/max_value/index.md b/files/fr/web/javascript/reference/global_objects/number/max_value/index.md index 9b1b8da13a2658..834384334788f0 100644 --- a/files/fr/web/javascript/reference/global_objects/number/max_value/index.md +++ b/files/fr/web/javascript/reference/global_objects/number/max_value/index.md @@ -22,9 +22,9 @@ Le code suivant teste si le produit de deux nombres est inférieur ou égal à ` ```js if (num1 * num2 <= Number.MAX_VALUE) { - func1(); + func1(); } else { - func2(); + func2(); } ``` diff --git a/files/fr/web/javascript/reference/global_objects/number/min_safe_integer/index.md b/files/fr/web/javascript/reference/global_objects/number/min_safe_integer/index.md index df9e90636b983a..0a113f9e004dac 100644 --- a/files/fr/web/javascript/reference/global_objects/number/min_safe_integer/index.md +++ b/files/fr/web/javascript/reference/global_objects/number/min_safe_integer/index.md @@ -21,8 +21,9 @@ La constante `MIN_SAFE_INTEGER` vaut `-9007199254740991`. Cette valeur provient ## Exemples ```js -Number.MIN_SAFE_INTEGER // -9007199254740991 --Math.pow(2, 53) -1 // -9007199254740991 +Number.MIN_SAFE_INTEGER - // -9007199254740991 + Math.pow(2, 53) - + 1; // -9007199254740991 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/number/min_value/index.md b/files/fr/web/javascript/reference/global_objects/number/min_value/index.md index f04dae6fead7af..082a0e04450cdc 100644 --- a/files/fr/web/javascript/reference/global_objects/number/min_value/index.md +++ b/files/fr/web/javascript/reference/global_objects/number/min_value/index.md @@ -24,9 +24,9 @@ Le code qui suit effectue la division de deux nombres. Si le résultat obtenu es ```js if (num1 / num2 >= Number.MIN_VALUE) { - func1(); + func1(); } else { - func2(); + func2(); } ``` diff --git a/files/fr/web/javascript/reference/global_objects/number/nan/index.md b/files/fr/web/javascript/reference/global_objects/number/nan/index.md index 91739a2f4d762d..96fca95e2fc9d3 100644 --- a/files/fr/web/javascript/reference/global_objects/number/nan/index.md +++ b/files/fr/web/javascript/reference/global_objects/number/nan/index.md @@ -6,7 +6,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/NaN {{JSRef}} -La propriété **`Number.NaN`** représente une valeur qui n'est pas un nombre (en anglais « *Not-A-Number* » qui donne NaN). Elle est équivalente à {{jsxref("NaN")}}. +La propriété **`Number.NaN`** représente une valeur qui n'est pas un nombre (en anglais « _Not-A-Number_ » qui donne NaN). Elle est équivalente à {{jsxref("NaN")}}. {{EmbedInteractiveExample("pages/js/number-nan.html")}} diff --git a/files/fr/web/javascript/reference/global_objects/number/negative_infinity/index.md b/files/fr/web/javascript/reference/global_objects/number/negative_infinity/index.md index 4752c6249e65ae..eea997c31737fd 100644 --- a/files/fr/web/javascript/reference/global_objects/number/negative_infinity/index.md +++ b/files/fr/web/javascript/reference/global_objects/number/negative_infinity/index.md @@ -35,10 +35,10 @@ La propriété `Number.NEGATIVE_INFINITY` peut être utilisée pour indiquer une Dans l'exemple qui suit, on affecte une variable inférieure à la valeur numérique minimale à la variable `petitNombre`. Lorsque l'instruction conditionnelle `if` est exécutée, `petitNombre` possède la valeur "`-Infinity`", on modifie donc la valeur de `petitNombre` afin qu'il puisse être géré. ```js -var petitNombre = (-Number.MAX_VALUE) * 2 +var petitNombre = -Number.MAX_VALUE * 2; if (petitNombre === Number.NEGATIVE_INFINITY) { - petitNombre = renvoyerUneValeurFinie(); + petitNombre = renvoyerUneValeurFinie(); } ``` diff --git a/files/fr/web/javascript/reference/global_objects/number/number/index.md b/files/fr/web/javascript/reference/global_objects/number/number/index.md index 6d0128b02595f2..c7248341f19acd 100644 --- a/files/fr/web/javascript/reference/global_objects/number/number/index.md +++ b/files/fr/web/javascript/reference/global_objects/number/number/index.md @@ -11,7 +11,7 @@ Le **constructeur `Number()`** permet de créer un objet [`Number`](/fr/docs/Web ## Syntaxe ```js -new Number(valeur) +new Number(valeur); ``` ### Paramètres @@ -24,10 +24,10 @@ new Number(valeur) ### Créer des objets `Number` ```js -const a = new Number('123'); // a === 123 vaut false -const b = Number('123'); // b === 123 vaut true -a instanceof Number; // true -b instanceof Number; // false +const a = new Number("123"); // a === 123 vaut false +const b = Number("123"); // b === 123 vaut true +a instanceof Number; // true +b instanceof Number; // false ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/number/parsefloat/index.md b/files/fr/web/javascript/reference/global_objects/number/parsefloat/index.md index 86af8ff4996c09..8370c1400a998e 100644 --- a/files/fr/web/javascript/reference/global_objects/number/parsefloat/index.md +++ b/files/fr/web/javascript/reference/global_objects/number/parsefloat/index.md @@ -13,7 +13,7 @@ La méthode **`Number.parseFloat()`** analyse et convertit une chaîne de caract ## Syntaxe ```js -Number.parseFloat(chaîne) +Number.parseFloat(chaîne); ``` ### Paramètres @@ -39,7 +39,7 @@ Cette méthode fait partie d'ECMAScript 2015 et notamment de la modularisation d ```js if (Number.parseFloat === undefined) { - Number.parseFloat = parseFloat; + Number.parseFloat = parseFloat; } ``` diff --git a/files/fr/web/javascript/reference/global_objects/number/parseint/index.md b/files/fr/web/javascript/reference/global_objects/number/parseint/index.md index 3a7166a95f7942..6607b4cba06308 100644 --- a/files/fr/web/javascript/reference/global_objects/number/parseint/index.md +++ b/files/fr/web/javascript/reference/global_objects/number/parseint/index.md @@ -40,7 +40,7 @@ Number.parseInt === parseInt; // true Si on souhaite bénéficier de cette fonction dans un environnement qui n'en dispose pas, on pourra donc l'émuler de la façon suivante : ```js -if(Number.parseInt === undefined) { +if (Number.parseInt === undefined) { Number.parseInt = parseInt; } ``` diff --git a/files/fr/web/javascript/reference/global_objects/number/positive_infinity/index.md b/files/fr/web/javascript/reference/global_objects/number/positive_infinity/index.md index 3719dc9acac25a..f1e8ef168c8da3 100644 --- a/files/fr/web/javascript/reference/global_objects/number/positive_infinity/index.md +++ b/files/fr/web/javascript/reference/global_objects/number/positive_infinity/index.md @@ -39,9 +39,9 @@ Il est possible d'utiliser la propriété `Number.POSITIVE_INFINITY` pour faire Dans l'exemple qui suit, on affecte une valeur plus grande que la valeur maximale à la variable `grosNombre`. Lors de l'exécution de l'instruction `if`, `grosNombre` aura la valeur `Infinity`, pour continuer, on met à jour `grosNombre` avec une valeur plus acceptable. ```js -var grosNombre = Number.MAX_VALUE * 2 +var grosNombre = Number.MAX_VALUE * 2; if (grosNombre == Number.POSITIVE_INFINITY) { - grosNombre = renvoyerUnNombreFini(); + grosNombre = renvoyerUnNombreFini(); } ``` diff --git a/files/fr/web/javascript/reference/global_objects/number/toexponential/index.md b/files/fr/web/javascript/reference/global_objects/number/toexponential/index.md index 1a96aacb393060..71d033cd7523c3 100644 --- a/files/fr/web/javascript/reference/global_objects/number/toexponential/index.md +++ b/files/fr/web/javascript/reference/global_objects/number/toexponential/index.md @@ -13,7 +13,7 @@ La méthode **`toExponential()`** renvoie une chaîne de caractères, représent ## Syntaxe ```js -numObj.toExponential([nbChiffresDécimaux]) +numObj.toExponential([nbChiffresDécimaux]); ``` ### Paramètre @@ -47,11 +47,11 @@ Si un nombre possède plus de chiffres décimaux que `nbChiffresDécimaux`, le n ```js var numObj = 77.1234; -console.log(numObj.toExponential()); // affiche 7.71234e+1 +console.log(numObj.toExponential()); // affiche 7.71234e+1 console.log(numObj.toExponential(4)); // affiche 7.7123e+1 console.log(numObj.toExponential(2)); // affiche 7.71e+1 -console.log(77.1234.toExponential()); // affiche 7.71234e+1 -console.log(77 .toExponential()); // affiche 7.7e+1 +console.log((77.1234).toExponential()); // affiche 7.71234e+1 +console.log((77).toExponential()); // affiche 7.7e+1 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/number/tofixed/index.md b/files/fr/web/javascript/reference/global_objects/number/tofixed/index.md index 662d8e147c29dd..05876433d03b28 100644 --- a/files/fr/web/javascript/reference/global_objects/number/tofixed/index.md +++ b/files/fr/web/javascript/reference/global_objects/number/tofixed/index.md @@ -13,7 +13,7 @@ La méthode **`toFixed()`** permet de formater un nombre en notation à point-fi ## Syntaxe ```js -numObj.toFixed([nbChiffres]) +numObj.toFixed([nbChiffres]); ``` ### Paramètres @@ -43,17 +43,17 @@ Une chaîne de caractères qui représente le nombre indiqué avec une notation ```js var numObj = 12345.6789; -numObj.toFixed(); // Renvoie '12346' : arrondi, aucune partie fractionnaire -numObj.toFixed(1); // Renvoie '12345.7' : arrondi ici aussi -numObj.toFixed(6); // Renvoie '12345.678900' : des zéros sont ajoutés -(1.23e+20).toFixed(2); // Renvoie '123000000000000000000.00' -(1.23e-10).toFixed(2); // Renvoie '0.00' -2.34.toFixed(1); // Renvoie '2.3' --2.34.toFixed(1); // Renvoie -2.3 (en raison de la précédence des opérateurs, - // les littéraux de nombres négatifs ne renvoient pas de chaînes) -2.35.toFixed(1); // Renvoie '2.4' (arrondi supérieur) -2.55.toFixed(1); // Renvoie '2.5' (cf. l'avertissement ci-avant) -(-2.34).toFixed(1); // Renvoie '-2.3' +numObj.toFixed(); // Renvoie '12346' : arrondi, aucune partie fractionnaire +numObj.toFixed(1); // Renvoie '12345.7' : arrondi ici aussi +numObj.toFixed(6); // Renvoie '12345.678900' : des zéros sont ajoutés +(1.23e20).toFixed(2); // Renvoie '123000000000000000000.00' +(1.23e-10).toFixed(2); // Renvoie '0.00' +(2.34).toFixed(1); // Renvoie '2.3' +-(2.34).toFixed(1); // Renvoie -2.3 (en raison de la précédence des opérateurs, +// les littéraux de nombres négatifs ne renvoient pas de chaînes) +(2.35).toFixed(1); // Renvoie '2.4' (arrondi supérieur) +(2.55).toFixed(1); // Renvoie '2.5' (cf. l'avertissement ci-avant) +(-2.34).toFixed(1); // Renvoie '-2.3' ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/number/tolocalestring/index.md b/files/fr/web/javascript/reference/global_objects/number/tolocalestring/index.md index 81a3b5d2c1bb61..cb6a5abca9c0db 100644 --- a/files/fr/web/javascript/reference/global_objects/number/tolocalestring/index.md +++ b/files/fr/web/javascript/reference/global_objects/number/tolocalestring/index.md @@ -13,9 +13,9 @@ La méthode **`toLocaleString()`** permet de renvoyer une chaîne de caractères ## Syntaxe ```js -toLocaleString() -toLocaleString(locales) -toLocaleString(locales, options) +toLocaleString(); +toLocaleString(locales); +toLocaleString(locales, options); ``` ### Paramètres @@ -66,7 +66,11 @@ Afin de vérifier la prise en charge pour tous les environnements, y compris ceu ```js function toLocaleStringSupportsOptions() { - return !!(typeof Intl == 'object' && Intl && typeof Intl.NumberFormat == 'function'); + return !!( + typeof Intl == "object" && + Intl && + typeof Intl.NumberFormat == "function" + ); } ``` @@ -111,21 +115,30 @@ Les résultats fournis par `toLocaleString` peuvent être adaptés en utilisant const nombre = 123456.789; // on formate selon une devise -console.log(nombre.toLocaleString("de-DE", {style: "currency", currency: "EUR"})); +console.log( + nombre.toLocaleString("de-DE", { style: "currency", currency: "EUR" }), +); // → 123.456,79 € // le yen japonais ne possède pas de centimes -console.log(nombre.toLocaleString("ja-JP", {style: "currency", currency: "JPY"})) +console.log( + nombre.toLocaleString("ja-JP", { style: "currency", currency: "JPY" }), +); // → ¥123,457 // on se limite à trois chiffres significatifs -console.log(nombre.toLocaleString("en-IN", {maximumSignificantDigits: 3})); +console.log(nombre.toLocaleString("en-IN", { maximumSignificantDigits: 3 })); // → 1,23,000 // on utilise la langue du système pour la mise en // forme des nombres const num = 30000.65; -console.log(num.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})); +console.log( + num.toLocaleString(undefined, { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + }), +); // → "30,000.65" quand l'anglais est la langue par défaut // → "30.000,65" quand l'allemand est la langue par défaut // → "30 000,65" quand le français est la langue par défaut diff --git a/files/fr/web/javascript/reference/global_objects/number/toprecision/index.md b/files/fr/web/javascript/reference/global_objects/number/toprecision/index.md index d17959ac07c28e..3352694dac29b8 100644 --- a/files/fr/web/javascript/reference/global_objects/number/toprecision/index.md +++ b/files/fr/web/javascript/reference/global_objects/number/toprecision/index.md @@ -13,7 +13,7 @@ La méthode **`toPrecision()`** renvoie une chaîne de caractères représentant ## Syntaxe ```js -numObj.toPrecision([précision]) +numObj.toPrecision([précision]); ``` ### Paramètre @@ -36,17 +36,17 @@ Si l'argument `précision` n'est pas utilisé, la méthode aura le même effet q ```js var objetNumber = 5.123456; -console.log(objetNumber.toPrecision()); //affiche "5.123456" +console.log(objetNumber.toPrecision()); //affiche "5.123456" console.log(objetNumber.toPrecision(5)); //affiche "5.1235" console.log(objetNumber.toPrecision(2)); //affiche "5.1" console.log(objetNumber.toPrecision(1)); //affiche "5" numObj = 0.000123; -console.log(numObj.toPrecision()); // affiche "0.000123" -console.log(numObj.toPrecision(5)); // affiche "0.00012300" -console.log(numObj.toPrecision(2)); // affiche "0.00012" -console.log(numObj.toPrecision(1)); // affiche "0.0001" +console.log(numObj.toPrecision()); // affiche "0.000123" +console.log(numObj.toPrecision(5)); // affiche "0.00012300" +console.log(numObj.toPrecision(2)); // affiche "0.00012" +console.log(numObj.toPrecision(1)); // affiche "0.0001" // dans certaines circonstances, on peut avoir une notation exponentielle console.log((1234.5).toPrecision(2)); // "1.2e+3" diff --git a/files/fr/web/javascript/reference/global_objects/number/tostring/index.md b/files/fr/web/javascript/reference/global_objects/number/tostring/index.md index cfb40c47ff38fc..15e45e281738ca 100644 --- a/files/fr/web/javascript/reference/global_objects/number/tostring/index.md +++ b/files/fr/web/javascript/reference/global_objects/number/tostring/index.md @@ -13,7 +13,7 @@ La méthode **`toString()`** renvoie une chaîne de caractère représentant l'o ## Syntaxe ```js -numObj.toString([base]) +numObj.toString([base]); ``` ### Paramètre @@ -49,17 +49,16 @@ Si l'objet `Number` n'est pas un nombre entier, le point (.) sera utilisé pour ```js var compte = 10; -console.log(compte.toString()); // affiche "10" -console.log((17).toString()); // affiche "17" -console.log((17.2).toString()); // affiche "17.2" +console.log(compte.toString()); // affiche "10" +console.log((17).toString()); // affiche "17" +console.log((17.2).toString()); // affiche "17.2" var x = 6; -console.log(x.toString(2)); // affiche "110" -console.log((254).toString(16)); // affiche "fe" +console.log(x.toString(2)); // affiche "110" +console.log((254).toString(16)); // affiche "fe" - -console.log((-10).toString(2)); // affiche "-1010" +console.log((-10).toString(2)); // affiche "-1010" console.log((-0xff).toString(2)); // affiche "-11111111" ``` diff --git a/files/fr/web/javascript/reference/global_objects/number/valueof/index.md b/files/fr/web/javascript/reference/global_objects/number/valueof/index.md index 81df525f2b38bd..8e33bb0e793605 100644 --- a/files/fr/web/javascript/reference/global_objects/number/valueof/index.md +++ b/files/fr/web/javascript/reference/global_objects/number/valueof/index.md @@ -13,7 +13,7 @@ La méthode **`valueOf()`** renvoie la valeur primitive correspondant à celle r ## Syntaxe ```js -objetNumber.valueOf() +objetNumber.valueOf(); ``` ### Valeur de retour @@ -33,8 +33,8 @@ var numObj = new Number(10); console.log(typeof numObj); // object var num = numObj.valueOf(); -console.log(num); // 10 -console.log(typeof num); // number +console.log(num); // 10 +console.log(typeof num); // number ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/object/__definegetter__/index.md b/files/fr/web/javascript/reference/global_objects/object/__definegetter__/index.md index 7cccb852b35991..eb145836146981 100644 --- a/files/fr/web/javascript/reference/global_objects/object/__definegetter__/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/__definegetter__/index.md @@ -13,7 +13,7 @@ La méthode **`__defineGetter__`** permet de lier une propriété d'un objet à ## Syntaxe ```js -obj.__defineGetter__(prop, func) +obj.__defineGetter__(prop, func); ``` ### Paramètres @@ -37,22 +37,27 @@ La méthode `__defineGetter__` permet de définir un {{jsxref("Opérateurs/L_op // Méthode non-standard et dépréciée var o = {}; -o.__defineGetter__('gimmeFive', function() { return 5; }); +o.__defineGetter__("gimmeFive", function () { + return 5; +}); console.log(o.gimmeFive); // 5 - // Façon standard // En utilisant l'opérateur get -var o = { get gimmeFive() { return 5; } }; +var o = { + get gimmeFive() { + return 5; + }, +}; console.log(o.gimmeFive); // 5 // En utilisant Object.defineProperty var o = {}; -Object.defineProperty(o, 'gimmeFive', { - get: function() { +Object.defineProperty(o, "gimmeFive", { + get: function () { return 5; - } + }, }); console.log(o.gimmeFive); // 5 ``` diff --git a/files/fr/web/javascript/reference/global_objects/object/__definesetter__/index.md b/files/fr/web/javascript/reference/global_objects/object/__definesetter__/index.md index 8ce519a7aaefcb..71b09e6fab0a4a 100644 --- a/files/fr/web/javascript/reference/global_objects/object/__definesetter__/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/__definesetter__/index.md @@ -13,7 +13,7 @@ La méthode **`__defineSetter__`** permet de lier une propriété d'un objet à ## Syntaxe ```js -obj.__defineSetter__(prop, fun) +obj.__defineSetter__(prop, fun); ``` ### Paramètres @@ -25,8 +25,8 @@ obj.__defineSetter__(prop, fun) - : Une fonction à appeler pour chaque modification de la propriété. Cette fonction prend la forme suivante : ```js - function(val) { . . . } - ``` + function(val) { . . . } + ``` - `val` - : Un alias pour la variable contenant la nouvelle valeur qu'on souhaite affecter à `prop`. @@ -45,26 +45,31 @@ La méthode `__defineSetter__` permet de définir un {{jsxref("Opérateurs/L_op // Méthode non-standard et dépréciée var o = {}; -o.__defineSetter__('valeur', function(val) { this.uneAutreValeur = val; }); +o.__defineSetter__("valeur", function (val) { + this.uneAutreValeur = val; +}); o.valeur = 5; console.log(o.valeur); // undefined console.log(o.uneAutreValeur); // 5 - // Façons standard // En utilisant l'opérateur set -var o = { set valeur(val) { this.uneAutreValeur = val; } }; +var o = { + set valeur(val) { + this.uneAutreValeur = val; + }, +}; o.valeur = 5; console.log(o.valeur); // undefined console.log(o.uneAutreValeur); // 5 // En utilisant Object.defineProperty var o = {}; -Object.defineProperty(o, 'valeur', { - set: function(val) { +Object.defineProperty(o, "valeur", { + set: function (val) { this.uneAutreValeur = val; - } + }, }); o.valeur = 5; console.log(o.valeur); // undefined diff --git a/files/fr/web/javascript/reference/global_objects/object/__lookupgetter__/index.md b/files/fr/web/javascript/reference/global_objects/object/__lookupgetter__/index.md index 315f88d53c304e..969381e0040687 100644 --- a/files/fr/web/javascript/reference/global_objects/object/__lookupgetter__/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/__lookupgetter__/index.md @@ -11,7 +11,7 @@ La méthode **`__lookupGetter__`** renvoie la fonction liée comme accesseur d'u ## Syntaxe ```js -obj.__lookupGetter__(sprop) +obj.__lookupGetter__(sprop); ``` ### Paramètres @@ -34,16 +34,14 @@ Cette méthode ne doit plus être utilisée et il est possible de la remplacer d ```js var obj = { get toto() { - return Math.random() > 0.5 ? 'toto' : 'truc'; - } + return Math.random() > 0.5 ? "toto" : "truc"; + }, }; - // Méthode non-standard et dépréciée -obj.__lookupGetter__('toto'); +obj.__lookupGetter__("toto"); // (function() { return Math.random() > 0.5 ? 'toto' : 'truc'; }) - // Méthode standard Object.getOwnPropertyDescriptor(obj, "toto").get; // (function() { return Math.random() > 0.5 ? 'toto' : 'truc'; }) diff --git a/files/fr/web/javascript/reference/global_objects/object/__lookupsetter__/index.md b/files/fr/web/javascript/reference/global_objects/object/__lookupsetter__/index.md index 167063216be79f..15a9e3b915a191 100644 --- a/files/fr/web/javascript/reference/global_objects/object/__lookupsetter__/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/__lookupsetter__/index.md @@ -11,7 +11,7 @@ La méthode **`__lookupSetter__`** renvoie la fonction définie comme mutateur p ## Syntaxe ```js -obj.__lookupSetter__(sprop) +obj.__lookupSetter__(sprop); ``` ### Paramètres @@ -35,15 +35,13 @@ Cette méthode ne doit plus être utilisée et peut être remplacée avec la mé var obj = { set toto(valeur) { this.truc = value; - } + }, }; - // Méthode non-standard et dépréciée -obj.__lookupSetter__('toto') +obj.__lookupSetter__("toto"); // (function(valeur) { this.truc = valeur; }) - // Méthode standard Object.getOwnPropertyDescriptor(obj, "toto").set; // (function(valeur) { this.truc = valeur; }) diff --git a/files/fr/web/javascript/reference/global_objects/object/assign/index.md b/files/fr/web/javascript/reference/global_objects/object/assign/index.md index 93c215fd015894..b4d59841fd80b6 100644 --- a/files/fr/web/javascript/reference/global_objects/object/assign/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/assign/index.md @@ -13,7 +13,7 @@ La méthode **`Object.assign()`** est utilisée afin de copier les valeurs de to ## Syntaxe ```js -Object.assign(cible, ...sources) +Object.assign(cible, ...sources); ``` ### Paramètres @@ -58,7 +58,7 @@ var o3 = { c: 3 }; var obj = Object.assign(o1, o2, o3); console.log(obj); // { a: 1, b: 2, c: 3 } -console.log(o1); // { a: 1, b: 2, c: 3 }, l'objet cible est aussi modifié +console.log(o1); // { a: 1, b: 2, c: 3 }, l'objet cible est aussi modifié ``` ### Fusionner des objets partageant des propriétés @@ -78,7 +78,7 @@ Les propriétés communes sont surchargées selon l'ordre des paramètres. ```js var o1 = { a: 1 }; -var o2 = { [Symbol('toto')]: 2 }; +var o2 = { [Symbol("toto")]: 2 }; var obj = Object.assign({}, o1, o2); console.log(obj); // { a: 1, [Symbol("toto")]: 2 } @@ -90,15 +90,19 @@ console.log(Object.getOwnPropertySymbols(obj)); // [Symbol(toto)] ### Les propriétés héritées et les propriétés non-énumérables ne peuvent être copiées ```js -var obj = Object.create({ toto: 1 }, { // toto est héritée - truc: { - value: 2 // truc est non-enumerable (par défaut) +var obj = Object.create( + { toto: 1 }, + { + // toto est héritée + truc: { + value: 2, // truc est non-enumerable (par défaut) + }, + bidule: { + value: 3, + enumerable: true, // bidule est une propriété propre et énumérable + }, }, - bidule: { - value: 3, - enumerable: true // bidule est une propriété propre et énumérable - } -}); +); var copie = Object.assign({}, obj); console.log(copie); // { bidule: 3 } @@ -107,10 +111,10 @@ console.log(copie); // { bidule: 3 } ### Les types primitifs seront passés en objets ```js -var v1 = 'abc'; +var v1 = "abc"; var v2 = true; var v3 = 10; -var v4 = Symbol('toto') +var v4 = Symbol("toto"); var obj = Object.assign({}, v1, null, v2, undefined, v3, v4); // Les valeurs primitives seront converties, null et undefined seront ignorés. @@ -121,20 +125,25 @@ console.log(obj); // { "0": "a", "1": "b", "2": "c" } ### Les exceptions interrompent la copie ```js -var target = Object.defineProperty({}, 'toto', { +var target = Object.defineProperty({}, "toto", { value: 1, - writable: false + writable: false, }); // target.toto est en lecture seule -Object.assign(target, { truc: 2 }, { toto2: 3, toto: 3, toto3: 3 }, { bidule: 4 }); +Object.assign( + target, + { truc: 2 }, + { toto2: 3, toto: 3, toto3: 3 }, + { bidule: 4 }, +); // TypeError: "toto" est en lecture seule // L'exception est levée lorsqu'on affecte target.toto -console.log(target.truc); // 2, le premier objet source est bien copié +console.log(target.truc); // 2, le premier objet source est bien copié console.log(target.toto2); // 3, la première propriété du deuxième objet source est bien copiée -console.log(target.toto); // 1, on a une exception ici +console.log(target.toto); // 1, on a une exception ici console.log(target.toto3); // undefined, assign est terminé toto3 ne sera pas copié -console.log(target.bidule);// undefined, le troisième objet source ne sera pas copié non plus. +console.log(target.bidule); // undefined, le troisième objet source ne sera pas copié non plus. ``` ### Copier des accesseurs @@ -144,7 +153,7 @@ var obj = { toto: 1, get truc() { return 2; - } + }, }; var copie = Object.assign({}, obj); @@ -155,14 +164,14 @@ console.log(copie); // Voici une fonction qui copie les descripteurs // dans leur intégralité function completeAssign(target, ...sources) { - sources.forEach(source => { + sources.forEach((source) => { let descriptors = Object.keys(source).reduce((descriptors, key) => { descriptors[key] = Object.getOwnPropertyDescriptor(source, key); return descriptors; }, {}); // Par défaut, Object.assign copie également // les symboles énumérables - Object.getOwnPropertySymbols(source).forEach(sym => { + Object.getOwnPropertySymbols(source).forEach((sym) => { let descriptor = Object.getOwnPropertyDescriptor(source, sym); if (descriptor.enumerable) { descriptors[sym] = descriptor; diff --git a/files/fr/web/javascript/reference/global_objects/object/constructor/index.md b/files/fr/web/javascript/reference/global_objects/object/constructor/index.md index 112972aeadc1dd..113b8d252cfd1c 100644 --- a/files/fr/web/javascript/reference/global_objects/object/constructor/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/constructor/index.md @@ -19,7 +19,7 @@ o.constructor === Object; // true var a = []; a.constructor === Array; // true -var n = new Number(3) +var n = new Number(3); n.constructor === Number; // true ``` @@ -31,11 +31,11 @@ L'exemple ci-dessous crée un constructeur `Arbre`, et un objet de ce type, `mon ```js function Arbre(nom) { - this.nom = nom; + this.nom = nom; } var monArbre = new Arbre("Sequoia"); -console.log( "monArbre.constructor vaut " + monArbre.constructor ); +console.log("monArbre.constructor vaut " + monArbre.constructor); ``` Cet exemple produira le résultat suivant : @@ -51,34 +51,38 @@ monArbre.constructor vaut function Arbre(nom) { Dans l'exemple suivant, on illustre comment modifier la valeur d'un constructeur pour les objets génériques. Dans l'exemple suivant, seules les valeurs `true`, `1` et `"test"` ne seront pas affectées car leurs constructeurs sont en lecture seule uniquement. Cet exemple montre qu'il ne faut pas se reposer de façon aveugle sur la propriété `constructor` d'un objet. ```js -function Type () {} +function Type() {} var types = [ new Array(), [], new Boolean(), - true, // restera tel quel + true, // restera tel quel new Date(), new Error(), new Function(), function () {}, Math, new Number(), - 1, // restera tel quel + 1, // restera tel quel new Object(), {}, new RegExp(), /(?:)/, new String(), - 'test' // restera tel quel + "test", // restera tel quel ]; for (var i = 0; i < types.length; i++) { types[i].constructor = Type; - types[i] = [types[i].constructor, types[i] instanceof Type, types[i].toString()]; + types[i] = [ + types[i].constructor, + types[i] instanceof Type, + types[i].toString(), + ]; } -console.log(types.join('\n')); +console.log(types.join("\n")); ``` L'exemple produira le résultat suivant : @@ -133,14 +137,14 @@ Essayons de définir les cas où il est nécessaire de réaffecter le constructe Imaginons que l'objet possède une méthode `create()` qui lui permette de créer un autre exemplaire : ```js -function Parent() {}; +function Parent() {} function CreatedConstructor() {} CreatedConstructor.prototype = Object.create(Parent.prototype); CreatedConstructor.prototype.create = function create() { return new this.constructor(); -} +}; new CreatedConstructor().create().create(); // error undefined is not a function car constructor === Parent @@ -151,7 +155,7 @@ Dans l'exemple précédent, on a une exception car le constructeur pointe vers ` Pour éviter cet écueil, il suffit d'affecter le bon constructeur (celui qui sera utilisé ensuite) : ```js -function Parent() {}; +function Parent() {} function CreatedConstructor() {} CreatedConstructor.prototype = Object.create(Parent.prototype); @@ -160,7 +164,7 @@ CreatedConstructor.prototype.constructor = CreatedConstructor; CreatedConstructor.prototype.create = function create() { return new this.constructor(); -} +}; new CreatedConstructor().create().create(); // pas d'exception cette fois-ci @@ -171,30 +175,31 @@ Prenons un autre exemple : ```js function ParentWithStatic() {} -ParentWithStatic.startPosition = { x: 0, y:0 }; +ParentWithStatic.startPosition = { x: 0, y: 0 }; ParentWithStatic.getStartPosition = function getStartPosition() { return this.startPosition; -} +}; function Child(x, y) { this.position = { x: x, - y: y + y: y, }; } Child.prototype = Object.create(ParentWithStatic.prototype); Child.prototype.constructor = Child; -Child.prototype.getOffsetByInitialPosition = function getOffsetByInitialPosition() { - var position = this.position; - var startPosition = this.constructor.getStartPosition(); // error undefined is not a function, since the constructor is Child +Child.prototype.getOffsetByInitialPosition = + function getOffsetByInitialPosition() { + var position = this.position; + var startPosition = this.constructor.getStartPosition(); // error undefined is not a function, since the constructor is Child - return { - offsetX: startPosition.x - position.x, - offsetY: startPosition.y - position.y - } -}; + return { + offsetX: startPosition.x - position.x, + offsetY: startPosition.y - position.y, + }; + }; ``` Ici, il faudra conserverr le constructeur parent si on veut que le code fonctionne correctement. diff --git a/files/fr/web/javascript/reference/global_objects/object/create/index.md b/files/fr/web/javascript/reference/global_objects/object/create/index.md index 61a01b3fb55d51..c86ce4baa033b2 100644 --- a/files/fr/web/javascript/reference/global_objects/object/create/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/create/index.md @@ -13,8 +13,8 @@ La méthode **`Object.create()`** crée un nouvel objet avec un prototype donné ## Syntaxe ```js -Object.create(proto) -Object.create(proto, objetPropriétés) +Object.create(proto); +Object.create(proto, objetPropriétés); ``` ### Paramètres @@ -46,10 +46,10 @@ function Forme() { } // Méthode de la classe parente -Forme.prototype.déplacer = function(x, y) { +Forme.prototype.déplacer = function (x, y) { this.x += x; this.y += y; - console.info('Forme déplacée.'); + console.info("Forme déplacée."); }; // Rectangle - classe fille @@ -67,10 +67,10 @@ Rectangle.prototype.constructor = Rectangle; var rect = new Rectangle(); -console.log('instance de Rectangle ? ', (rect instanceof Rectangle)); +console.log("instance de Rectangle ? ", rect instanceof Rectangle); +// true +console.log("une instance de Forme ? ", rect instanceof Forme); // true -console.log('une instance de Forme ? ', (rect instanceof Forme)); - // true rect.déplacer(1, 1); // Affiche 'Forme déplacée.' ``` @@ -87,7 +87,7 @@ MaClasse.prototype = Object.create(ClasseParente1.prototype); // héritage d'une Object.assign(MaClasse.prototype, ClasseParente2.prototype); // mixin pour une autre MaClasse.prototype.constructor = MaClasse; // On réaffecte le constructeur -MaClasse.prototype.maMéthode = function() { +MaClasse.prototype.maMéthode = function () { // faire quelque chose }; ``` @@ -103,30 +103,31 @@ var o; // comme prototype o = Object.create(null); - o = {}; // est équivalent à : o = Object.create(Object.prototype); - // Exemple où on crée un objet avec quelques propriétés // (On voit ici que le second paramètres fait correspondre les clés // avec des descripteurs de propriétés.) o = Object.create(Object.prototype, { // toto est une propriété de donnée - toto: { writable: true, configurable: true, value: 'hello' }, + toto: { writable: true, configurable: true, value: "hello" }, // truc est une propriété d'accesseur/mutateur truc: { configurable: false, - get: function() { return 10; }, - set: function(value) { console.log('Définir `o.truc` à', value); } -/* avec les accesseurs ES2015 on aura : + get: function () { + return 10; + }, + set: function (value) { + console.log("Définir `o.truc` à", value); + }, + /* avec les accesseurs ES2015 on aura : get() { return 10; }, set(value) { console.log('Définir `o.truc` à', value); } */ - } + }, }); - function Constructeur() {} o = new Constructeur(); // est équivalent à : @@ -135,7 +136,6 @@ o = Object.create(Constructeur.prototype); // possède des instructions pour l'initialisation, // Object.create() ne pourra pas le reproduire - // on crée un nouvel objet dont le prototype est // un nouvel objet vide et on y ajoute une propriété // 'p' qui vaut 42 @@ -157,14 +157,17 @@ delete o.p; // false // Pour définir une propriété selon ES3 -o2 = Object.create({}, { - p: { - value: 42, - writable: true, - enumerable: true, - configurable: true - } -}); +o2 = Object.create( + {}, + { + p: { + value: 42, + writable: true, + enumerable: true, + configurable: true, + }, + }, +); // Équivalent à // o2 = Object.create({p: 42}); diff --git a/files/fr/web/javascript/reference/global_objects/object/defineproperties/index.md b/files/fr/web/javascript/reference/global_objects/object/defineproperties/index.md index 8b8cbee498c035..ad696179692bae 100644 --- a/files/fr/web/javascript/reference/global_objects/object/defineproperties/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/defineproperties/index.md @@ -13,7 +13,7 @@ La méthode **`Object.defineProperties()`** permet de définir ou de modifier le ## Syntaxe ```js -Object.defineProperties(obj, props) +Object.defineProperties(obj, props); ``` ### Paramètres @@ -64,14 +64,14 @@ L'objet passé à la fonction, éventuellement modifié. ```js var obj = {}; Object.defineProperties(obj, { - "propriété1": { + propriété1: { value: true, - writable: true + writable: true, }, - "propriété2": { + propriété2: { value: "Coucou", - writable: false - } + writable: false, + }, // etc. }); ``` @@ -99,22 +99,18 @@ function defineProperties(obj, properties) { var d = {}; - if (hasProperty(desc, "enumerable")) - d.enumerable = !!desc.enumerable; - if (hasProperty(desc, "configurable")) - d.configurable = !!desc.configurable; - if (hasProperty(desc, "value")) - d.value = desc.value; - if (hasProperty(desc, "writable")) - d.writable = !!desc.writable; - if ( hasProperty(desc, "get") ) { + if (hasProperty(desc, "enumerable")) d.enumerable = !!desc.enumerable; + if (hasProperty(desc, "configurable")) d.configurable = !!desc.configurable; + if (hasProperty(desc, "value")) d.value = desc.value; + if (hasProperty(desc, "writable")) d.writable = !!desc.writable; + if (hasProperty(desc, "get")) { var g = desc.get; if (!isCallable(g) && typeof g !== "undefined") throw new TypeError("bad get"); d.get = g; } - if ( hasProperty(desc, "set") ) { + if (hasProperty(desc, "set")) { var s = desc.set; if (!isCallable(s) && typeof s !== "undefined") throw new TypeError("bad set"); @@ -127,8 +123,7 @@ function defineProperties(obj, properties) { return d; } - if (typeof obj !== "object" || obj === null) - throw new TypeError("bad obj"); + if (typeof obj !== "object" || obj === null) throw new TypeError("bad obj"); properties = Object(properties); diff --git a/files/fr/web/javascript/reference/global_objects/object/defineproperty/index.md b/files/fr/web/javascript/reference/global_objects/object/defineproperty/index.md index 17449759463e0e..d41eacfe5ded67 100644 --- a/files/fr/web/javascript/reference/global_objects/object/defineproperty/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/defineproperty/index.md @@ -15,7 +15,7 @@ La méthode statique **`Object.defineProperty()`** permet de définir une nouvel ## Syntaxe ```js -Object.defineProperty(obj, prop, descripteur) +Object.defineProperty(obj, prop, descripteur); ``` ### Paramètres @@ -70,10 +70,10 @@ var obj = {}; // en utilisant __proto__ Object.defineProperty(obj, "clé", { __proto__: null, // aucune propriété héritée - value: "static" // non énumérable - // non configurable - // non accessible en écriture - // par défaut + value: "static", // non énumérable + // non configurable + // non accessible en écriture + // par défaut }); // en étant explicite @@ -81,20 +81,20 @@ Object.defineProperty(obj, "clé", { enumerable: false, configurable: false, writable: false, - value: "static" + value: "static", }); // en recyclant un objet function avecValeur(valeur) { - var d = avecValeur.d || ( - avecValeur.d = { + var d = + avecValeur.d || + (avecValeur.d = { enumerable: false, writable: false, configurable: false, - value: null - } - ); - if(d.value !== valeur){ + value: null, + }); + if (d.value !== valeur) { d.value = valeur; } return d; @@ -106,7 +106,7 @@ Object.defineProperty(obj, "clé", avecValeur("static")); // on peut empêcher que du code ajoute des // propriétés (valeur, get, set, enumerable, // writable, configurable) au prototype d'Object -(Object.freeze||Object)(Object.prototype); +(Object.freeze || Object)(Object.prototype); ``` ## Exemples @@ -122,21 +122,27 @@ var o = {}; // on crée un nouvel objet // Exemple d'une propriété ajoutée via defineProperty // avec un descripteur de données -Object.defineProperty(o, "a", {value : 37, - writable : true, - enumerable : true, - configurable : true}); +Object.defineProperty(o, "a", { + value: 37, + writable: true, + enumerable: true, + configurable: true, +}); // la propriété 'a' existe pour l'objet o et vaut 37 // Exemple d'une propriété ajoutée via defineProperty // avec un descripteur d'accesseur var valeurB = 38; -Object.defineProperty(o, "b", {get : function(){ return valeurB; }, - set : function(nouvelleValeur){ - valeurB = nouvelleValeur; - }, - enumerable : true, - configurable : true}); +Object.defineProperty(o, "b", { + get: function () { + return valeurB; + }, + set: function (nouvelleValeur) { + valeurB = nouvelleValeur; + }, + enumerable: true, + configurable: true, +}); o.b; // 38 // la propriété 'b' existe pour l'objet o // et vaut 38 @@ -144,11 +150,12 @@ o.b; // 38 // identique à valeurB, sauf si o.b est redéfini // On ne peut pas mélanger les deux : -Object.defineProperty(o, "conflit", { value: 0x9f91102, - get: function() { - return 0xdeadbeef; - } - }); +Object.defineProperty(o, "conflit", { + value: 0x9f91102, + get: function () { + return 0xdeadbeef; + }, +}); // une exception TypeError sera lancée : value n'apparaît // que dans les descripteurs de données // get n'apparait que dans les descripteurs d'accesseur @@ -169,29 +176,28 @@ Lorsque l'attribut `writable` vaut `false` pour la propriété, cette dernière ```js var o = {}; // On crée un nouvel objet -Object.defineProperty(o, "a", { value : 37, - writable : false }); +Object.defineProperty(o, "a", { value: 37, writable: false }); console.log(o.a); // inscrit 37 dans les journaux (logs) o.a = 25; // Aucune exception n'est lancée (on aurait une - // exception en mode strict, y compris si la - // valeur souhaitée avait été la même) +// exception en mode strict, y compris si la +// valeur souhaitée avait été la même) console.log(o.a); // inscrit toujours 37. - //L'affectation n'a pas fonctionné. +//L'affectation n'a pas fonctionné. ``` ```js // En mode strict -(function() { - 'use strict'; +(function () { + "use strict"; var o = {}; - Object.defineProperty(o, 'b', { + Object.defineProperty(o, "b", { value: 2, - writable: false + writable: false, }); o.b = 3; // déclenche une TypeError: "b" est en lecture seule return o.b; // renvoie 2 sans la ligne précédente -}()); +})(); ``` Comme on l'a vu dans l'exemple, essayer de modifier une propriété non accessible en écriture ne la modifie pas. Cela ne rend pas d'erreur non plus (en mode non-strict). @@ -202,27 +208,27 @@ L'attribut de propriété `enumerable` permet de définir si la propriété est ```js var o = {}; -Object.defineProperty(o, 'a', { +Object.defineProperty(o, "a", { value: 1, - enumerable: true + enumerable: true, }); -Object.defineProperty(o, 'b', { +Object.defineProperty(o, "b", { value: 2, - enumerable: false + enumerable: false, }); -Object.defineProperty(o, 'c', { - value: 3 +Object.defineProperty(o, "c", { + value: 3, }); // enumerable vaut false par défaut o.d = 4; // enumerable vaut true par défaut - // lorsqu'on crée une propriété - // en la définissant -Object.defineProperty(o, Symbol.for('e'), { +// lorsqu'on crée une propriété +// en la définissant +Object.defineProperty(o, Symbol.for("e"), { value: 5, - enumerable: true + enumerable: true, }); -Object.defineProperty(o, Symbol.for('f'), { +Object.defineProperty(o, Symbol.for("f"), { value: 6, - enumerable: false + enumerable: false, }); for (var i in o) { @@ -232,20 +238,20 @@ for (var i in o) { Object.keys(o); // ['a', 'd'] -o.propertyIsEnumerable('a'); // true -o.propertyIsEnumerable('b'); // false -o.propertyIsEnumerable('c'); // false -o.propertyIsEnumerable('d'); // true -o.propertyIsEnumerable(Symbol.for('e')); // true -o.propertyIsEnumerable(Symbol.for('f')); // false - -var p = { ...o } -p.a // 1 -p.b // undefined -p.c // undefined -p.d // 4 -p[Symbol.for('e')] // 5 -p[Symbol.for('f')] // undefined +o.propertyIsEnumerable("a"); // true +o.propertyIsEnumerable("b"); // false +o.propertyIsEnumerable("c"); // false +o.propertyIsEnumerable("d"); // true +o.propertyIsEnumerable(Symbol.for("e")); // true +o.propertyIsEnumerable(Symbol.for("f")); // false + +var p = { ...o }; +p.a; // 1 +p.b; // undefined +p.c; // undefined +p.d; // 4 +p[Symbol.for("e")]; // 5 +p[Symbol.for("f")]; // undefined ``` #### Attribut `configurable` @@ -254,23 +260,31 @@ L'attribut `configurable` permet de contrôler si la propriété peut être supp ```js var o = {}; -Object.defineProperty(o, "a", { get : function(){return 1;}, - configurable : false } ); +Object.defineProperty(o, "a", { + get: function () { + return 1; + }, + configurable: false, +}); -Object.defineProperty(o, "a", {configurable : true}); +Object.defineProperty(o, "a", { configurable: true }); // renvoie une TypeError -Object.defineProperty(o, "a", {enumerable : true}); +Object.defineProperty(o, "a", { enumerable: true }); // renvoie une TypeError -Object.defineProperty(o, "a", {set : function(){}}); +Object.defineProperty(o, "a", { set: function () {} }); // renvoie une TypeError (set était non défini avant) -Object.defineProperty(o, "a", {get : function(){return 1;}}); +Object.defineProperty(o, "a", { + get: function () { + return 1; + }, +}); // renvoie une TypeError // (bien que le nouveau get soit identique au précédent) -Object.defineProperty(o, "a", {value : 12}); +Object.defineProperty(o, "a", { value: 12 }); // renvoie une TypeError console.log(o.a); // log 1 @@ -289,19 +303,22 @@ var o = {}; o.a = 1; // est équivalent à : -Object.defineProperty(o, "a", {value : 1, - writable : true, - configurable : true, - enumerable : true}); - +Object.defineProperty(o, "a", { + value: 1, + writable: true, + configurable: true, + enumerable: true, +}); // D'un autre côté, -Object.defineProperty(o, "a", {value : 1}); +Object.defineProperty(o, "a", { value: 1 }); // sera équivalent à : -Object.defineProperty(o, "a", {value : 1, - writable : false, - configurable : false, - enumerable : false}); +Object.defineProperty(o, "a", { + value: 1, + writable: false, + configurable: false, + enumerable: false, +}); ``` ### Accesseurs et mutateurs adaptés @@ -313,18 +330,20 @@ function Archiviste() { var température = null; var archive = []; - Object.defineProperty(this, "température",{ - get: function() { + Object.defineProperty(this, "température", { + get: function () { console.log("accès !"); return température; }, - set: function(value) { + set: function (value) { température = value; - archive.push({val: température}); - } + archive.push({ val: température }); + }, }); - this.getArchive = function() {return archive;}; + this.getArchive = function () { + return archive; + }; } var arc = new Archiviste(); diff --git a/files/fr/web/javascript/reference/global_objects/object/entries/index.md b/files/fr/web/javascript/reference/global_objects/object/entries/index.md index a68f66c63953bb..86affad5b2f265 100644 --- a/files/fr/web/javascript/reference/global_objects/object/entries/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/entries/index.md @@ -15,7 +15,7 @@ L'ordre du tableau renvoyé par cette méthode ne dépend pas de la façon dont ## Syntaxe ```js -Object.entries(obj) +Object.entries(obj); ``` ### Paramètres @@ -38,16 +38,25 @@ var obj = { toto: "truc", machin: 42 }; console.log(Object.entries(obj)); // [ ['toto', 'truc'], ['machin', 42] ] // Un objet semblable à un tableau -var obj = { 0: 'a', 1: 'b', 2: 'c' }; +var obj = { 0: "a", 1: "b", 2: "c" }; console.log(Object.entries(obj)); // [ ['0', 'a'], ['1', 'b'], ['2', 'c'] ] // Un objet semblable à un tableau // dont les clés sont aléatoirement ordonnées -var un_obj = { 100: 'a', 2: 'b', 7: 'c' }; +var un_obj = { 100: "a", 2: "b", 7: "c" }; console.log(Object.entries(un_obj)); // [ ['2', 'b'], ['7', 'c'], ['100', 'a'] ] // getToto est une propriété non énumérable -var mon_obj = Object.create({}, { getToto: { value: function() { return this.toto; } } }); +var mon_obj = Object.create( + {}, + { + getToto: { + value: function () { + return this.toto; + }, + }, + }, +); mon_obj.toto = "truc"; console.log(Object.entries(mon_obj)); // [ ['toto', 'truc'] ] @@ -59,15 +68,15 @@ console.log(Object.entries("toto")); // [ ['0', 't'], ['1', 'o'], ['2', 't'], [ console.log(Object.entries(100)); // [ ] // parcourir les clés-valeurs -var autreObjet = {a:5, b:7, c:9}; +var autreObjet = { a: 5, b: 7, c: 9 }; -for (var [cle, valeur] of Object.entries(autreObjet)){ - console.log(cle + ' ' + valeur); +for (var [cle, valeur] of Object.entries(autreObjet)) { + console.log(cle + " " + valeur); } // Ou encore, en utilisant les méthodes génériques Object.entries(autreObjet).forEach(([clé, valeur]) => { - console.log(clé + ' ' + valeur); + console.log(clé + " " + valeur); }); ``` @@ -87,8 +96,8 @@ En utilisant [la décomposition des tableaux](/fr/docs/Web/JavaScript/Reference/ ```js const obj = { toto: "truc", bidule: 42 }; -Object.entries(obj).forEach( - ([clé, valeur]) => console.log(`${clé}: ${valeur}`) +Object.entries(obj).forEach(([clé, valeur]) => + console.log(`${clé}: ${valeur}`), ); // "toto: truc" // "bidule: 42" @@ -102,12 +111,11 @@ Vous pouvez également utiliser la prothèse suivante (qui nécessitera la proth ```js if (!Object.entries) { - Object.entries = function( obj ){ - var ownProps = Object.keys( obj ), - i = ownProps.length, - resArray = new Array(i); - while (i--) - resArray[i] = [ownProps[i], obj[ownProps[i]]]; + Object.entries = function (obj) { + var ownProps = Object.keys(obj), + i = ownProps.length, + resArray = new Array(i); + while (i--) resArray[i] = [ownProps[i], obj[ownProps[i]]]; return resArray; }; diff --git a/files/fr/web/javascript/reference/global_objects/object/freeze/index.md b/files/fr/web/javascript/reference/global_objects/object/freeze/index.md index acf711a362d326..5d9ce02b93284c 100644 --- a/files/fr/web/javascript/reference/global_objects/object/freeze/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/freeze/index.md @@ -13,7 +13,7 @@ La méthode **`Object.freeze()`** permet de geler un objet, c'est-à-dire qu'on ## Syntaxe ```js -Object.freeze(obj) +Object.freeze(obj); ``` ### Paramètres @@ -39,8 +39,8 @@ La fonction renvoie l'objet passé en argument, elle ne crée pas une copie « g ```js var obj = { - prop: function (){}, - toto: "truc" + prop: function () {}, + toto: "truc", }; // On peut ajouter de nouvelles propriétés, @@ -61,15 +61,15 @@ Object.isFrozen(obj); // true // Maintenant que l'objet est gelé, les changements échoueront obj.toto = "eheh"; // échoue silencieusement obj.roxor = "ga bu zo meu"; // échoue silencieusement et n'ajoute - // pas la propriété +// pas la propriété // ...en mode strict, l'échec se traduira par une exception TypeErrors -function echec(){ +function echec() { "use strict"; obj.toto = "bipbip"; // renvoie une TypeError - delete obj.toto; // renvoie une TypeError - delete obj.roxor; // renvoie true car l'attribut n' a pas été ajouté - obj.bipbip = "arf"; // renvoie une TypeError + delete obj.toto; // renvoie une TypeError + delete obj.roxor; // renvoie true car l'attribut n' a pas été ajouté + obj.bipbip = "arf"; // renvoie une TypeError } echec(); @@ -93,13 +93,13 @@ let a = [0]; Object.freeze(a); // Le tableau ne peut plus être modifié -a[0] = 1; // échoue silencieusement +a[0] = 1; // échoue silencieusement a.push(2); // échoue silencieusement // en mode strict, de telles tentatives // déclencheront des exceptions TypeError function echec() { - "use strict" + "use strict"; a[0] = 1; a.push(2); } @@ -111,13 +111,13 @@ L'exemple qui suit illustre comment les propriétés qui sont des objets peuvent ```js obj1 = { - internal: {} + internal: {}, }; Object.freeze(obj1); -obj1.internal.a = 'valeurA'; +obj1.internal.a = "valeurA"; -obj1.internal.a // 'valeurA' +obj1.internal.a; // 'valeurA' ``` L'objet qui est gelé est immuable mais ce n'est pas nécessairement une constante. Pour obtenir une constante, il faut que l'ensemble des références (directes et indirectes) pointe vers des objets immuables. Les chaînes de caractères, les nombres et les booléens sont toujours immuables. La plupart du temps, on aura besoin de créer des constantes au cas par cas (et non de façon générale). @@ -132,8 +132,8 @@ var employé = { designation: "Développeur", adresse: { cp: "72000", - ville: "Le Mans" - } + ville: "Le Mans", + }, }; Object.freeze(employé); @@ -148,15 +148,13 @@ Pour rendre l'objet complètement immuable, on gèle chacun des objets qu'il con ```js function deepFreeze(obj) { - // On récupère les noms des propriétés définies sur obj var propNames = Object.getOwnPropertyNames(obj); // On gèle les propriétés avant de geler l'objet - for(let name of propNames){ + for (let name of propNames) { let value = obj[name]; - obj[name] = value && typeof value === "object" ? - deepFreeze(value) : value; + obj[name] = value && typeof value === "object" ? deepFreeze(value) : value; } // On gèle l'objet initial @@ -165,12 +163,12 @@ function deepFreeze(obj) { obj2 = { internal: { - a: null - } + a: null, + }, }; deepFreeze(obj2); -obj2.internal.a = 'valeurB'; // échouera silencieusement en mode non-strict +obj2.internal.a = "valeurB"; // échouera silencieusement en mode non-strict obj2.internal.a; // null ``` diff --git a/files/fr/web/javascript/reference/global_objects/object/fromentries/index.md b/files/fr/web/javascript/reference/global_objects/object/fromentries/index.md index e763f68d54fa67..61dd50cf243066 100644 --- a/files/fr/web/javascript/reference/global_objects/object/fromentries/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/fromentries/index.md @@ -38,7 +38,10 @@ La méthode `Object.fromEntries()` prend comme argument une liste de paires de c Grâce à `Object.fromEntries`, on peut convertir des objets {{jsxref("Map")}} en {{jsxref("Object")}} : ```js -const map = new Map([ ['toto', 'truc'], ['machin', 42] ]); +const map = new Map([ + ["toto", "truc"], + ["machin", 42], +]); const obj = Object.fromEntries(map); console.log(obj); // { toto: "truc", machin: 42 } ``` @@ -48,7 +51,11 @@ console.log(obj); // { toto: "truc", machin: 42 } Grâce à `Object.fromEntries`, on peut convertir des objets {{jsxref("Array")}} en {{jsxref("Object")}} : ```js -const arr = [ ['0', 'a'], ['1', 'b'], ['2', 'c'] ]; +const arr = [ + ["0", "a"], + ["1", "b"], + ["2", "c"], +]; const obj = Object.fromEntries(arr); console.log(obj); // { 0: "a", 1: "b", 2: "c" } ``` @@ -61,8 +68,7 @@ Avec `Object.fromEntries` et la méthode réciproque {{jsxref("Object.entries()" const object1 = { a: 1, b: 2, c: 3 }; const object2 = Object.fromEntries( - Object.entries(object1) - .map(([ key, val ]) => [ key, val * 2 ]) + Object.entries(object1).map(([key, val]) => [key, val * 2]), ); console.log(object2); diff --git a/files/fr/web/javascript/reference/global_objects/object/getownpropertydescriptor/index.md b/files/fr/web/javascript/reference/global_objects/object/getownpropertydescriptor/index.md index 2ebd482039425f..63d9701d111e63 100644 --- a/files/fr/web/javascript/reference/global_objects/object/getownpropertydescriptor/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/getownpropertydescriptor/index.md @@ -13,7 +13,7 @@ La méthode **`Object.getOwnPropertyDescriptor()`** renvoie un descripteur de la ## Syntaxe ```js -Object.getOwnPropertyDescriptor(obj, prop) +Object.getOwnPropertyDescriptor(obj, prop); ``` ### Paramètres @@ -51,7 +51,11 @@ Un descripteur de propriété est un enregistrement qui dispose des attributs su ```js var o, d; -o = { get toto() { return 17; } }; +o = { + get toto() { + return 17; + }, +}; d = Object.getOwnPropertyDescriptor(o, "toto"); // d : { // configurable: true, @@ -71,9 +75,10 @@ d = Object.getOwnPropertyDescriptor(o, "truc"); o = {}; Object.defineProperty(o, "machin", { - value: 8675309, - writable: false, - enumerable: false }); + value: 8675309, + writable: false, + enumerable: false, +}); d = Object.getOwnPropertyDescriptor(o, "machin"); // d : { // value: 8675309, diff --git a/files/fr/web/javascript/reference/global_objects/object/getownpropertydescriptors/index.md b/files/fr/web/javascript/reference/global_objects/object/getownpropertydescriptors/index.md index bed48a0ca10ae0..f387e68f60ee57 100644 --- a/files/fr/web/javascript/reference/global_objects/object/getownpropertydescriptors/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/getownpropertydescriptors/index.md @@ -13,7 +13,7 @@ La méthode **`Object.getOwnPropertyDescriptors()`** renvoie l'ensemble des desc ## Syntaxe ```js -Object.getOwnPropertyDescriptors(obj) +Object.getOwnPropertyDescriptors(obj); ``` ### Paramètres @@ -53,7 +53,7 @@ La méthode {{jsxref("Object.assign()")}} ne copiera que les propriétés propre ```js Object.create( Object.getPrototypeOf(obj), - Object.getOwnPropertyDescriptors(obj) + Object.getOwnPropertyDescriptors(obj), ); ``` @@ -62,19 +62,20 @@ Object.create( Pour créer une sous-classe, généralement, on définit la sous-classe et on définit son prototype comme étant une instance de la classe parente. Enfin on définit les propriétés de cette nouvelle sous-classe. ```js -function superclass() {}; +function superclass() {} superclass.prototype = { // on définit les méthodes et propriétés // de la classe parente }; -function subclass() {}; +function subclass() {} subclass.prototype = Object.create( superclass.prototype, Object.getOwnPropertyDescriptors({ - // on définit les méthodes et propriétés - // de la sous-classe -})); + // on définit les méthodes et propriétés + // de la sous-classe + }), +); ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/object/getownpropertynames/index.md b/files/fr/web/javascript/reference/global_objects/object/getownpropertynames/index.md index c13b516c31dfce..5df063f89623e6 100644 --- a/files/fr/web/javascript/reference/global_objects/object/getownpropertynames/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/getownpropertynames/index.md @@ -13,7 +13,7 @@ La méthode **`Object.getOwnPropertyNames()`** renvoie un tableau de toutes les ## Syntaxe ```js -Object.getOwnPropertyNames(obj) +Object.getOwnPropertyNames(obj); ``` ### Paramètres @@ -39,16 +39,14 @@ console.log(Object.getOwnPropertyNames(arr).sort()); // ["0", "1", "2", "length"] // Objet semblable à un tableau (array-like) -var obj = { 0: "a", 1: "b", 2: "c"}; +var obj = { 0: "a", 1: "b", 2: "c" }; console.log(Object.getOwnPropertyNames(obj).sort()); // ["0", "1", "2"] - // On affiche les noms et les valeurs // des propriétés avec Array.forEach -Object.getOwnPropertyNames(obj).forEach( - function(val, idx, array) { - console.log(val + " -> " + obj[val]); +Object.getOwnPropertyNames(obj).forEach(function (val, idx, array) { + console.log(val + " -> " + obj[val]); }); // affiche // 0 -> a @@ -56,12 +54,17 @@ Object.getOwnPropertyNames(obj).forEach( // 2 -> c // propriété non-énumérable -var mon_obj = Object.create({}, { - getToto: { - value: function() { return this.toto; }, - enumerable: false - } -}); +var mon_obj = Object.create( + {}, + { + getToto: { + value: function () { + return this.toto; + }, + enumerable: false, + }, + }, +); mon_obj.toto = 1; console.log(Object.getOwnPropertyNames(mon_obj).sort()); @@ -76,7 +79,7 @@ Les propriétés héritées via la chaîne de prototype ne sont pas listées : function ClasseParente() {} ClasseParente.prototype.inheritedMethod = function () {}; -function ClasseFille () { +function ClasseFille() { this.prop = 5; this.method = function () {}; } @@ -85,9 +88,9 @@ ClasseFille.prototype.prototypeMethod = function () {}; console.log( Object.getOwnPropertyNames( - new ClasseFille() // ["prop", "method"] - ) -) + new ClasseFille(), // ["prop", "method"] + ), +); ``` ### Obtenir uniquement les propriétés non-énumérables @@ -98,8 +101,8 @@ On utilise ici la fonction {{jsxref("Array.prototype.filter()")}} pour retirer l var target = myObject; var enum_et_nonenum = Object.getOwnPropertyNames(target); var enum_uniquement = Object.keys(target); -var nonenum_uniquement = enum_et_nonenum.filter(function(key) { - var indexInEnum = enum_uniquement.indexOf(key) +var nonenum_uniquement = enum_et_nonenum.filter(function (key) { + var indexInEnum = enum_uniquement.indexOf(key); if (indexInEnum == -1) { // non trouvée dans enum_uniquement indique // que la clé est non-énumérable, on la diff --git a/files/fr/web/javascript/reference/global_objects/object/getownpropertysymbols/index.md b/files/fr/web/javascript/reference/global_objects/object/getownpropertysymbols/index.md index 49a8ccc5554585..0c7ef6fa133665 100644 --- a/files/fr/web/javascript/reference/global_objects/object/getownpropertysymbols/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/getownpropertysymbols/index.md @@ -13,7 +13,7 @@ La méthode **`Object.getOwnPropertySymbols()`** renvoie un tableau contenant to ## Syntaxe ```js -Object.getOwnPropertySymbols(obj) +Object.getOwnPropertySymbols(obj); ``` ### Paramètres @@ -44,8 +44,8 @@ obj[b] = "symboleGlobal"; var objectSymboles = Object.getOwnPropertySymbols(obj); console.log(objectSymboles.length); // 2 -console.log(objectSymboles) // [Symbol(a), Symbol(b)] -console.log(objectSymboles[0]) // Symbol(a) +console.log(objectSymboles); // [Symbol(a), Symbol(b)] +console.log(objectSymboles[0]); // Symbol(a) ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/object/getprototypeof/index.md b/files/fr/web/javascript/reference/global_objects/object/getprototypeof/index.md index 2b4a1b7f532a94..6ae05d0604d6e3 100644 --- a/files/fr/web/javascript/reference/global_objects/object/getprototypeof/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/getprototypeof/index.md @@ -13,7 +13,7 @@ La méthode **`Object.getPrototypeOf()`** renvoie le prototype d'un objet donné ## Syntaxe ```js -Object.getPrototypeOf(obj) +Object.getPrototypeOf(obj); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/object/hasown/index.md b/files/fr/web/javascript/reference/global_objects/object/hasown/index.md index 1e0428ea633ca0..d6c36cd7f24d9e 100644 --- a/files/fr/web/javascript/reference/global_objects/object/hasown/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/hasown/index.md @@ -15,7 +15,7 @@ La méthode statique **`Object.hasOwn()`** renvoie `true` si l'objet indiqué po ## Syntaxe ```js -Object.hasOwn(instance,prop) +Object.hasOwn(instance, prop); ``` ### Paramètres @@ -43,16 +43,16 @@ Le code suivant illustre comment déterminer si l'objet `exemple` contient une p ```js let exemple = {}; -Object.hasOwn(exemple, 'prop'); // false : 'prop' n'a pas été définie +Object.hasOwn(exemple, "prop"); // false : 'prop' n'a pas été définie -exemple.prop = 'existe'; -Object.hasOwn(exemple, 'prop'); // true : 'prop' a été définie +exemple.prop = "existe"; +Object.hasOwn(exemple, "prop"); // true : 'prop' a été définie exemple.prop = null; -Object.hasOwn(exemple, 'prop'); // true : la propriété existe malgré sa valeur null +Object.hasOwn(exemple, "prop"); // true : la propriété existe malgré sa valeur null exemple.prop = undefined; -Object.hasOwn(exemple, 'prop'); // true : la propriété existe malgré sa valeur undefined +Object.hasOwn(exemple, "prop"); // true : la propriété existe malgré sa valeur undefined ``` ### Propriétés propres et propriétés héritées @@ -60,18 +60,18 @@ Object.hasOwn(exemple, 'prop'); // true : la propriété existe malgré sa val Dans l'exemple suivant, on distingue les propriétés propres/directes et celles qui sont héritées via la chaîne de prototypes : ```js -let exemple = {} -exemple.prop = 'existe'; +let exemple = {}; +exemple.prop = "existe"; // `Objet.hasOwn()` renverra true seulement pour les propriétés propres -Object.hasOwn(exemple, 'prop'); // renvoie true -Object.hasOwn(exemple, 'toString'); // renvoie false -Object.hasOwn(exemple, 'hasOwnProperty'); // renvoie false +Object.hasOwn(exemple, "prop"); // renvoie true +Object.hasOwn(exemple, "toString"); // renvoie false +Object.hasOwn(exemple, "hasOwnProperty"); // renvoie false // L'opérateur `in` renverra true pour les propriétés propres et héritées -'prop' in exemple; // renvoie true -'toString' in exemple; // renvoie true -'hasOwnProperty' in exemple; // renvoie true +"prop" in exemple; // renvoie true +"toString" in exemple; // renvoie true +"hasOwnProperty" in exemple; // renvoie true ``` ### Parcourir les propriétés d'un objet= @@ -101,9 +101,9 @@ for (let nom in exemple) { Les éléments d'un tableau ([`Array`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array)) sont définis comme propriétés propres. Ainsi, `Object.hasOwn()` pourra être utilisé pour vérifier si un indice donné existe : ```js -let fruits = ['Pomme', 'Banane', 'Melon', 'Orange']; -Object.hasOwn(fruits, 3); // true ('Orange') -Object.hasOwn(fruits, 4); // false, non défini +let fruits = ["Pomme", "Banane", "Melon", "Orange"]; +Object.hasOwn(fruits, 3); // true ('Orange') +Object.hasOwn(fruits, 4); // false, non défini ``` ### Cas problématiques pour hasOwnProperty() @@ -112,13 +112,13 @@ Cette section illustre l'immunité de `Object.hasOwn()` concernant des problème ```js let toto = { - hasOwnProperty: function() { + hasOwnProperty: function () { return false; }, - truc: 'Ga bu zo meu' + truc: "Ga bu zo meu", }; -if (Object.hasOwn(toto, 'truc')) { +if (Object.hasOwn(toto, "truc")) { console.log(toto.truc); //true - la surcharge de hasOwnProperty() n'a pas d'impact } ``` @@ -127,8 +127,8 @@ On peut également l'utiliser pour tester des objets créés avec [`Object.creat ```js let toto = Object.create(null); -toto.prop = 'existe'; -if (Object.hasOwn(toto, 'prop')) { +toto.prop = "existe"; +if (Object.hasOwn(toto, "prop")) { console.log(toto.prop); // true. } ``` diff --git a/files/fr/web/javascript/reference/global_objects/object/hasownproperty/index.md b/files/fr/web/javascript/reference/global_objects/object/hasownproperty/index.md index a71a37c093840c..47243adca37b69 100644 --- a/files/fr/web/javascript/reference/global_objects/object/hasownproperty/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/hasownproperty/index.md @@ -13,7 +13,7 @@ La méthode **`hasOwnProperty()`** retourne un booléen indiquant si l'objet pos ## Syntaxe ```js -obj.hasOwnProperty(prop) +obj.hasOwnProperty(prop); ``` ### Paramètres @@ -37,9 +37,9 @@ L'exemple suivant détermine si l'objet `o` contient une propriété appelée `p ```js o = new Object(); -o.hasOwnProperty('prop'); // false -o.prop = 'exists'; -o.hasOwnProperty('prop'); // true +o.hasOwnProperty("prop"); // false +o.prop = "exists"; +o.hasOwnProperty("prop"); // true ``` ### Propriétés directes et propriétés héritées @@ -48,15 +48,15 @@ L'exemple suivant illustre la différence entre les propriétés directes et les ```js o = new Object(); -o.prop = 'exists'; +o.prop = "exists"; -o.hasOwnProperty('prop'); +o.hasOwnProperty("prop"); // retourne true -o.hasOwnProperty('toString'); +o.hasOwnProperty("toString"); // retourne false -o.hasOwnProperty('hasOwnProperty'); +o.hasOwnProperty("hasOwnProperty"); // retourne false ``` @@ -66,20 +66,18 @@ L'exemple suivant montre comment parcourir les propriétés d'un objet sans trai ```js var bidule = { - truc: 'stack' + truc: "stack", }; for (var nom in bidule) { - if (bidule.hasOwnProperty(nom)) { - console.log("C'est bien la propriété (" + - nom + - "), sa valeur : " + bidule[nom] - ); - } - else { - console.log(nom); - // toString ou autre - } + if (bidule.hasOwnProperty(nom)) { + console.log( + "C'est bien la propriété (" + nom + "), sa valeur : " + bidule[nom], + ); + } else { + console.log(nom); + // toString ou autre + } } ``` @@ -89,20 +87,20 @@ JavaScript ne protège pas le nom de propriété `hasOwnProperty`, ainsi il est ```js var toto = { - hasOwnProperty: function() { + hasOwnProperty: function () { return false; }, - truc: 'Voici les dragons' + truc: "Voici les dragons", }; -toto.hasOwnProperty('truc'); // renvoie toujours false +toto.hasOwnProperty("truc"); // renvoie toujours false // On utilise une méthode d'un autre objet // et on l'appelle avec this qui vaut toto -({}).hasOwnProperty.call(toto, 'truc'); // true +({}).hasOwnProperty.call(toto, "truc"); // true // On peut aussi utiliser la propriété hasOwnProperty de Object prototype -Object.prototype.hasOwnProperty.call(toto, 'truc'); // true +Object.prototype.hasOwnProperty.call(toto, "truc"); // true ``` La dernière version utilisée permet de ne pas créer d'objet supplémentaire. diff --git a/files/fr/web/javascript/reference/global_objects/object/index.md b/files/fr/web/javascript/reference/global_objects/object/index.md index 887c9f7b675fe9..811a601b08b5e6 100644 --- a/files/fr/web/javascript/reference/global_objects/object/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/index.md @@ -60,7 +60,7 @@ Il n'existe pas de méthode pour `Object` qui permette de supprimer une proprié - [`Object.getPrototypeOf()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf) - : Retourne le prototype de l'objet indiqué. - [`Object.is()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Object/is) - - : Détermine si deux valeurs sont la même valeur. Considère comme égales toutes les valeurs NaN (ce qui diffère à la fois de la *comparaison d'égalité abstraite* et de la *comparaison d'égalité stricte*). + - : Détermine si deux valeurs sont la même valeur. Considère comme égales toutes les valeurs NaN (ce qui diffère à la fois de la _comparaison d'égalité abstraite_ et de la _comparaison d'égalité stricte_). - [`Object.isExtensible()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible) - : Détermine si l'extension d'un objet est permise. - [`Object.isFrozen()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen) diff --git a/files/fr/web/javascript/reference/global_objects/object/is/index.md b/files/fr/web/javascript/reference/global_objects/object/is/index.md index 6608cda48fad65..2347ad9204ee51 100644 --- a/files/fr/web/javascript/reference/global_objects/object/is/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/is/index.md @@ -48,32 +48,33 @@ Cette égalité est également différente de l'égalité stricte qu'on peut avo ## Exemples ```js -Object.is("toto", "toto"); // true -Object.is(window, window); // true +Object.is("toto", "toto"); // true +Object.is(window, window); // true -Object.is("toto", "truc"); // false -Object.is([], []); // false +Object.is("toto", "truc"); // false +Object.is([], []); // false -var toto = {a: 1}; -var truc = {a: 1}; -Object.is(toto, toto); // true -Object.is(toto, truc); // false +var toto = { a: 1 }; +var truc = { a: 1 }; +Object.is(toto, toto); // true +Object.is(toto, truc); // false -Object.is(null, null); // true +Object.is(null, null); // true // Cas aux limites (cas spéciaux) -Object.is(0, -0); // false -Object.is(-0, -0); // true -Object.is(NaN, 0/0); // true +Object.is(0, -0); // false +Object.is(-0, -0); // true +Object.is(NaN, 0 / 0); // true ``` ## Prothèse d'émulation (_polyfill_) ```js if (!Object.is) { - Object.is = function(v1, v2) { + Object.is = function (v1, v2) { // Algorithme SameValue - if (v1 === v2) { //Étapes 1-5, 7-10 + if (v1 === v2) { + //Étapes 1-5, 7-10 //Étapes 6.b-6.b +0 !=-0 return v1 !== 0 || 1 / v1 === 1 / v2; } else { diff --git a/files/fr/web/javascript/reference/global_objects/object/isextensible/index.md b/files/fr/web/javascript/reference/global_objects/object/isextensible/index.md index de8a886d33af24..b4b9bfe00a1d90 100644 --- a/files/fr/web/javascript/reference/global_objects/object/isextensible/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/isextensible/index.md @@ -13,7 +13,7 @@ La méthode **`Object.isExtensible()`** permet de déterminer si un objet est ex ## Syntaxe ```js -Object.isExtensible(obj) +Object.isExtensible(obj); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/object/isfrozen/index.md b/files/fr/web/javascript/reference/global_objects/object/isfrozen/index.md index 10b236c1e8ba6b..54a753f6054a53 100644 --- a/files/fr/web/javascript/reference/global_objects/object/isfrozen/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/isfrozen/index.md @@ -13,7 +13,7 @@ La méthode **`Object.isFrozen()`** permet de déterminer si un objet est {{jsxr ## Syntaxe ```js -Object.isFrozen(obj) +Object.isFrozen(obj); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/object/isprototypeof/index.md b/files/fr/web/javascript/reference/global_objects/object/isprototypeof/index.md index 99db201dfe30c2..e65d99932db42a 100644 --- a/files/fr/web/javascript/reference/global_objects/object/isprototypeof/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/isprototypeof/index.md @@ -15,7 +15,7 @@ La méthode **`isPrototypeOf()`** permet de tester si un objet existe dans la ch ## Syntaxe ```js -prototypeObj.isPrototypeOf(objet) +prototypeObj.isPrototypeOf(objet); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/object/issealed/index.md b/files/fr/web/javascript/reference/global_objects/object/issealed/index.md index 4b2b16ff68ea59..894775136eeb3f 100644 --- a/files/fr/web/javascript/reference/global_objects/object/issealed/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/issealed/index.md @@ -13,7 +13,7 @@ La méthode **`Object.isSealed()`** permet de déterminer si un objet est scell ## Syntaxe ```js -Object.isSealed(obj) +Object.isSealed(obj); ``` ### Paramètres @@ -68,10 +68,14 @@ Object.isFrozen(scellé); // true var s2 = Object.seal({ p: 3 }); Object.isFrozen(s2); // false ("p" est toujours modifiable) -var s3 = Object.seal({ get p() { return 0; } }); +var s3 = Object.seal({ + get p() { + return 0; + }, +}); // pour les accesseurs, seule l'accès en // configuration est important -Object.isFrozen(s3); // true +Object.isFrozen(s3); // true ``` ## Notes diff --git a/files/fr/web/javascript/reference/global_objects/object/keys/index.md b/files/fr/web/javascript/reference/global_objects/object/keys/index.md index 0d164ff488ea28..dd839274fa2260 100644 --- a/files/fr/web/javascript/reference/global_objects/object/keys/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/keys/index.md @@ -13,7 +13,7 @@ La méthode **`Object.keys()`** renvoie un tableau contenant les noms des propri ## Syntaxe ```js -Object.keys(obj) +Object.keys(obj); ``` ### Paramètres @@ -37,23 +37,27 @@ console.log(Object.keys(arr)); // affichera ['0', '1', '2'] // un objet semblable à un tableau -var obj = { 0 : "a", 1 : "b", 2 : "c"}; +var obj = { 0: "a", 1: "b", 2: "c" }; console.log(Object.keys(obj)); // affichera ['0', '1', '2'] // un objet semblable à un tableau avec // un ordre de clé aléatoire -var an_obj = { 100: "a", 2: "b", 7: "c"}; +var an_obj = { 100: "a", 2: "b", 7: "c" }; console.log(Object.keys(an_obj)); // affichera ['2', '7', '100'] // getToto est une propriété non énumérable -var monObjet = Object.create({}, { - getToto : { - value : function () { - return this.toto } - } - }); +var monObjet = Object.create( + {}, + { + getToto: { + value: function () { + return this.toto; + }, + }, + }, +); monObjet.toto = 1; console.log(Object.keys(monObjet)); diff --git a/files/fr/web/javascript/reference/global_objects/object/object/index.md b/files/fr/web/javascript/reference/global_objects/object/object/index.md index e1577aa862c6b1..85c048da6822e7 100644 --- a/files/fr/web/javascript/reference/global_objects/object/object/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/object/index.md @@ -17,8 +17,8 @@ Lorsqu'il est appelé comme une fonction plutôt que comme un constructeur (c'es ## Syntaxe ```js -new Object() -new Object(valeur) +new Object(); +new Object(valeur); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/object/preventextensions/index.md b/files/fr/web/javascript/reference/global_objects/object/preventextensions/index.md index 98df4de609f973..7b6d9078680292 100644 --- a/files/fr/web/javascript/reference/global_objects/object/preventextensions/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/preventextensions/index.md @@ -13,7 +13,7 @@ La méthode **`Object.preventExtensions()`** permet d'empêcher l'ajout de nouve ## Syntaxe ```js -Object.preventExtensions(obj) +Object.preventExtensions(obj); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/object/propertyisenumerable/index.md b/files/fr/web/javascript/reference/global_objects/object/propertyisenumerable/index.md index b935bbd62ae9fd..731f2ec3162cf8 100644 --- a/files/fr/web/javascript/reference/global_objects/object/propertyisenumerable/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/propertyisenumerable/index.md @@ -13,7 +13,7 @@ La méthode **`propertyIsEnumerable()`** renvoie un booléen qui indique si la p ## Syntaxe ```js -obj.propertyIsEnumerable(prop) +obj.propertyIsEnumerable(prop); ``` ### Paramètres @@ -38,11 +38,11 @@ Dans l'exemple qui suit, on illustre comment utiliser `propertyIsEnumerable` sur ```js var o = {}; var a = []; -o.prop = 'est énumérable'; -a[0] = 'est énumérable'; +o.prop = "est énumérable"; +a[0] = "est énumérable"; -o.propertyIsEnumerable('prop'); // renvoie true -a.propertyIsEnumerable(0); // renvoie true +o.propertyIsEnumerable("prop"); // renvoie true +a.propertyIsEnumerable(0); // renvoie true ``` ### Objets natifs et objets définis par l'utilisateur @@ -50,50 +50,52 @@ a.propertyIsEnumerable(0); // renvoie true Dans l'exemple ci-dessous, on illustre l'énumérabilité des propriétés des objets natifs et celle des objets tiers, définis dans les scripts : ```js -var a = ['est énumérable']; +var a = ["est énumérable"]; -a.propertyIsEnumerable(0); // renvoie true -a.propertyIsEnumerable('length'); // renvoie false +a.propertyIsEnumerable(0); // renvoie true +a.propertyIsEnumerable("length"); // renvoie false -Math.propertyIsEnumerable('random'); // renvoie false -this.propertyIsEnumerable('Math'); // renvoie false +Math.propertyIsEnumerable("random"); // renvoie false +this.propertyIsEnumerable("Math"); // renvoie false ``` ### Propriétés héritées et propriétés propres ```js var a = []; -a.propertyIsEnumerable('constructor'); // renvoie false +a.propertyIsEnumerable("constructor"); // renvoie false function premierConstructeur() { - this.propriete = 'non énumérable'; + this.propriete = "non énumérable"; } -premierConstructeur.prototype.premiereMethode = function() {}; +premierConstructeur.prototype.premiereMethode = function () {}; function secondConstructeur() { - this.methode = function methode() { return 'énumérable'; }; + this.methode = function methode() { + return "énumérable"; + }; } -secondConstructeur.prototype = new premierConstructeur; +secondConstructeur.prototype = new premierConstructeur(); secondConstructeur.prototype.constructor = secondConstructeur; var o = new secondConstructeur(); -o.propArbitraire = 'is enumerable'; +o.propArbitraire = "is enumerable"; -o.propertyIsEnumerable('propArbitraire'); // renvoie true -o.propertyIsEnumerable('méthode'); // renvoie true -o.propertyIsEnumerable('propriété'); // renvoie false +o.propertyIsEnumerable("propArbitraire"); // renvoie true +o.propertyIsEnumerable("méthode"); // renvoie true +o.propertyIsEnumerable("propriété"); // renvoie false -o.propriete = 'énumérable'; +o.propriete = "énumérable"; -o.propertyIsEnumerable('propriété'); // renvoie true +o.propertyIsEnumerable("propriété"); // renvoie true // Ces instructions renvoient false car propertyIsEnumerable // ne prend pas en compte la chaîne de prototypes -o.propertyIsEnumerable('prototype'); // renvoie false -o.propertyIsEnumerable('constructor'); // renvoie false -o.propertyIsEnumerable('premièreMéthode'); // renvoie false +o.propertyIsEnumerable("prototype"); // renvoie false +o.propertyIsEnumerable("constructor"); // renvoie false +o.propertyIsEnumerable("premièreMéthode"); // renvoie false ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/object/proto/index.md b/files/fr/web/javascript/reference/global_objects/object/proto/index.md index cef3267be619a9..930c56679e84b2 100644 --- a/files/fr/web/javascript/reference/global_objects/object/proto/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/proto/index.md @@ -52,8 +52,12 @@ console.log(aucunProto.__proto__); // 17 console.log(Object.getPrototypeOf(aucunProto)); // null var protoCaché = {}; -Object.defineProperty(protoCaché, "__proto__", - { value: 42, writable: true, configurable: true, enumerable: true }); +Object.defineProperty(protoCaché, "__proto__", { + value: 42, + writable: true, + configurable: true, + enumerable: true, +}); console.log(protoCaché.__proto__); // 42 console.log(Object.getPrototypeOf(protoCaché) === Object.prototype); // true @@ -101,9 +105,16 @@ On notera que même la propriété `__proto__` de `Object.prototype` peut être ```js var b = {}; -Object.prototype.__proto__ = - Object.create(null, //[[Prototype]] - { salut: { value: function () {console.log('salut');}}}); +Object.prototype.__proto__ = Object.create( + null, //[[Prototype]] + { + salut: { + value: function () { + console.log("salut"); + }, + }, + }, +); b.salut(); ``` diff --git a/files/fr/web/javascript/reference/global_objects/object/seal/index.md b/files/fr/web/javascript/reference/global_objects/object/seal/index.md index 27f5c5edb25060..ec8ef00f3a1a03 100644 --- a/files/fr/web/javascript/reference/global_objects/object/seal/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/seal/index.md @@ -13,7 +13,7 @@ La méthode **`Object.seal()`** scelle un objet afin d'empêcher l'ajout de nouv ## Syntaxe ```js -Object.seal(obj) +Object.seal(obj); ``` ### Paramètres @@ -35,9 +35,9 @@ La chaîne de prototypes reste la même. Cependant, la propriété [`Object.prot ```js var obj = { - prop: function () {}, - toto: "truc" - }; + prop: function () {}, + toto: "truc", +}; // On peut ajouter de nouvelles propriétés // Les propriétés existantes peuvent être @@ -57,7 +57,11 @@ obj.toto = "moh"; // Mais on ne peut pas convertir les données // en accesseurs (ou vice versa) -Object.defineProperty(obj, "toto", { get: function() { return "g"; } }); +Object.defineProperty(obj, "toto", { + get: function () { + return "g"; + }, +}); // lancera une TypeError // Tout autre changement que celui d'une valeur diff --git a/files/fr/web/javascript/reference/global_objects/object/setprototypeof/index.md b/files/fr/web/javascript/reference/global_objects/object/setprototypeof/index.md index d13ad09d8b4915..eaebeff9b2a22c 100644 --- a/files/fr/web/javascript/reference/global_objects/object/setprototypeof/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/setprototypeof/index.md @@ -13,7 +13,7 @@ La méthode **`Object.setPrototypeOf()`** définit le prototype (autrement dit l ## Syntaxe ```js -Object.setPrototypeOf(obj, prototype) +Object.setPrototypeOf(obj, prototype); ``` ### Paramètres @@ -45,10 +45,12 @@ En utilisant la propriété [`Object.prototype.__proto__`](/fr/docs/Web/JavaScri ```js // Cette prothèse ne fonctionne pas pour IE -Object.setPrototypeOf = Object.setPrototypeOf || function (obj, proto) { - obj.__proto__ = proto; - return obj; -} +Object.setPrototypeOf = + Object.setPrototypeOf || + function (obj, proto) { + obj.__proto__ = proto; + return obj; + }; ``` ## Ajouter une chaîne de prototypes à un objet @@ -57,10 +59,10 @@ En combinant `Object.getPrototypeOf()` et [`Object.prototype.__proto__`](/fr/doc ```js /** -*** Object.setPrototypeOf(@object, @prototype) -* Change le prototype d'une instance -* -**/ + *** Object.setPrototypeOf(@object, @prototype) + * Change le prototype d'une instance + * + **/ Object.setPrototypeOf = function (oInstance, oProto) { oInstance.__proto__ = oProto; @@ -68,32 +70,42 @@ Object.setPrototypeOf = function (oInstance, oProto) { }; /** -*** Object.appendChain(@object, @prototype) -* -* Ajoute le premier prototype non-natif d'une chaîne au nouveau prototype. -* Renvoie @object (si c'est une valeur primitive, elle sera transformée -* en objet). -* -*** Object.appendChain(@object [, "@arg_name_1", "@arg_name_2", "@arg_name_3", "..."], "@function_body") -*** Object.appendChain(@object [, "@arg_name_1, @arg_name_2, @arg_name_3, ..."], "@function_body") -* -* Ajoute le premier prototype non-natif d'une chaîne à l'objet Function.prototype -* puis ajoute new Function(["@arg"(s)], "@function_body") à cette chaîne. -* Renvoie la fonction. -* -**/ + *** Object.appendChain(@object, @prototype) + * + * Ajoute le premier prototype non-natif d'une chaîne au nouveau prototype. + * Renvoie @object (si c'est une valeur primitive, elle sera transformée + * en objet). + * + *** Object.appendChain(@object [, "@arg_name_1", "@arg_name_2", "@arg_name_3", "..."], "@function_body") + *** Object.appendChain(@object [, "@arg_name_1, @arg_name_2, @arg_name_3, ..."], "@function_body") + * + * Ajoute le premier prototype non-natif d'une chaîne à l'objet Function.prototype + * puis ajoute new Function(["@arg"(s)], "@function_body") à cette chaîne. + * Renvoie la fonction. + * + **/ Object.appendChain = function (oChain, oProto) { if (arguments.length < 2) { throw new TypeError("Object.appendChain - Pas suffisamment d'arguments"); } - if (typeof oProto !== 'object' && typeof oProto !== 'string') { - throw new TypeError("le deuxième argument de Object.appendChain doit être un objet ou une chaîne"); + if (typeof oProto !== "object" && typeof oProto !== "string") { + throw new TypeError( + "le deuxième argument de Object.appendChain doit être un objet ou une chaîne", + ); } - var oNewProto = oProto, oReturn = o2nd = oLast = oChain instanceof this ? oChain : new oChain.constructor(oChain); - - for (var o1st = this.getPrototypeOf(o2nd); o1st !== Object.prototype && o1st !== Function.prototype; o1st = this.getPrototypeOf(o2nd)) { + var oNewProto = oProto, + oReturn = + (o2nd = + oLast = + oChain instanceof this ? oChain : new oChain.constructor(oChain)); + + for ( + var o1st = this.getPrototypeOf(o2nd); + o1st !== Object.prototype && o1st !== Function.prototype; + o1st = this.getPrototypeOf(o2nd) + ) { o2nd = o1st; } @@ -105,7 +117,7 @@ Object.appendChain = function (oChain, oProto) { this.setPrototypeOf(o2nd, oNewProto); return oReturn; -} +}; ``` ### Utilisation @@ -113,11 +125,11 @@ Object.appendChain = function (oChain, oProto) { #### Ajouter une chaîne de prototypes à un prototype ```js -function Mammifère () { +function Mammifère() { this.isMammifère = "oui"; } -function EspèceMammifère (sEspèceMammifère) { +function EspèceMammifère(sEspèceMammifère) { this.espèce = sEspèceMammifère; } @@ -128,7 +140,7 @@ var oChat = new EspèceMammifère("Felis"); console.log(oChat.isMammifère); // "oui" -function Animal () { +function Animal() { this.respire = "oui"; } @@ -140,7 +152,7 @@ console.log(oChat.respire); // "oui" #### Deuxième exemple : Transformer une valeur primitive en une instance de son constructeur et ajouter sa chaîne à un prototype ```js -function MySymbol () { +function MySymbol() { this.isSymbol = "yes"; } @@ -158,12 +170,14 @@ console.log(typeof oPrime); // "object" #### Troisième exemple : Ajouter une chaîne de prototypes à l'objet Function.prototype object et ajouter une nouvelle fonction à cette chaîne ```js -function Personne (sNom) { +function Personne(sNom) { this.identité = sNom; } -var george = Object.appendChain(new Person("George"), - "console.log(\"Salut !!\");"); +var george = Object.appendChain( + new Person("George"), + 'console.log("Salut !!");', +); console.log(george.identité); // "George" george(); // "Salut !!" diff --git a/files/fr/web/javascript/reference/global_objects/object/tolocalestring/index.md b/files/fr/web/javascript/reference/global_objects/object/tolocalestring/index.md index 0bc845fb21c25e..970f35c1aa3d5e 100644 --- a/files/fr/web/javascript/reference/global_objects/object/tolocalestring/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/tolocalestring/index.md @@ -13,7 +13,7 @@ La méthode **`toLocaleString()`** renvoie une chaine de caractères représenta ## Syntaxe ```js -obj.toLocaleString() +obj.toLocaleString(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/object/tostring/index.md b/files/fr/web/javascript/reference/global_objects/object/tostring/index.md index 8ef6b90b6df900..e23257c39b7907 100644 --- a/files/fr/web/javascript/reference/global_objects/object/tostring/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/tostring/index.md @@ -13,7 +13,7 @@ La méthode **`toString()`** renvoie une chaîne de caractères représentant l' ## Syntaxe ```js -obj.toString() +obj.toString(); ``` ### Valeur de retour @@ -26,7 +26,7 @@ Chaque object possède une méthode `toString()` qui est appelée de façon auto ```js var o = new Object(); -o.toString(); // renvoie [object Object] +o.toString(); // renvoie [object Object] ``` > **Note :** À partir de JavaScript 1.8.5 `toString()`, lorsqu'elle est appelée sur {{jsxref("null")}} renvoie `[object Null]`, et lorsqu'elle est appelée sur {{jsxref("undefined")}} renvoie `[object Undefined]`, ce qui est conforme à ECMAScript 5 et aux errata qui ont suivis. Voir l'exemple ci-après [Utiliser `toString` pour détecter le type d'un objet](#detect). @@ -47,7 +47,7 @@ function Chien(nom, race, couleur, sexe) { this.sexe = sexe; } -monChien = new Chien('Gabby', 'Labrador', 'chocolat', 'femelle'); +monChien = new Chien("Gabby", "Labrador", "chocolat", "femelle"); ``` Si on appelle la méthode `toString()` sur cet objet, on aura le résultat suivant (provenant de la méthode originale, héritée d'{{jsxref("Object")}}) : @@ -60,9 +60,17 @@ Dans le code qui suit, on surcharge la méthode `toString()` avec `chienToString ```js Chien.prototype.toString = function chienToString() { - var ret = 'Le chien ' + this.nom + ' est un ' + this.race + ' ' + this.sexe + ' ' + this.couleur; + var ret = + "Le chien " + + this.nom + + " est un " + + this.race + + " " + + this.sexe + + " " + + this.couleur; return ret; -} +}; ``` En utilisant la fonction ci-avant, à chaque fois que `monChien` sera utilisé là où on attend une chaîne, le moteur JavaScript appellera automatique la fonction `chienToString()` qui renverra la chaîne suivante : @@ -78,13 +86,13 @@ Le chien Gabby est un labrador femelle chocolat. ```js var toString = Object.prototype.toString; -toString.call(new Date); // [object Date] -toString.call(new String); // [object String] -toString.call(Math); // [object Math] +toString.call(new Date()); // [object Date] +toString.call(new String()); // [object String] +toString.call(Math); // [object Math] // Depuis JavaScript 1.8.5 -toString.call(undefined); // [object Undefined] -toString.call(null); // [object Null] +toString.call(undefined); // [object Undefined] +toString.call(null); // [object Null] ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/object/valueof/index.md b/files/fr/web/javascript/reference/global_objects/object/valueof/index.md index fa5dd7e59a7b0e..4d773fa6890d44 100644 --- a/files/fr/web/javascript/reference/global_objects/object/valueof/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/valueof/index.md @@ -13,7 +13,7 @@ La méthode **`valueOf()`** renvoie la valeur primitive d'un objet donné. ## Syntaxe ```js -object.valueOf() +object.valueOf(); ``` ### Valeur de retour @@ -39,7 +39,9 @@ Il est possible de créer une fonction à appeler à la place de la méthode `va Supposons qu'on ait un type d'objet `monTypeDeNombre` et qu'on désire lui ajouter une méthode `valueOf` spécifique, on pourra utiliser le code suivant : ```js -monTypeDeNombre.prototype.valueOf = function(){ return valeurPrimitive;}; +monTypeDeNombre.prototype.valueOf = function () { + return valeurPrimitive; +}; ``` En utilisant ce code, chaque fois qu'un objet de type `monTypeDeNombre` sera utilisé dans un contexte où il doit être représenté comme une valeur primitive, JavaScript appellera automatiquement la fonction qui y est définie. @@ -47,7 +49,7 @@ En utilisant ce code, chaque fois qu'un objet de type `monTypeDeNombre` sera uti C'est habituellement JavaScript qui invoquera la méthode `valueOf`, mais il est aussi possible de l'appeler soi-même : ```js -monNombre.valueOf() +monNombre.valueOf(); ``` > **Note :** Les objets à utiliser dans un contexte textuel sont convertis avec la méthode {{jsxref("Object.toString", "toString()")}} ce qui est différent de la conversion d'objets {{jsxref("String")}} en valeurs primitives avec `valueOf`. Tous les objets peuvent être convertis en chaînes de caractères (la façon la plus générique étant "`[object type]`"). En revanche, la plupart des objets ne peut pas être convertie en nombre ou booléen par exemple. @@ -58,12 +60,12 @@ monNombre.valueOf() ```js function MonTypeDeNombre(n) { - this.nombre = n; + this.nombre = n; } -MonTypeDeNombre.prototype.valueOf = function(){ +MonTypeDeNombre.prototype.valueOf = function () { return this.nombre; -} +}; var monObj = new MonTypeDeNombre(4); console.log(monObj + 3); // 7 car l'opération a implicitement utilisé valueOf diff --git a/files/fr/web/javascript/reference/global_objects/object/values/index.md b/files/fr/web/javascript/reference/global_objects/object/values/index.md index e1e478efe8ddd9..d008cef25b3e90 100644 --- a/files/fr/web/javascript/reference/global_objects/object/values/index.md +++ b/files/fr/web/javascript/reference/global_objects/object/values/index.md @@ -13,7 +13,7 @@ La méthode **`Object.values()`** renvoie un tableau contenant les valeurs des p ## Syntaxe ```js -Object.values(obj) +Object.values(obj); ``` ### Paramètres @@ -36,19 +36,28 @@ var obj = { toto: "truc", machin: 42 }; console.log(Object.values(obj)); // ['truc', 42] // un objet semblable à un tableau -var obj = { 0: 'a', 1: 'b', 2: 'c' }; +var obj = { 0: "a", 1: "b", 2: "c" }; console.log(Object.values(obj)); // ['a', 'b', 'c'] // un objet semblable à un tableau // dont les clés sont ordonnées aléatoirement // lorsque des clés numériques sont utilisées, les valeurs sont // renvoyées selon l'ordre numérique des clés -var un_obj = { 100: 'a', 2: 'b', 7: 'c' }; +var un_obj = { 100: "a", 2: "b", 7: "c" }; console.log(Object.values(un_obj)); // ['b', 'c', 'a'] // getToto est une propriété qui // n'est pas énumérable -var mon_obj = Object.create({}, { getToto: { value: function() { return this.toto; } } }); +var mon_obj = Object.create( + {}, + { + getToto: { + value: function () { + return this.toto; + }, + }, + }, +); mon_obj.toto = "truc"; console.log(Object.values(mon_obj)); // ['truc'] diff --git a/files/fr/web/javascript/reference/global_objects/parsefloat/index.md b/files/fr/web/javascript/reference/global_objects/parsefloat/index.md index 9341a628687765..4ac4fb230dee1e 100644 --- a/files/fr/web/javascript/reference/global_objects/parsefloat/index.md +++ b/files/fr/web/javascript/reference/global_objects/parsefloat/index.md @@ -13,7 +13,7 @@ La fonction **`parseFloat()`** permet de transformer une chaîne de caractères ## Syntaxe ```js -parseFloat(string) +parseFloat(string); ``` ### Paramètres @@ -56,7 +56,9 @@ parseFloat("0.0314E+2"); parseFloat("3.14d'autres caractères non numériques"); var titi = Object.create(null); -titi.valueOf = function () { return "3.14"; }; +titi.valueOf = function () { + return "3.14"; +}; parseFloat(titi); ``` @@ -81,20 +83,19 @@ Si on souhaite éviter de convertir des chaînes qui contiennent des caractères ```js var filterFloat = function (value) { - if (/^(\-|\+)?([0-9]+(\.[0-9]+)?|Infinity)$/ - .test(value)) - return Number(value); + if (/^(\-|\+)?([0-9]+(\.[0-9]+)?|Infinity)$/.test(value)) + return Number(value); return NaN; -} - -console.log(filterFloat('421')); // 421 -console.log(filterFloat('-421')); // -421 -console.log(filterFloat('+421')); // 421 -console.log(filterFloat('Infinity')); // Infinity -console.log(filterFloat('1.61803398875')); // 1.61803398875 -console.log(filterFloat('421e+0')); // NaN -console.log(filterFloat('421hop')); // NaN -console.log(filterFloat('hop1.61803398875')); // NaN +}; + +console.log(filterFloat("421")); // 421 +console.log(filterFloat("-421")); // -421 +console.log(filterFloat("+421")); // 421 +console.log(filterFloat("Infinity")); // Infinity +console.log(filterFloat("1.61803398875")); // 1.61803398875 +console.log(filterFloat("421e+0")); // NaN +console.log(filterFloat("421hop")); // NaN +console.log(filterFloat("hop1.61803398875")); // NaN ``` Attention : ce code n'est qu'un exemple et renverra `NaN` pour des valeurs pourtant valides comme `1.` ou `.5`. diff --git a/files/fr/web/javascript/reference/global_objects/parseint/index.md b/files/fr/web/javascript/reference/global_objects/parseint/index.md index 3c7c89da5cbdfc..1976e8b2c68552 100644 --- a/files/fr/web/javascript/reference/global_objects/parseint/index.md +++ b/files/fr/web/javascript/reference/global_objects/parseint/index.md @@ -78,8 +78,8 @@ Les exemples suivants renvoient **`NaN`** : ```js parseInt("Coucou", 8); // Ce sont des lettres et pas des chiffres -parseInt("546", 2); // Ces chiffres ne sont pas valides pour une représentation - // binaire +parseInt("546", 2); // Ces chiffres ne sont pas valides pour une représentation +// binaire ``` Les exemples suivants renvoient tous **`-15`** : @@ -88,7 +88,7 @@ Les exemples suivants renvoient tous **`-15`** : parseInt("-F", 16); parseInt("-0F", 16); parseInt("-0XF", 16); -parseInt(-15.1, 10) +parseInt(-15.1, 10); parseInt("-17", 8); parseInt("-15", 10); parseInt("-1111", 2); @@ -121,7 +121,7 @@ Bien que cela soit fortement déconseillé par ECMAScript 3 et que cela soit int ```js parseInt("0e0"); // 0 -parseInt("08"); // 0, '8' n'est pas un chiffre octal. +parseInt("08"); // 0, '8' n'est pas un chiffre octal. ``` ### ECMAScript 5 supprime l'interprétation octale @@ -140,19 +140,18 @@ Il est parfois utile d'avoir une fonction de conversion plus stricte. Pour cela, ```js filterInt = function (value) { - if (/^(-|\+)?(\d+|Infinity)$/.test(value)) - return Number(value); + if (/^(-|\+)?(\d+|Infinity)$/.test(value)) return Number(value); return NaN; -} - -console.log(filterInt('421')); // 421 -console.log(filterInt('-421')); // -421 -console.log(filterInt('+421')); // 421 -console.log(filterInt('Infinity')); // Infinity -console.log(filterInt('421e+0')); // NaN -console.log(filterInt('421hop')); // NaN -console.log(filterInt('hop1.61803398875')); // NaN -console.log(filterInt('1.61803398875')); // NaN +}; + +console.log(filterInt("421")); // 421 +console.log(filterInt("-421")); // -421 +console.log(filterInt("+421")); // 421 +console.log(filterInt("Infinity")); // Infinity +console.log(filterInt("421e+0")); // NaN +console.log(filterInt("421hop")); // NaN +console.log(filterInt("hop1.61803398875")); // NaN +console.log(filterInt("1.61803398875")); // NaN ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/promise/all/index.md b/files/fr/web/javascript/reference/global_objects/promise/all/index.md index 4520ef8ed59ef6..dfb98d2e2fb415 100644 --- a/files/fr/web/javascript/reference/global_objects/promise/all/index.md +++ b/files/fr/web/javascript/reference/global_objects/promise/all/index.md @@ -48,10 +48,10 @@ Cette méthode peut être utile lorsqu'on souhaite agréger le résultat de plus var p1 = Promise.resolve(3); var p2 = 1337; var p3 = new Promise((resolve, reject) => { - setTimeout(resolve, 100, 'foo'); + setTimeout(resolve, 100, "foo"); }); -Promise.all([p1, p2, p3]).then(values => { +Promise.all([p1, p2, p3]).then((values) => { console.log(values); // [3, 1337, "foo"] }); ``` @@ -62,36 +62,41 @@ La promesse créée par `Promise.all()` échoue immédiatement si l'une des prom ```js var p1 = new Promise((resolve, reject) => { - setTimeout(resolve, 1000, 'un'); + setTimeout(resolve, 1000, "un"); }); var p2 = new Promise((resolve, reject) => { - setTimeout(resolve, 2000, 'deux'); + setTimeout(resolve, 2000, "deux"); }); var p3 = new Promise((resolve, reject) => { - setTimeout(resolve, 3000, 'trois'); + setTimeout(resolve, 3000, "trois"); }); var p4 = new Promise((resolve, reject) => { - setTimeout(resolve, 4000, 'quatre'); + setTimeout(resolve, 4000, "quatre"); }); var p5 = new Promise((resolve, reject) => { - reject('rejet'); + reject("rejet"); }); -Promise.all([p1, p2, p3, p4, p5]).then(values => { - console.log(values); -}, reason => { - console.log(reason) -}); +Promise.all([p1, p2, p3, p4, p5]).then( + (values) => { + console.log(values); + }, + (reason) => { + console.log(reason); + }, +); // Dans la console : // "rejet" //On peut aussi employer .catch -Promise.all([p1, p2, p3, p4, p5]).then(values => { - console.log(values); -}).catch(reason => { - console.log(reason) -}); +Promise.all([p1, p2, p3, p4, p5]) + .then((values) => { + console.log(values); + }) + .catch((reason) => { + console.log(reason); + }); // Dans la console : // "rejet" @@ -101,20 +106,24 @@ Il est possible de modifier ce comportement en gérant les éventuels échecs : ```js var p1 = new Promise((resolve, reject) => { - setTimeout(resolve, 1000, 'p1_resolution_retardee'); + setTimeout(resolve, 1000, "p1_resolution_retardee"); }); var p2 = new Promise((resolve, reject) => { - reject(new Error('p2_rejet_immediat')); + reject(new Error("p2_rejet_immediat")); }); Promise.all([ - p1.catch(error => { return error }), - p2.catch(error => { return error }), -]).then(values => { + p1.catch((error) => { + return error; + }), + p2.catch((error) => { + return error; + }), +]).then((values) => { console.log(values[0]); // "p1_resolution_retardee" console.log(values[1]); // "Error: p2_rejet_immediat" -}) +}); ``` ### Caractère asynchrone de `Promise.all()` @@ -132,9 +141,9 @@ console.log(p); // on utilise la méthode setTimeout pour exécuter // du code dès que la pile est vide -setTimeout(function() { - console.log('La pile est vide'); - console.log(p); +setTimeout(function () { + console.log("La pile est vide"); + console.log(p); }); // Cela affichera dans la console (et dans cet ordre) : @@ -149,9 +158,9 @@ On aura le même comportement si `Promise.all` produit une promesse rompue : var mixedPromisesArray = [Promise.resolve(33), Promise.reject(44)]; var p = Promise.all(mixedPromisesArray); console.log(p); -setTimeout(function() { - console.log('La pile est vide'); - console.log(p); +setTimeout(function () { + console.log("La pile est vide"); + console.log(p); }); // Affichera : @@ -170,10 +179,10 @@ var p = Promise.all([]); // immédiatement résolue // de façon asynchrone var p2 = Promise.all([1337, "hi"]); console.log(p); -console.log(p2) -setTimeout(function() { - console.log('La pile est vide'); - console.log(p2); +console.log(p2); +setTimeout(function () { + console.log("La pile est vide"); + console.log(p2); }); // Affichera : diff --git a/files/fr/web/javascript/reference/global_objects/promise/any/index.md b/files/fr/web/javascript/reference/global_objects/promise/any/index.md index 7429d3cab1d392..bac59c6fb108dd 100644 --- a/files/fr/web/javascript/reference/global_objects/promise/any/index.md +++ b/files/fr/web/javascript/reference/global_objects/promise/any/index.md @@ -82,7 +82,7 @@ const pErr = new Promise((resolve, reject) => { Promise.any([pErr]).catch((err) => { console.log(err); -}) +}); // résultat attendu : "AggregateError: No Promise in Promise.any was resolved" ``` @@ -92,26 +92,25 @@ Dans cet exemple, nous avons une fonction qui requête une image et retourne un ```js function fetchAndDecode(url) { - return fetch(url).then(réponse => { - if (!réponse.ok) - throw new Error(`Erreur HTTP ! état : ${response.status}`); - else - return réponse.blob(); - }) + return fetch(url).then((réponse) => { + if (!réponse.ok) throw new Error(`Erreur HTTP ! état : ${response.status}`); + else return réponse.blob(); + }); } -let café = fetchAndDecode('coffee.jpg'); -let thé = fetchAndDecode('tea.jpg'); - -Promise.any([café, thé]).then(valeur => { - let URLobjet = URL.createObjectURL(valeur); - let image = document.createElement('img'); - image.src = URLobjet; - document.body.appendChild(image); -}) -.catch(e => { - console.log(e.message); -}); +let café = fetchAndDecode("coffee.jpg"); +let thé = fetchAndDecode("tea.jpg"); + +Promise.any([café, thé]) + .then((valeur) => { + let URLobjet = URL.createObjectURL(valeur); + let image = document.createElement("img"); + image.src = URLobjet; + document.body.appendChild(image); + }) + .catch((e) => { + console.log(e.message); + }); ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/promise/catch/index.md b/files/fr/web/javascript/reference/global_objects/promise/catch/index.md index 0df1f5092183d1..53882118898b10 100644 --- a/files/fr/web/javascript/reference/global_objects/promise/catch/index.md +++ b/files/fr/web/javascript/reference/global_objects/promise/catch/index.md @@ -15,7 +15,7 @@ La méthode **`catch()`** renvoie un objet {{jsxref("Promise")}} et ne traite qu ```js p.catch(siRejetée); -p.catch(function(raison) { +p.catch(function (raison) { // rejet }); ``` @@ -44,48 +44,52 @@ La méthode `catch()` est utile pour gérer les cas d'erreur en cas de compositi ### Utilisation de la méthode `catch` ```js -var p1 = new Promise(function(resolve, reject) { +var p1 = new Promise(function (resolve, reject) { resolve("Succès"); }); -p1.then(function(value) { +p1.then(function (value) { console.log(value); // "Succès!" throw new Error("zut !"); -}).catch(function(e) { - console.error(e.message); // "zut !" -}).then(function(e) { - console.log('après le catch, la chaîne est restaurée'); -}); +}) + .catch(function (e) { + console.error(e.message); // "zut !" + }) + .then(function (e) { + console.log("après le catch, la chaîne est restaurée"); + }); // Le code qui suit est équivalent : -p1.then(function(value) { +p1.then(function (value) { console.log(value); // "Succès!" - return Promise.reject('zut !'); -}).catch(function(e) { - console.log(e); // "zut !" -}).then(function(e){ - console.log('après le catch, la chaîne est restaurée'); -}); + return Promise.reject("zut !"); +}) + .catch(function (e) { + console.log(e); // "zut !" + }) + .then(function (e) { + console.log("après le catch, la chaîne est restaurée"); + }); ``` ### Les promesses n'interceptent pas les exceptions levées de façon asynchrone ```js -var p1 = new Promise(function(resolve, reject) { - throw new Error('Oh oh!'); +var p1 = new Promise(function (resolve, reject) { + throw new Error("Oh oh!"); }); -p1.catch(function(e) { +p1.catch(function (e) { console.log(e.message); // "Oh oh!" }); -var p2 = new Promise(function(resolve, reject) { - setTimeout(function() { - throw new Error('Exception invisible !'); +var p2 = new Promise(function (resolve, reject) { + setTimeout(function () { + throw new Error("Exception invisible !"); }, 1000); }); -p2.catch(function(e) { +p2.catch(function (e) { console.log(e.message); // Cela n'est jamais appelé }); ``` @@ -95,25 +99,30 @@ p2.catch(function(e) { ```js // On surcharge Promise.prototype.then/catch // pour y ajouter des logs -(function(Promise){ - var originalThen = Promise.prototype.then; - var originalCatch = Promise.prototype.catch; - - Promise.prototype.then = function(){ - console.log('> > > > > > appel de .then sur %o avec les arguments: %o', this, arguments); - return originalThen.apply(this, arguments); - }; - Promise.prototype.catch = function(){ - console.log('> > > > > > appel de .catch sur %o avec les arguments: %o', this, arguments); - return originalCatch.apply(this, arguments); - }; - +(function (Promise) { + var originalThen = Promise.prototype.then; + var originalCatch = Promise.prototype.catch; + + Promise.prototype.then = function () { + console.log( + "> > > > > > appel de .then sur %o avec les arguments: %o", + this, + arguments, + ); + return originalThen.apply(this, arguments); + }; + Promise.prototype.catch = function () { + console.log( + "> > > > > > appel de .catch sur %o avec les arguments: %o", + this, + arguments, + ); + return originalCatch.apply(this, arguments); + }; })(this.Promise); - - // On appelle catch sur une promesse déjà résolue -Promise.resolve().catch(function XXX(){}); +Promise.resolve().catch(function XXX() {}); // Dans la console, on aura : // > > > > > > appel de .catch sur Promise{} avec les arguments: Arguments{1} [0: function XXX()] diff --git a/files/fr/web/javascript/reference/global_objects/promise/finally/index.md b/files/fr/web/javascript/reference/global_objects/promise/finally/index.md index 549fb63a4b653e..ec3bae34de0fc4 100644 --- a/files/fr/web/javascript/reference/global_objects/promise/finally/index.md +++ b/files/fr/web/javascript/reference/global_objects/promise/finally/index.md @@ -13,7 +13,7 @@ La méthode **`finally()`** renvoie un objet `Promise` et accepte en argument un ```js p.finally(onFinally); -p.finally(function() { +p.finally(function () { // appelée dans tous les // cas de terminaison }); @@ -47,19 +47,25 @@ La méthode `finally` est similaire à l'utilisation de la forme `.then(onFinall ```js let isLoading = true; -fetch(myRequest).then(function(response) { +fetch(myRequest) + .then(function (response) { var contentType = response.headers.get("content-type"); - if(contentType && contentType.includes("application/json")) { + if (contentType && contentType.includes("application/json")) { return response.json(); } throw new TypeError("Oups, ceci n'est pas du JSON !"); }) - .then(function(json) { /* traiter le JSON */ }) - .catch(function(error) { console.log(error); - /* La ligne précédent peut aussi déclencher une + .then(function (json) { + /* traiter le JSON */ + }) + .catch(function (error) { + console.log(error); + /* La ligne précédent peut aussi déclencher une erreur (si console vaut {} par exemple) */ - }) - .finally(function() { isLoading = false; }); + }) + .finally(function () { + isLoading = false; + }); ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/promise/index.md b/files/fr/web/javascript/reference/global_objects/promise/index.md index 63e349b1f79f98..f49c7553f05488 100644 --- a/files/fr/web/javascript/reference/global_objects/promise/index.md +++ b/files/fr/web/javascript/reference/global_objects/promise/index.md @@ -41,7 +41,7 @@ La méthode `.then()` prend deux arguments : le premier est une fonction de ```js const maPromesse = new Promise((resolve, reject) => { setTimeout(() => { - resolve('toto'); + resolve("toto"); }, 300); }); @@ -57,22 +57,34 @@ La gestion d'une promesse rompue dans chaque `.then()` a des conséquences plus ```js maPromesse -.then(gestionnaireSuccesA) -.then(gestionnaireSuccesB) -.then(gestionnaireSuccesC) -.catch(gestionnaireToutEchec); + .then(gestionnaireSuccesA) + .then(gestionnaireSuccesB) + .then(gestionnaireSuccesC) + .catch(gestionnaireToutEchec); ``` On peut utiliser les [expressions de fonctions fléchées](/fr/docs/Web/JavaScript/Reference/Functions/Arrow_functions) pour les fonctions de rappel. Un enchaînement avec cette forme pourra alors ressembler à : ```js promesse1 -.then(valeur => { return valeur + ' et truc'; }) -.then(valeur => { return valeur + ' et truc bla'; }) -.then(valeur => { return valeur + ' et blabla'; }) -.then(valeur => { return valeur + ' et blabla'; }) -.then(valeur => { console.log(valeur) }) -.catch(err => { console.log(err) }); + .then((valeur) => { + return valeur + " et truc"; + }) + .then((valeur) => { + return valeur + " et truc bla"; + }) + .then((valeur) => { + return valeur + " et blabla"; + }) + .then((valeur) => { + return valeur + " et blabla"; + }) + .then((valeur) => { + console.log(valeur); + }) + .catch((err) => { + console.log(err); + }); ``` La condition de terminaison d'une promesse détermine son état d'acquittement pour la prochaine promesse de la chaîne. Une promesse tenue indique un succès tandis qu'une promesse rompue indique un échec. La valeur de retour pour chaque promesse résolue de la chaîne est passée à la suivante avec `.then()`, alors que la raison de l'échec est passée au prochain gestionnaire d'échec dans la chaîne. @@ -100,11 +112,13 @@ const promesseC = promesseA.then(gestionSucces2, gestionEchec2); Il est possible d'affecter une action à une promesse qui est déjà acquittée. Dans ce cas, l'action (le cas échéant), sera réalisé à la première opportunité asynchrone, c'est-à-dire lorsque la pile d'appel aura été nettoyée et qu'un battement d'horloge se sera écoulé. On aura autrement dit un effet similaire à celui d'un `setTimeout(action,10)`. ```js -const promesseA = new Promise( (resolutionFunc,rejectionFunc) => { - resolutionFunc(777); +const promesseA = new Promise((resolutionFunc, rejectionFunc) => { + resolutionFunc(777); }); // Ici, "promesseA" est déjà acquittée. -promesseA.then( (val) => console.log("journalisation asynchrone / val vaut :",val) ); +promesseA.then((val) => + console.log("journalisation asynchrone / val vaut :", val), +); console.log("journalisation immédiate"); // On aura alors, dans la console, la suite de messages suivante : @@ -141,7 +155,7 @@ console.log("journalisation immédiate"); - [`Promise.prototype.finally()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally) - : Ajoute un gestionnaire à la promesse et renvoie une nouvelle promesse qui est résolue lors de la résolution de la première promesse. Le gestionnaire est appelé quand la première promesse est acquittée, qu'elle ait réussi ou non. ->**Note :** Voir [le guide sur les micro-tâches](/fr/docs/Web/API/HTML_DOM_API/Microtask_guide) pour en savoir plus sur la façon dont ces méthodes utilisent la queue et les services de micro-tâches. +> **Note :** Voir [le guide sur les micro-tâches](/fr/docs/Web/API/HTML_DOM_API/Microtask_guide) pour en savoir plus sur la façon dont ces méthodes utilisent la queue et les services de micro-tâches. ## Exemples @@ -154,15 +168,15 @@ let maPremierePromesse = new Promise((resolve, reject) => { // Dans cet exemple, on utilise setTimeout(...) pour simuler // du code asynchrone. En situation réelle, on utiliserait // plutôt XHR ou une API Web asynchrone. - setTimeout( function() { - resolve("Succès !") // Tout s'est bien passé ! - }, 250) -}) + setTimeout(function () { + resolve("Succès !"); // Tout s'est bien passé ! + }, 250); +}); maPremierePromesse.then((messageReussite) => { - // messageReussite correspond à ce qui a été passé à + // messageReussite correspond à ce qui a été passé à // la fonction resolve(...) ci-avant. - console.log("Youpi ! " + messageReussite) + console.log("Youpi ! " + messageReussite); }); ``` @@ -187,30 +201,29 @@ const SEUIL_A = 8; // Abaissez ce seuil à 0 pour forcer les erreurs function tetheredGetNumber(resolve, reject) { try { - setTimeout( - function() { - const randomInt = Date.now(); - const value = randomInt % 10; - try { - if(value >= SEUIL_A) { - throw new Error(`Trop grand : ${value}`); - } - } catch(msg) { - reject(`Erreur dans le callback ${msg}`); + setTimeout(function () { + const randomInt = Date.now(); + const value = randomInt % 10; + try { + if (value >= SEUIL_A) { + throw new Error(`Trop grand : ${value}`); } + } catch (msg) { + reject(`Erreur dans le callback ${msg}`); + } resolve(value); return; }, 500); // Vous pouvez expérimenter en décommentant le 'throw' // qui suit - } catch(err) { + } catch (err) { reject(`Erreur à l'initialisation : ${err}`); } return; } function determineParity(value) { - const isOdd = value % 2 ? true : false ; + const isOdd = value % 2 ? true : false; const parityInfo = { theNumber: value, isOdd: isOdd }; return parityInfo; } @@ -221,36 +234,34 @@ function troubleWithGetNumber(reason) { } function promiseGetWord(parityInfo) { - - const tetheredGetWord = function(resolve,reject) { + const tetheredGetWord = function (resolve, reject) { const theNumber = parityInfo.theNumber; const seuil_B = SEUIL_A - 1; - if(theNumber >= seuil_B) { + if (theNumber >= seuil_B) { reject(`Toujours trop grand : ${theNumber}`); } else { - parityInfo.wordEvenOdd = parityInfo.isOdd ? 'impair' : 'pair'; + parityInfo.wordEvenOdd = parityInfo.isOdd ? "impair" : "pair"; resolve(parityInfo); } return; - } + }; return new Promise(tetheredGetWord); } -(new Promise(tetheredGetNumber)) - .then(determineParity,troubleWithGetNumber) +new Promise(tetheredGetNumber) + .then(determineParity, troubleWithGetNumber) .then(promiseGetWord) .then((info) => { - console.log("On a eu : ",info.theNumber," , ", info.wordEvenOdd); + console.log("On a eu : ", info.theNumber, " , ", info.wordEvenOdd); return info; }) .catch((reason) => { - if(reason === -999) { + if (reason === -999) { console.error("Erreur précédemment gérée"); - } - else { + } else { console.error(`Problème avec promiseGetWord(): ${reason}`); } - }) + }) .finally((info) => console.log("C'est fini.")); ``` @@ -270,31 +281,40 @@ Le fait que la promesse soit tenue est simplement enregistré via un _callback_ #### JavaScript ```js -'use strict'; +"use strict"; let comptePromesse = 0; function testPromise() { let thisComptePromesse = ++comptePromesse; - let log = document.getElementById('log'); - log.insertAdjacentHTML('beforeend', thisComptePromesse + - ') Started (Début du code synchrone)
'); + let log = document.getElementById("log"); + log.insertAdjacentHTML( + "beforeend", + thisComptePromesse + + ") Started (Début du code synchrone)
", + ); // on crée une nouvelle promesse : let p1 = new Promise( // La fonction de résolution est appelée avec la capacité de // tenir ou de rompre la promesse - function(resolve, reject) { - log.insertAdjacentHTML('beforeend', thisComptePromesse + - ') Promise started (Début du code asynchrone)
'); + function (resolve, reject) { + log.insertAdjacentHTML( + "beforeend", + thisComptePromesse + + ") Promise started (Début du code asynchrone)
", + ); // Voici un exemple simple pour créer un code asynchrone window.setTimeout( - function() { + function () { // On tient la promesse ! resolve(thisComptePromesse); - }, Math.random() * 2000 + 1000); - }); + }, + Math.random() * 2000 + 1000, + ); + }, + ); // On définit ce qui se passe quand la promesse est tenue // et ce qu'on appelle (uniquement) dans ce cas @@ -302,25 +322,34 @@ function testPromise() { // quand la promesse est rompue. p1.then( // On affiche un message avec la valeur - function(val) { - log.insertAdjacentHTML('beforeend', val + - ') Promise fulfilled (Fin du code asynchrone)
'); - }).catch( - // Promesse rejetée - function() { - console.log("promesse rompue"); - }); - - log.insertAdjacentHTML('beforeend', thisComptePromesse + - ') Promise made (Fin du code synchrone)
'); + function (val) { + log.insertAdjacentHTML( + "beforeend", + val + + ") Promise fulfilled (Fin du code asynchrone)
", + ); + }, + ).catch( + // Promesse rejetée + function () { + console.log("promesse rompue"); + }, + ); + + log.insertAdjacentHTML( + "beforeend", + thisComptePromesse + + ") Promise made (Fin du code synchrone)
", + ); } if ("Promise" in window) { let btn = document.getElementById("btn"); btn.addEventListener("click", testPromise); - } else { - log = document.getElementById('log'); - log.innerHTML = "L'exemple live n'est pas disponible pour votre navigateur car celui-ci ne supporte pas l'interface Promise."; +} else { + log = document.getElementById("log"); + log.innerHTML = + "L'exemple live n'est pas disponible pour votre navigateur car celui-ci ne supporte pas l'interface Promise."; } ``` diff --git a/files/fr/web/javascript/reference/global_objects/promise/promise/index.md b/files/fr/web/javascript/reference/global_objects/promise/promise/index.md index c9fc86eb902a3a..adfdd59775a1b7 100644 --- a/files/fr/web/javascript/reference/global_objects/promise/promise/index.md +++ b/files/fr/web/javascript/reference/global_objects/promise/promise/index.md @@ -13,7 +13,7 @@ Le constructeur **`Promise()`** est principalement utilisé afin d'envelopper de ## Syntaxe ```js -new Promise(executeur) +new Promise(executeur); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/promise/race/index.md b/files/fr/web/javascript/reference/global_objects/promise/race/index.md index 701b7f55c3539d..e36c1762f4728d 100644 --- a/files/fr/web/javascript/reference/global_objects/promise/race/index.md +++ b/files/fr/web/javascript/reference/global_objects/promise/race/index.md @@ -51,9 +51,9 @@ console.log(p); // Avec setTimeout on peut exécuter du code // une fois que la pile est vide -setTimeout(function(){ - console.log('La pile est désormais vide'); - console.log(p); +setTimeout(function () { + console.log("La pile est désormais vide"); + console.log(p); }); // affichera, dans cet ordre : @@ -67,9 +67,9 @@ Un itérable vide renverra une promesse qui restera en attente : ```js var foreverPendingPromise = Promise.race([]); console.log(foreverPendingPromise); -setTimeout(function(){ - console.log('La pile est désormais vide'); - console.log(foreverPendingPromise); +setTimeout(function () { + console.log("La pile est désormais vide"); + console.log(foreverPendingPromise); }); // affichera, dans cet ordre : @@ -91,10 +91,10 @@ var p2 = Promise.race(arr2); console.log(p); console.log(p2); -setTimeout(function(){ - console.log('the stack is now empty'); - console.log(p); - console.log(p2); +setTimeout(function () { + console.log("the stack is now empty"); + console.log(p); + console.log(p2); }); // affichera dans l'ordre : @@ -108,45 +108,51 @@ setTimeout(function(){ ### Utilisation de `Promise.race` – exemples avec `setTimeout` ```js -var p1 = new Promise(function(resolve, reject) { - setTimeout(resolve, 500, "un"); +var p1 = new Promise(function (resolve, reject) { + setTimeout(resolve, 500, "un"); }); -var p2 = new Promise(function(resolve, reject) { - setTimeout(resolve, 100, "deux"); +var p2 = new Promise(function (resolve, reject) { + setTimeout(resolve, 100, "deux"); }); -Promise.race([p1, p2]).then(function(value) { +Promise.race([p1, p2]).then(function (value) { console.log(value); // "deux" // Les deux promesses sont résolues mais p2 est plus rapide }); -var p3 = new Promise(function(resolve, reject) { - setTimeout(resolve, 100, "trois"); +var p3 = new Promise(function (resolve, reject) { + setTimeout(resolve, 100, "trois"); }); -var p4 = new Promise(function(resolve, reject) { - setTimeout(reject, 500, "quatre"); +var p4 = new Promise(function (resolve, reject) { + setTimeout(reject, 500, "quatre"); }); -Promise.race([p3, p4]).then(function(value) { - console.log(value); // "trois" - // p3 est plus rapide et entraîne la résolution de la promesse de compétition -}, function(reason) { - // N'est pas appelée +Promise.race([p3, p4]).then( + function (value) { + console.log(value); // "trois" + // p3 est plus rapide et entraîne la résolution de la promesse de compétition + }, + function (reason) { + // N'est pas appelée + }, +); + +var p5 = new Promise(function (resolve, reject) { + setTimeout(resolve, 500, "cinq"); }); - -var p5 = new Promise(function(resolve, reject) { - setTimeout(resolve, 500, "cinq"); -}); -var p6 = new Promise(function(resolve, reject) { - setTimeout(reject, 100, "six"); +var p6 = new Promise(function (resolve, reject) { + setTimeout(reject, 100, "six"); }); -Promise.race([p5, p6]).then(function(value) { - // N'est pas appelée -}, function(reason) { - console.log(reason); // "six" - // p6 est plus rapide et rejète la promesse de compétition -}); +Promise.race([p5, p6]).then( + function (value) { + // N'est pas appelée + }, + function (reason) { + console.log(reason); // "six" + // p6 est plus rapide et rejète la promesse de compétition + }, +); ``` > **Note :** voir la documentation sur [`setTimeout`.](/fr/docs/Web/API/WindowTimers/setTimeout) diff --git a/files/fr/web/javascript/reference/global_objects/promise/reject/index.md b/files/fr/web/javascript/reference/global_objects/promise/reject/index.md index 63c5d3f4678345..29c6206b5852dd 100644 --- a/files/fr/web/javascript/reference/global_objects/promise/reject/index.md +++ b/files/fr/web/javascript/reference/global_objects/promise/reject/index.md @@ -32,11 +32,14 @@ La fonction statique `Promise.reject` renvoie une `Promise` qui est rejetée. Po ## Exemples ```js -Promise.reject(new Error("échec")).then(function() { - // n'est pas appelée -}, function(erreur) { - console.log(erreur); // Analyse de la pile d'appels -}); +Promise.reject(new Error("échec")).then( + function () { + // n'est pas appelée + }, + function (erreur) { + console.log(erreur); // Analyse de la pile d'appels + }, +); ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/promise/resolve/index.md b/files/fr/web/javascript/reference/global_objects/promise/resolve/index.md index 96fd24f76a10c8..14ef3ff8ea30ca 100644 --- a/files/fr/web/javascript/reference/global_objects/promise/resolve/index.md +++ b/files/fr/web/javascript/reference/global_objects/promise/resolve/index.md @@ -38,18 +38,21 @@ La fonction statique `Promise.resolve` renvoie un objet `Promise` qui est résol ### Utilisation de la méthode statique `Promise.resolve` ```js -Promise.resolve("Succès").then(function(valeur) { - console.log(valeur); // "Succès" -}, function(valeur) { - // n'est pas appelée -}); +Promise.resolve("Succès").then( + function (valeur) { + console.log(valeur); // "Succès" + }, + function (valeur) { + // n'est pas appelée + }, +); ``` ### Résoudre un tableau ```js -var p = Promise.resolve([1,2,3]); -p.then(function(v) { +var p = Promise.resolve([1, 2, 3]); +p.then(function (v) { console.log(v[0]); // 1 }); ``` @@ -59,7 +62,7 @@ p.then(function(v) { ```js var original = Promise.resolve(33); var cast = Promise.resolve(original); -cast.then(function(value) { +cast.then(function (value) { console.log("value: " + value); }); console.log("original === cast ? " + (original === cast)); @@ -76,43 +79,58 @@ L'ordre des traces dans la console est dû au fait que les gestionnaires `then() ```js // Résoudre un objet avec then var p1 = Promise.resolve({ - then: function(onFulfill, onReject) { onFulfill("tenue !"); } + then: function (onFulfill, onReject) { + onFulfill("tenue !"); + }, }); -console.log(p1 instanceof Promise) // true, l'objet est transformée en une Promise +console.log(p1 instanceof Promise); // true, l'objet est transformée en une Promise -p1.then(function(v) { +p1.then( + function (v) { console.log(v); // "tenue !" - }, function(e) { + }, + function (e) { // n'est pas appelée -}); + }, +); // L'objet avec then renvoie une erreur avant le callback // La promesse n'est pas tenue -var thenable = { then: function(resolve) { - throw new TypeError("Renvoi d'erreur"); - resolve("Résolution "); -}}; +var thenable = { + then: function (resolve) { + throw new TypeError("Renvoi d'erreur"); + resolve("Résolution "); + }, +}; var p2 = Promise.resolve(thenable); -p2.then(function(v) { - // n'est pas appelée -}, function(e) { - console.log(e); // TypeError : Renvoi d'erreur -}); +p2.then( + function (v) { + // n'est pas appelée + }, + function (e) { + console.log(e); // TypeError : Renvoi d'erreur + }, +); // L'objet avec then renvoie une erreur après le callback // La promesse est tenue -var thenable = { then: function(resolve) { - resolve("Résolue"); - throw new TypeError("Erreur"); -}}; +var thenable = { + then: function (resolve) { + resolve("Résolue"); + throw new TypeError("Erreur"); + }, +}; var p3 = Promise.resolve(thenable); -p3.then(function(v) { - console.log(v); // "Résolue" -}, function(e) { - // n'est pas appelée -}); +p3.then( + function (v) { + console.log(v); // "Résolue" + }, + function (e) { + // n'est pas appelée + }, +); ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/promise/then/index.md b/files/fr/web/javascript/reference/global_objects/promise/then/index.md index 8b0da28cc956f6..1589f4dbaf0c82 100644 --- a/files/fr/web/javascript/reference/global_objects/promise/then/index.md +++ b/files/fr/web/javascript/reference/global_objects/promise/then/index.md @@ -24,12 +24,12 @@ then(siTenue, siRejetée) - : Une fonction à exécuter de façon asynchrone quand la promesse est tenue. La valeur de retour de cette fonction devient la valeur de réussite de la promesse renvoyée par `then()`. Cette fonction de rappel est appelée avec les arguments suivants : - `valeur` - : La valeur avec laquelle la promesse a été tenue. - Si cet argument n'est pas une fonction, il est remplacé en interne par la fonction _identité_ (`(x) => x`) qui passe la valeur de réussite. + Si cet argument n'est pas une fonction, il est remplacé en interne par la fonction _identité_ (`(x) => x`) qui passe la valeur de réussite. - `siRejetée` {{optional_inline}} - : Une fonction à exécuter de façon asynchrone quand la promesse est rompue. Sa valeur de retour devient la valeur de réussite de la promesse renvoyée par `catch()`. Cette fonction de rappel est appelée avec les arguments suivants : - `raison` - : La valeur avec laquelle la promesse a été rompue. - Si cet argument n'est pas une fonction, il est remplacé en interne par une fonction de _rejet_ (`(x) => { throw x; }`) qui renvoie la raison d'échec qui a été reçue en amont. + Si cet argument n'est pas une fonction, il est remplacé en interne par une fonction de _rejet_ (`(x) => { throw x; }`) qui renvoie la raison d'échec qui a été reçue en amont. ### Valeur de retour @@ -117,7 +117,7 @@ Promise.resolve("toto") // avant le traitement de la chaîne dans le bloc then() précédent. .then((chaine) => { console.log( - "Dernier then(). Oups, on n'a pas pris la peine d'instancier et de renvoyer une promesse dans l'appel then() précédent. L'ordre de la séquence pourrait être surprenant." + "Dernier then(). Oups, on n'a pas pris la peine d'instancier et de renvoyer une promesse dans l'appel then() précédent. L'ordre de la séquence pourrait être surprenant.", ); // On notera qu'ici `chaine` n'a pas le suffixe 'machin'. En effet, nous avons @@ -182,7 +182,9 @@ Promise.resolve() console.error(`Fonction siRejetée() appelée : ${erreur.message}`); }) .then(() => { - console.log("Je suis toujours appelée, même si la promesse du then() précédent échoue."); + console.log( + "Je suis toujours appelée, même si la promesse du then() précédent échoue.", + ); }); ``` @@ -256,7 +258,7 @@ function obtenirDonnees() { const j = response.json(); // faire quelque chose avec j - // La valeur de réussite fournie lorsqu'on + // La valeur de réussite fournie lorsqu'on // appelle obtenirDonnees().then() return j; }); @@ -268,11 +270,11 @@ function obtenirDonnees() { Dans l'exemple qui suit, on illustre le caractère asynchrone de la méthode `then()`. ```js -// Prenons une promesse résolue comme 'promResolue', l'appel à +// Prenons une promesse résolue comme 'promResolue', l'appel à // 'promResolue.then(…)' renvoie immédiatement une nouvelle promesse, // mais la fonction de rappel '(value) => {…}' sera appelée de // façon asynchrone, comme on peut le voir dans la console. -// La nouvelle promesse est affectée à 'promSuivante', cette +// La nouvelle promesse est affectée à 'promSuivante', cette // dernière est résolue avec la valeur renvoyée par le gestionnaire. const promResolue = Promise.resolve(33); console.log(promResolue); @@ -280,9 +282,7 @@ console.log(promResolue); const promSuivante = promResolue.then((valeur) => { console.log( `Ceci est appelé après la fin de la pile principale. ` + - `La valeur reçue est : ${valeur}, la valeur renvoyée est : ${ - valeur + 1 - }`, + `La valeur reçue est : ${valeur}, la valeur renvoyée est : ${valeur + 1}`, ); return valeur + 1; }); diff --git a/files/fr/web/javascript/reference/global_objects/proxy/index.md b/files/fr/web/javascript/reference/global_objects/proxy/index.md index 3224019fa6f4cf..6f00c7e86bf0bd 100644 --- a/files/fr/web/javascript/reference/global_objects/proxy/index.md +++ b/files/fr/web/javascript/reference/global_objects/proxy/index.md @@ -24,7 +24,7 @@ Dans l'exemple qui suit, on a une cible simple avec deux propriétés et un gest ```js const cible = { message1: "coucou", - message2: "tout le monde" + message2: "tout le monde", }; const gestionnaire1 = {}; @@ -44,13 +44,13 @@ Pour adapter le proxy, on définit des fonctions sur le gestionnaire : ```js const cible = { message1: "coucou", - message2: "tout le monde" + message2: "tout le monde", }; const gestionnaire2 = { get(cible, prop, recepteur) { return "le monde"; - } + }, }; const proxy2 = new Proxy(cible, gestionnaire2); @@ -70,7 +70,7 @@ Avec [`Reflect`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Reflect), on p ```js const cible = { message1: "coucou", - message2: "tout le monde" + message2: "tout le monde", }; const gestionnaire3 = { @@ -107,10 +107,8 @@ Dans ce court exemple, on renvoie le nombre `37` comme valeur par défaut lorsqu ```js const handler = { get(obj, prop) { - return prop in obj ? - obj[prop] : - 37; - } + return prop in obj ? obj[prop] : 37; + }, }; const p = new Proxy({}, handler); @@ -120,7 +118,7 @@ p.b = undefined; console.log(p.a, p.b); // 1, undefined -console.log('c' in p, p.c); +console.log("c" in p, p.c); // false, 37 ``` @@ -135,7 +133,6 @@ const p = new Proxy(target, {}); p.a = 37; // L'opération est transmise à la cible par le proxy - console.log(target.a); // 37 // L'opération a bien été transmise @@ -149,13 +146,13 @@ En utilisant un `Proxy`, on peut simplement valider les valeurs passées à un o ```js let validateur = { - set: function(obj, prop, valeur) { - if (prop === 'age') { + set: function (obj, prop, valeur) { + if (prop === "age") { if (!Number.isInteger(valeur)) { throw new TypeError("Cet a n'est pas un entier."); } if (valeur > 200) { - throw new RangeError('Cet âge semble invalide.'); + throw new RangeError("Cet âge semble invalide."); } } @@ -164,15 +161,15 @@ let validateur = { // On indique le succès de l'opération return true; - } + }, }; const personne = new Proxy({}, validateur); personne.age = 100; console.log(personne.age); // 100 -personne.age = 'jeune'; // lève une exception -personne.age = 300; // lève une exception +personne.age = "jeune"; // lève une exception +personne.age = 300; // lève une exception ``` ### Étendre un constructeur @@ -180,33 +177,34 @@ personne.age = 300; // lève une exception En utilisant une fonction proxy, on peut étendre un constructeur avec un nouveau constructeur. Dans cet exemple, on utilise les gestionnaires correspondants à [`construct()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/construct) et [`apply()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/apply). ```js -function etendre(sup,base) { +function etendre(sup, base) { var descripteur = Object.getOwnPropertyDescriptor( - base.prototype, "constructor" + base.prototype, + "constructor", ); base.prototype = Object.create(sup.prototype); var gestionnaire = { - construct: function(cible, args) { + construct: function (cible, args) { var obj = Object.create(base.prototype); - this.apply(cible,obj,args); + this.apply(cible, obj, args); return obj; }, - apply: function(cible, that, args) { - sup.apply(that,args); - base.apply(that,args); - } + apply: function (cible, that, args) { + sup.apply(that, args); + base.apply(that, args); + }, }; - var proxy = new Proxy(base,gestionnaire); + var proxy = new Proxy(base, gestionnaire); descripteur.value = proxy; Object.defineProperty(base.prototype, "constructor", descripteur); return proxy; } -var Personne = function(nom){ +var Personne = function (nom) { this.nom = nom; }; -var Garcon = etendre(Personne, function(nom, âge) { +var Garcon = etendre(Personne, function (nom, âge) { this.âge = âge; }); @@ -214,8 +212,8 @@ Garcon.prototype.genre = "M"; var Pierre = new Garcon("Pierre", 13); console.log(Pierre.genre); // "M" -console.log(Pierre.nom); // "Pierre" -console.log(Pierre.âge); // 13 +console.log(Pierre.nom); // "Pierre" +console.log(Pierre.âge); // 13 ``` ### Manipuler les nœuds DOM @@ -227,47 +225,49 @@ On crée un objet `vue` qui est un proxy pour l'objet avec une `selected`. Le ge Lorsqu'on affecte un élément HTML à `vue.selected`, l'attribut `'aria-selected'` de l'élément est placé à `true`. Si on affecte ensuite un autre élément à `vue.selected`, ce nouvel élément aura l'attribut `'aria-selected'` défini à `true` et l'élément précédent verra son attribut `'aria-selected'` automatiquement défini à `false`. ```js -let vue = new Proxy({ - selected: null -}, -{ - set(obj, prop, nouvelleValeur) { - let ancienneValeur = obj[prop]; - - if (prop === 'selected') { - if (ancienneValeur) { - ancienneValeur.setAttribute('aria-selected', 'false'); - } - if (nouvelleValeur) { - nouvelleValeur.setAttribute('aria-selected', 'true'); +let vue = new Proxy( + { + selected: null, + }, + { + set(obj, prop, nouvelleValeur) { + let ancienneValeur = obj[prop]; + + if (prop === "selected") { + if (ancienneValeur) { + ancienneValeur.setAttribute("aria-selected", "false"); + } + if (nouvelleValeur) { + nouvelleValeur.setAttribute("aria-selected", "true"); + } } - } - // Le comportement par défaut : enregistrer la valeur - obj[prop] = nouvelleValeur; + // Le comportement par défaut : enregistrer la valeur + obj[prop] = nouvelleValeur; - // On indique le succès de l'opération - return true; - } -}); + // On indique le succès de l'opération + return true; + }, + }, +); -const element1 = document.getElementById('elem-1'); -const element2 = document.getElementById('elem-2'); +const element1 = document.getElementById("elem-1"); +const element2 = document.getElementById("elem-2"); // on sélectionne element1 vue.selected = element1; -console.log(`element1 : ${element1.getAttribute('aria-selected')}`); +console.log(`element1 : ${element1.getAttribute("aria-selected")}`); // element1 : true // on sélectionne element2 et cela entraîne // la déselection automatique de element1 vue.selected = element2; -console.log(`element1 : ${element1.getAttribute('aria-selected')}`); +console.log(`element1 : ${element1.getAttribute("aria-selected")}`); // element1 : false -console.log(`element2 : ${element2.getAttribute('aria-selected')}`); +console.log(`element2 : ${element2.getAttribute("aria-selected")}`); // element2 : true ``` @@ -276,48 +276,50 @@ console.log(`element2 : ${element2.getAttribute('aria-selected')}`); Dans l'exemple qui suit, le proxy `produits` évalue la valeur passée et la convertit en tableau si besoin. L'objet prend également en charge la propriété supplémentaire `dernierNavigateur` à la fois comme accesseur et mutateur. ```js -let produits = new Proxy({ - navigateurs: ['Internet Explorer', 'Netscape'] -}, -{ - get(obj, prop) { - // Une propriété supplémentaire - if (prop === 'dernierNavigateur') { - return obj.navigateurs[obj.navigateurs.length - 1]; - } - - // Le comportement par défaut : renvoyer la valeur - return obj[prop]; +let produits = new Proxy( + { + navigateurs: ["Internet Explorer", "Netscape"], }, - set(obj, prop, valeur) { - // Une propriété supplémentaire - if (prop === 'dernierNavigateur') { - obj.navigateurs.push(valeur); - return true; - } + { + get(obj, prop) { + // Une propriété supplémentaire + if (prop === "dernierNavigateur") { + return obj.navigateurs[obj.navigateurs.length - 1]; + } - // on convertit la valeur si ce n'est pas un tableau - if (typeof valeur === 'string') { - valeur = [valeur]; - } + // Le comportement par défaut : renvoyer la valeur + return obj[prop]; + }, + set(obj, prop, valeur) { + // Une propriété supplémentaire + if (prop === "dernierNavigateur") { + obj.navigateurs.push(valeur); + return true; + } - // Le comportement par défaut : enregistrer la valeur - obj[prop] = valeur; + // on convertit la valeur si ce n'est pas un tableau + if (typeof valeur === "string") { + valeur = [valeur]; + } - // On indique le succès de l'opération - return true; - } -}); + // Le comportement par défaut : enregistrer la valeur + obj[prop] = valeur; + + // On indique le succès de l'opération + return true; + }, + }, +); console.log(produits.navigateurs); // ['Internet Explorer', 'Netscape'] -produits.navigateurs = 'Firefox'; +produits.navigateurs = "Firefox"; // on passe une chaîne console.log(produits.navigateurs); // ['Firefox'] <- pas de problème, elle est convertie en tableau -produits.dernierNavigateur = 'Chrome'; +produits.dernierNavigateur = "Chrome"; console.log(produits.navigateurs); // ['Firefox', 'Chrome'] @@ -331,64 +333,67 @@ console.log(produits.dernierNavigateur); Dans cet exemple, ce proxy étend le tableau avec des fonctionnalités supplémentaires. Ici, on définit des propriétés sans utiliser [`Object.defineProperties()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties). Cet exemple pourrait être adapté pour trouver la ligne d'un tableau à partir d'une de ces cellules (la cible serait alors [`table.rows`](/fr/docs/Web/API/HTMLTableElement.rows)). ```js -let produits = new Proxy([ - { nom: 'Firefox', type: 'navigateur' }, - { nom: 'SeaMonkey', type: 'navigateur' }, - { nom: 'Thunderbird', type: 'client mail' } -], -{ - get(obj, prop) { - // Le comportement par défaut : on renvoie la valeur - // prop est généralement un entier - if (prop in obj) { - return obj[prop]; - } - - // On obtient le nombre de produits - // un alias pour products.length - if (prop === 'nombre') { - return obj.length; - } - - let resultat, types = {}; +let produits = new Proxy( + [ + { nom: "Firefox", type: "navigateur" }, + { nom: "SeaMonkey", type: "navigateur" }, + { nom: "Thunderbird", type: "client mail" }, + ], + { + get(obj, prop) { + // Le comportement par défaut : on renvoie la valeur + // prop est généralement un entier + if (prop in obj) { + return obj[prop]; + } - for (let produit of obj) { - if (produit.nom === prop) { - resultat = produit; + // On obtient le nombre de produits + // un alias pour products.length + if (prop === "nombre") { + return obj.length; } - if (types[produit.type]) { - types[produit.type].push(produit); - } else { - types[produit.type] = [produit]; + + let resultat, + types = {}; + + for (let produit of obj) { + if (produit.nom === prop) { + resultat = produit; + } + if (types[produit.type]) { + types[produit.type].push(produit); + } else { + types[produit.type] = [produit]; + } } - } - // Obtenir un produit grâce à un nom - if (resultat) { - return resultat; - } + // Obtenir un produit grâce à un nom + if (resultat) { + return resultat; + } - // Obtenir un produit par type - if (prop in types) { - return types[prop]; - } + // Obtenir un produit par type + if (prop in types) { + return types[prop]; + } - // Obtenir les types de produits - if (prop === 'types') { - return Object.keys(types); - } + // Obtenir les types de produits + if (prop === "types") { + return Object.keys(types); + } - return undefined; - } -}); + return undefined; + }, + }, +); console.log(produits[0]); // { nom: 'Firefox', type: 'navigateur' } -console.log(produits['Firefox']); +console.log(produits["Firefox"]); // { nom: 'Firefox', type: 'navigateur' } -console.log(produits['Chrome']); +console.log(produits["Chrome"]); // undefined console.log(produits.navigateur); @@ -412,15 +417,19 @@ Pour illustrer l'ensemble des trappes, on tente de « proxifier » un */ var docCookies = new Proxy(docCookies, { - get (oTarget, sKey) { + get(oTarget, sKey) { return oTarget[sKey] || oTarget.getItem(sKey) || undefined; }, set: function (oTarget, sKey, vValue) { - if (sKey in oTarget) { return false; } + if (sKey in oTarget) { + return false; + } return oTarget.setItem(sKey, vValue); }, deleteProperty: function (oTarget, sKey) { - if (!sKey in oTarget) { return false; } + if (!sKey in oTarget) { + return false; + } return oTarget.removeItem(sKey); }, ownKeys: function (oTarget, sKey) { @@ -430,26 +439,30 @@ var docCookies = new Proxy(docCookies, { return sKey in oTarget || oTarget.hasItem(sKey); }, defineProperty: function (oTarget, sKey, oDesc) { - if (oDesc && 'value' in oDesc) { oTarget.setItem(sKey, oDesc.value); } + if (oDesc && "value" in oDesc) { + oTarget.setItem(sKey, oDesc.value); + } return oTarget; }, getOwnPropertyDescriptor: function (oTarget, sKey) { var vValue = oTarget.getItem(sKey); - return vValue ? { - value: vValue, - writable: true, - enumerable: true, - configurable: false - } : undefined; + return vValue + ? { + value: vValue, + writable: true, + enumerable: true, + configurable: false, + } + : undefined; }, }); /* Test */ -console.log(docCookies.monCookie1 = 'Première valeur'); -console.log(docCookies.getItem('monCookie1')); +console.log((docCookies.monCookie1 = "Première valeur")); +console.log(docCookies.getItem("monCookie1")); -docCookies.setItem('monCookie1', 'Valeur modifiée'); +docCookies.setItem("monCookie1", "Valeur modifiée"); console.log(docCookies.monCookie1); ``` diff --git a/files/fr/web/javascript/reference/global_objects/proxy/proxy/apply/index.md b/files/fr/web/javascript/reference/global_objects/proxy/proxy/apply/index.md index ef9cc6854b37f6..fa2cea82a49c9e 100644 --- a/files/fr/web/javascript/reference/global_objects/proxy/proxy/apply/index.md +++ b/files/fr/web/javascript/reference/global_objects/proxy/proxy/apply/index.md @@ -14,8 +14,7 @@ La méthode **`handler.apply()`** représente une trappe pour un appel de foncti ```js var p = new Proxy(cible, { - apply: function(cible, thisArg, listeArguments) { - } + apply: function (cible, thisArg, listeArguments) {}, }); ``` @@ -57,15 +56,15 @@ Si les invariants suivants ne sont pas respectés, le proxy lèvera une exceptio Dans l'exemple ci-dessous, on piège un appel de fonction. ```js -var p = new Proxy(function() {}, { - apply: function(target, thisArg, argumentsList) { +var p = new Proxy(function () {}, { + apply: function (target, thisArg, argumentsList) { console.log("called: " + argumentsList.join(", ")); return argumentsList[0] + argumentsList[1] + argumentsList[2]; - } + }, }); console.log(p(1, 2, 3)); // "called: 1, 2, 3" - // 6 +// 6 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/proxy/proxy/construct/index.md b/files/fr/web/javascript/reference/global_objects/proxy/proxy/construct/index.md index 3d2c10f79d757f..77c24379e351f5 100644 --- a/files/fr/web/javascript/reference/global_objects/proxy/proxy/construct/index.md +++ b/files/fr/web/javascript/reference/global_objects/proxy/proxy/construct/index.md @@ -14,8 +14,7 @@ La méthode **`handler.construct()`** est une trappe pour l'opérateur {{jsxref( ```js var p = new Proxy(cible, { - construct: function(cible, listeArguments, newTarget) { - } + construct: function (cible, listeArguments, newTarget) {}, }); ``` @@ -56,24 +55,24 @@ Si les invariants suivants ne sont pas respectés, le proxy renverra une excepti Dans l'exemple qui suit, on piège l'opérateur {{jsxref("Opérateurs/L_opérateur_new", "new")}}. ```js -var p = new Proxy(function() {}, { - construct: function(target, argumentsList) { +var p = new Proxy(function () {}, { + construct: function (target, argumentsList) { console.log("called: " + argumentsList.join(", ")); return { value: argumentsList[0] * 10 }; - } + }, }); console.log(new p(1).value); // "appel sur : 1" - // 10 +// 10 ``` Dans cette version, on ne respecte pas la contrainte d'invariance : ```js -var p = new Proxy(function() {}, { - construct: function(target, argumentsList) { +var p = new Proxy(function () {}, { + construct: function (target, argumentsList) { return 1; - } + }, }); new p(); // Une exception TypeError est levée @@ -82,11 +81,14 @@ new p(); // Une exception TypeError est levée Dans le code qui suit, le proxy n'est pas correctement initialisé. La cible du proxy doit être un constructeur valide qui puisse être utilisé avec `new`. ```js -var p = new Proxy({}, { - construct: function(target, argumentsList, newTarget){ - return {}; - } -}); +var p = new Proxy( + {}, + { + construct: function (target, argumentsList, newTarget) { + return {}; + }, + }, +); new p(); // TypeError: p is not a constructor ``` diff --git a/files/fr/web/javascript/reference/global_objects/proxy/proxy/defineproperty/index.md b/files/fr/web/javascript/reference/global_objects/proxy/proxy/defineproperty/index.md index 33bc685a2ecf60..736d6e4530790b 100644 --- a/files/fr/web/javascript/reference/global_objects/proxy/proxy/defineproperty/index.md +++ b/files/fr/web/javascript/reference/global_objects/proxy/proxy/defineproperty/index.md @@ -14,8 +14,7 @@ La méthode **`handler.defineProperty()`** est une trappe pour {{jsxref("Object. ```js var p = new Proxy(cible, { - defineProperty: function(cible, propriété, descripteur) { - } + defineProperty: function (cible, propriété, descripteur) {}, }); ``` @@ -60,11 +59,14 @@ Si les contraintes d'invariances suivantes ne sont pas respectées, le proxy ren Dans le code suivant, on piège l'appel à {{jsxref("Object.defineProperty()")}}. ```js -var p = new Proxy({}, { - defineProperty: function(target, prop, descriptor) { - console.log("appelé avec : " + prop); - } -}); +var p = new Proxy( + {}, + { + defineProperty: function (target, prop, descriptor) { + console.log("appelé avec : " + prop); + }, + }, +); var desc = { configurable: true, enumerable: true, value: 10 }; Object.defineProperty(p, "a", desc); // "appelé avec : a" diff --git a/files/fr/web/javascript/reference/global_objects/proxy/proxy/deleteproperty/index.md b/files/fr/web/javascript/reference/global_objects/proxy/proxy/deleteproperty/index.md index 4ae2470f94842c..61096b2e3aede0 100644 --- a/files/fr/web/javascript/reference/global_objects/proxy/proxy/deleteproperty/index.md +++ b/files/fr/web/javascript/reference/global_objects/proxy/proxy/deleteproperty/index.md @@ -14,8 +14,7 @@ La méthode **`handler.deleteProperty()`** est une trappe pour l'opérateur {{js ```js var p = new Proxy(cible, { - deleteProperty: function(cible, propriété) { - } + deleteProperty: function (cible, propriété) {}, }); ``` @@ -54,12 +53,15 @@ Si les invarians suivants ne sont pas respectés, le proxy renverra une exceptio Dans l'exemple qui suit, on intercepte les opérations de {{jsxref("Opérateurs/L_opérateur_delete", "delete")}}. ```js -var p = new Proxy({}, { - deleteProperty: function(cible, prop) { - console.log("appelée sur : " + prop); - return true; - } -}); +var p = new Proxy( + {}, + { + deleteProperty: function (cible, prop) { + console.log("appelée sur : " + prop); + return true; + }, + }, +); delete p.a; // "appelée sur : a" ``` diff --git a/files/fr/web/javascript/reference/global_objects/proxy/proxy/get/index.md b/files/fr/web/javascript/reference/global_objects/proxy/proxy/get/index.md index 17415b2f141554..170d73cc1c442c 100644 --- a/files/fr/web/javascript/reference/global_objects/proxy/proxy/get/index.md +++ b/files/fr/web/javascript/reference/global_objects/proxy/proxy/get/index.md @@ -14,8 +14,7 @@ La méthode **`handler.get()`** est une trappe pour intercepter l'accès à la v ```js var p = new Proxy(cible, { - get: function(cible, propriété, récepteur) { - } + get: function (cible, propriété, récepteur) {}, }); ``` @@ -58,15 +57,18 @@ Si les invariants suivants ne sont pas respectés, le proxy renverra une excepti Dans l'exemple suivant, on intercepte les accès aux propriétés : ```js -var p = new Proxy({}, { - get: function(cible, propriété, récepteur) { - console.log("appelée : " + propriété); - return 10; - } -}); +var p = new Proxy( + {}, + { + get: function (cible, propriété, récepteur) { + console.log("appelée : " + propriété); + return 10; + }, + }, +); console.log(p.a); // "appelée : a" - // 10 +// 10 ``` Le code suivant ne respecte pas l'invariant : @@ -77,13 +79,13 @@ Object.defineProperty(obj, "a", { configurable: false, enumerable: false, value: 10, - writable: false + writable: false, }); var p = new Proxy(obj, { - get: function(cible, propriété) { + get: function (cible, propriété) { return 20; - } + }, }); p.a; // exception TypeError levée diff --git a/files/fr/web/javascript/reference/global_objects/proxy/proxy/getownpropertydescriptor/index.md b/files/fr/web/javascript/reference/global_objects/proxy/proxy/getownpropertydescriptor/index.md index 209982c7004f16..7e5eaaaf52aa19 100644 --- a/files/fr/web/javascript/reference/global_objects/proxy/proxy/getownpropertydescriptor/index.md +++ b/files/fr/web/javascript/reference/global_objects/proxy/proxy/getownpropertydescriptor/index.md @@ -14,8 +14,7 @@ La méthode **`handler.getOwnPropertyDescriptor()`** est une trappe pour interce ```js var p = new Proxy(cible, { - getOwnPropertyDescriptor: function(cible, prop) { - } + getOwnPropertyDescriptor: function (cible, prop) {}, }); ``` @@ -59,15 +58,18 @@ Si les invariants suivants ne sont pas respectés, le proxy lèvera une exceptio Dans l'exemple qui suit, on intercepte {{jsxref("Object.getOwnPropertyDescriptor()")}}. ```js -var p = new Proxy({ a: 20 }, { - getOwnPropertyDescriptor: function(cible, prop) { - console.log("appelée : " + prop); - return { configurable: true, enumerable: true, value: 10 }; - } -}); +var p = new Proxy( + { a: 20 }, + { + getOwnPropertyDescriptor: function (cible, prop) { + console.log("appelée : " + prop); + return { configurable: true, enumerable: true, value: 10 }; + }, + }, +); console.log(Object.getOwnPropertyDescriptor(p, "a").value); // "appelée : a" - // 10 +// 10 ``` L'exemple suivant ne respecte pas un invariant : @@ -76,9 +78,9 @@ L'exemple suivant ne respecte pas un invariant : var obj = { a: 10 }; Object.preventExtensions(obj); var p = new Proxy(obj, { - getOwnPropertyDescriptor: function(cible, prop) { + getOwnPropertyDescriptor: function (cible, prop) { return undefined; - } + }, }); Object.getOwnPropertyDescriptor(p, "a"); // Une exception TypeError est renvoyée diff --git a/files/fr/web/javascript/reference/global_objects/proxy/proxy/getprototypeof/index.md b/files/fr/web/javascript/reference/global_objects/proxy/proxy/getprototypeof/index.md index 43096f60c8c097..232e32bbc1c004 100644 --- a/files/fr/web/javascript/reference/global_objects/proxy/proxy/getprototypeof/index.md +++ b/files/fr/web/javascript/reference/global_objects/proxy/proxy/getprototypeof/index.md @@ -58,15 +58,15 @@ Si les invariants suivant ne sont pas respectés, le proxy renverra une exceptio var obj = {}; var proto = {}; var gestionnaire = { - getPrototypeOf(cible) { - console.log(cible === obj); // true - console.log(this === gestionnaire); // true - return proto; - } + getPrototypeOf(cible) { + console.log(cible === obj); // true + console.log(this === gestionnaire); // true + return proto; + }, }; var p = new Proxy(obj, gestionnaire); -console.log(Object.getPrototypeOf(p) === proto); // true +console.log(Object.getPrototypeOf(p) === proto); // true ``` ### Cinq façons de déclencher la trappe `getPrototypeOf` @@ -74,16 +74,16 @@ console.log(Object.getPrototypeOf(p) === proto); // true ```js var obj = {}; var p = new Proxy(obj, { - getPrototypeOf(cible) { - return Array.prototype; - } + getPrototypeOf(cible) { + return Array.prototype; + }, }); console.log( - Object.getPrototypeOf(p) === Array.prototype, // true - Reflect.getPrototypeOf(p) === Array.prototype, // true - p.__proto__ === Array.prototype, // true - Array.prototype.isPrototypeOf(p), // true - p instanceof Array // true + Object.getPrototypeOf(p) === Array.prototype, // true + Reflect.getPrototypeOf(p) === Array.prototype, // true + p.__proto__ === Array.prototype, // true + Array.prototype.isPrototypeOf(p), // true + p instanceof Array, // true ); ``` @@ -92,17 +92,17 @@ console.log( ```js var obj = {}; var p = new Proxy(obj, { - getPrototypeOf(cible) { - return "toto"; - } + getPrototypeOf(cible) { + return "toto"; + }, }); Object.getPrototypeOf(p); // TypeError : "toto" n'est pas un objet ou null var obj = Object.preventExtensions({}); var p = new Proxy(obj, { - getPrototypeOf(cible) { - return {}; - } + getPrototypeOf(cible) { + return {}; + }, }); Object.getPrototypeOf(p); // TypeError : on attend la même valeur pour le prototype ``` diff --git a/files/fr/web/javascript/reference/global_objects/proxy/proxy/has/index.md b/files/fr/web/javascript/reference/global_objects/proxy/proxy/has/index.md index 3c9f2509def3e0..67054a7b884753 100644 --- a/files/fr/web/javascript/reference/global_objects/proxy/proxy/has/index.md +++ b/files/fr/web/javascript/reference/global_objects/proxy/proxy/has/index.md @@ -14,8 +14,7 @@ La méthode **`handler.has()`** est une trappe pour l'opérateur {{jsxref("Opér ```js var p = new Proxy(cible, { - has: function(cible, prop) { - } + has: function (cible, prop) {}, }); ``` @@ -57,15 +56,18 @@ Si les invariants suivants ne sont pas respectés, le proxy lèvera une exceptio Dans l'exemple qui suit, on intercepte l'opérateur {{jsxref("Opérateurs/L_opérateur_in", "in")}} : ```js -var p = new Proxy({}, { - has: function(cible, prop) { - console.log("appelée : " + prop); - return true; - } -}); +var p = new Proxy( + {}, + { + has: function (cible, prop) { + console.log("appelée : " + prop); + return true; + }, + }, +); console.log("a" in p); // "appelée : a" - // true +// true ``` L'exemple suivant ne respecte pas un invariant : @@ -74,9 +76,9 @@ L'exemple suivant ne respecte pas un invariant : var obj = { a: 10 }; Object.preventExtensions(obj); var p = new Proxy(obj, { - has: function(cible, prop) { + has: function (cible, prop) { return false; - } + }, }); "a" in p; // TypeError levée diff --git a/files/fr/web/javascript/reference/global_objects/proxy/proxy/isextensible/index.md b/files/fr/web/javascript/reference/global_objects/proxy/proxy/isextensible/index.md index 672c0eea129c46..cb94d50abb50ba 100644 --- a/files/fr/web/javascript/reference/global_objects/proxy/proxy/isextensible/index.md +++ b/files/fr/web/javascript/reference/global_objects/proxy/proxy/isextensible/index.md @@ -14,8 +14,7 @@ La méthode **`handler.isExtensible()`** est une trappe pour intercepter les op ```js var p = new Proxy(cible, { - isExtensible: function(cible) { - } + isExtensible: function (cible) {}, }); ``` @@ -52,25 +51,31 @@ Si les invariants suivants ne sont pas respectés, le proxy renverra une excepti Dans l'exemple qui suit, on intercepte {{jsxref("Object.isExtensible()")}}. ```js -var p = new Proxy({}, { - isExtensible: function(cible) { - console.log("appelée"); - return true; - } -}); +var p = new Proxy( + {}, + { + isExtensible: function (cible) { + console.log("appelée"); + return true; + }, + }, +); console.log(Object.isExtensible(p)); // "appelée" - // true +// true ``` Le code suivante ne respecte pas l'invariant et entraîne donc une exception. ```js -var p = new Proxy({}, { - isExtensible: function(cible) { - return false; - } -}); +var p = new Proxy( + {}, + { + isExtensible: function (cible) { + return false; + }, + }, +); Object.isExtensible(p); // TypeError est levée ``` From d413f210b77ed126759c5fab06ddfeab3ccbfd96 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 01:47:09 -0700 Subject: [PATCH 12/30] fr: Format /web/javascript using Prettier (part 8) (#14647) --- .../proxy/proxy/ownkeys/index.md | 28 +++-- .../proxy/proxy/preventextensions/index.md | 35 +++--- .../global_objects/proxy/proxy/set/index.md | 32 ++--- .../proxy/proxy/setprototypeof/index.md | 21 ++-- .../global_objects/proxy/revocable/index.md | 19 +-- .../global_objects/rangeerror/index.md | 28 +++-- .../rangeerror/rangeerror/index.md | 24 ++-- .../global_objects/referenceerror/index.md | 26 ++-- .../referenceerror/referenceerror/index.md | 38 +++--- .../global_objects/reflect/apply/index.md | 2 +- .../global_objects/reflect/construct/index.md | 8 +- .../reflect/defineproperty/index.md | 4 +- .../reflect/deleteproperty/index.md | 4 +- .../global_objects/reflect/get/index.md | 6 +- .../reflect/getownpropertydescriptor/index.md | 6 +- .../reflect/getprototypeof/index.md | 14 +-- .../global_objects/reflect/has/index.md | 21 ++-- .../reflect/isextensible/index.md | 2 +- .../global_objects/reflect/ownkeys/index.md | 16 ++- .../reflect/preventextensions/index.md | 2 +- .../reflect/setprototypeof/index.md | 2 +- .../global_objects/regexp/@@match/index.md | 16 +-- .../global_objects/regexp/@@matchall/index.md | 14 +-- .../global_objects/regexp/@@replace/index.md | 16 +-- .../global_objects/regexp/@@search/index.md | 16 +-- .../global_objects/regexp/@@species/index.md | 6 +- .../global_objects/regexp/@@split/index.md | 14 +-- .../global_objects/regexp/compile/index.md | 2 +- .../global_objects/regexp/exec/index.md | 14 +-- .../global_objects/regexp/flags/index.md | 10 +- .../global_objects/regexp/global/index.md | 12 +- .../global_objects/regexp/hasindices/index.md | 8 +- .../reference/global_objects/regexp/index.md | 33 ++--- .../global_objects/regexp/input/index.md | 12 +- .../global_objects/regexp/lastindex/index.md | 6 +- .../global_objects/regexp/lastmatch/index.md | 6 +- .../global_objects/regexp/lastparen/index.md | 6 +- .../regexp/leftcontext/index.md | 8 +- .../global_objects/regexp/n/index.md | 22 ++-- .../global_objects/regexp/regexp/index.md | 6 +- .../regexp/rightcontext/index.md | 6 +- .../global_objects/regexp/source/index.md | 6 +- .../global_objects/regexp/sticky/index.md | 2 +- .../global_objects/regexp/test/index.md | 20 +-- .../global_objects/regexp/tostring/index.md | 8 +- .../global_objects/regexp/unicode/index.md | 2 +- .../global_objects/set/@@iterator/index.md | 4 +- .../global_objects/set/@@species/index.md | 2 +- .../global_objects/set/clear/index.md | 6 +- .../global_objects/set/delete/index.md | 10 +- .../global_objects/set/entries/index.md | 2 +- .../global_objects/set/foreach/index.md | 2 +- .../reference/global_objects/set/has/index.md | 12 +- .../reference/global_objects/set/index.md | 59 +++++---- .../reference/global_objects/set/set/index.md | 16 +-- .../global_objects/set/size/index.md | 2 +- .../sharedarraybuffer/bytelength/index.md | 2 +- .../global_objects/sharedarraybuffer/index.md | 12 +- .../sharedarraybuffer/index.md | 4 +- .../sharedarraybuffer/slice/index.md | 14 +-- .../global_objects/string/@@iterator/index.md | 2 +- .../global_objects/string/anchor/index.md | 8 +- .../global_objects/string/at/index.md | 8 +- .../global_objects/string/big/index.md | 10 +- .../global_objects/string/blink/index.md | 2 +- .../global_objects/string/bold/index.md | 10 +- .../global_objects/string/charat/index.md | 63 +++++----- .../global_objects/string/charcodeat/index.md | 115 +++++++++--------- .../string/codepointat/index.md | 44 ++++--- .../global_objects/string/concat/index.md | 6 +- .../global_objects/string/endswith/index.md | 15 ++- .../global_objects/string/fixed/index.md | 2 +- .../global_objects/string/fontcolor/index.md | 13 +- .../global_objects/string/fontsize/index.md | 4 +- .../string/fromcharcode/index.md | 14 +-- .../string/fromcodepoint/index.md | 30 ++--- .../global_objects/string/includes/index.md | 24 ++-- .../reference/global_objects/string/index.md | 33 ++--- .../global_objects/string/indexof/index.md | 33 ++--- .../global_objects/string/italics/index.md | 2 +- .../string/lastindexof/index.md | 28 ++--- .../global_objects/string/length/index.md | 2 +- .../global_objects/string/link/index.md | 2 +- .../string/localecompare/index.md | 27 ++-- .../global_objects/string/match/index.md | 16 +-- .../global_objects/string/matchall/index.md | 18 +-- .../global_objects/string/normalize/index.md | 4 - .../global_objects/string/padend/index.md | 8 +- .../global_objects/string/padstart/index.md | 10 +- .../global_objects/string/raw/index.md | 8 +- .../global_objects/string/repeat/index.md | 23 ++-- .../global_objects/string/replace/index.md | 37 +++--- .../global_objects/string/replaceall/index.md | 6 +- .../global_objects/string/search/index.md | 2 +- .../global_objects/string/slice/index.md | 16 +-- .../global_objects/string/small/index.md | 8 +- .../global_objects/string/split/index.md | 23 ++-- .../global_objects/string/startswith/index.md | 4 +- .../global_objects/string/strike/index.md | 2 +- .../global_objects/string/string/index.md | 8 +- 100 files changed, 757 insertions(+), 689 deletions(-) diff --git a/files/fr/web/javascript/reference/global_objects/proxy/proxy/ownkeys/index.md b/files/fr/web/javascript/reference/global_objects/proxy/proxy/ownkeys/index.md index ce72b0624d1ac5..bcfa2e5f493206 100644 --- a/files/fr/web/javascript/reference/global_objects/proxy/proxy/ownkeys/index.md +++ b/files/fr/web/javascript/reference/global_objects/proxy/proxy/ownkeys/index.md @@ -14,8 +14,7 @@ La méthode **`handler.ownKeys()`** est une trappe pour {{jsxref("Object.getOwnP ```js var p = new Proxy(cible, { - ownKeys: function(cible) { - } + ownKeys: function (cible) {}, }); ``` @@ -57,15 +56,18 @@ Si les invariants suivants ne sont pas respectés, le proxy renverra une excepti Dans l'exemple suivant, on intercepte l'action de {{jsxref("Object.getOwnPropertyNames()")}}. ```js -var p = new Proxy({}, { - ownKeys: function(target) { - console.log("appelée"); - return ["a", "b", "c"]; - } -}); +var p = new Proxy( + {}, + { + ownKeys: function (target) { + console.log("appelée"); + return ["a", "b", "c"]; + }, + }, +); console.log(Object.getOwnPropertyNames(p)); // "appelée" - // [ "a", "b", "c"] +// [ "a", "b", "c"] ``` L'exemple suivant ne respecte pas l'ensemble des invariants : @@ -75,13 +77,13 @@ var obj = {}; Object.defineProperty(obj, "a", { configurable: false, enumerable: true, - value: 10 } -); + value: 10, +}); var p = new Proxy(obj, { - ownKeys: function(cible) { + ownKeys: function (cible) { return [123, 12.5, true, false, undefined, null, {}, []]; - } + }, }); console.log(Object.getOwnPropertyNames(p)); diff --git a/files/fr/web/javascript/reference/global_objects/proxy/proxy/preventextensions/index.md b/files/fr/web/javascript/reference/global_objects/proxy/proxy/preventextensions/index.md index d8a53c4114e13c..bcfaaf77f936e1 100644 --- a/files/fr/web/javascript/reference/global_objects/proxy/proxy/preventextensions/index.md +++ b/files/fr/web/javascript/reference/global_objects/proxy/proxy/preventextensions/index.md @@ -14,8 +14,7 @@ La méthode **`handler.preventExtensions()`** est une trappe pour {{jsxref("Obje ```js var p = new Proxy(cible, { - preventExtensions: function(cible) { - } + preventExtensions: function (cible) {}, }); ``` @@ -52,26 +51,32 @@ Si les invariants suivants ne sont pas respectés, le proxy renverra une execpti On intercepte l'appel à {{jsxref("Object.preventExtensions()")}} dans l'exemple suivant : ```js -var p = new Proxy({}, { - preventExtensions: function(cible) { - console.log("appelé"); - Object.preventExtensions(cible); - return true; - } -}); +var p = new Proxy( + {}, + { + preventExtensions: function (cible) { + console.log("appelé"); + Object.preventExtensions(cible); + return true; + }, + }, +); console.log(Object.preventExtensions(p)); // "appelé" - // true +// true ``` Le code suivant ne respecte pas l'invariant : ```js -var p = new Proxy({}, { - preventExtensions: function(cible) { - return true; - } -}); +var p = new Proxy( + {}, + { + preventExtensions: function (cible) { + return true; + }, + }, +); Object.preventExtensions(p); // TypeError est levée ``` diff --git a/files/fr/web/javascript/reference/global_objects/proxy/proxy/set/index.md b/files/fr/web/javascript/reference/global_objects/proxy/proxy/set/index.md index 60c45da9185f2b..5a56143bd313e2 100644 --- a/files/fr/web/javascript/reference/global_objects/proxy/proxy/set/index.md +++ b/files/fr/web/javascript/reference/global_objects/proxy/proxy/set/index.md @@ -14,8 +14,7 @@ La méthode **`handler.set()`** est une trappe permettant d'intercepter les opé ```js var p = new Proxy(cible, { - set: function(cible, propriété, valeur, récepteur) { - } + set: function (cible, propriété, valeur, récepteur) {}, }); ``` @@ -61,19 +60,22 @@ Si les invariants suivants ne sont pas respectés, le proxy renverra une excepti Dans l'exemple qui suit, on intercepte la définition d'une nouvelle propriété. ```js -var p = new Proxy({}, { - set: function(target, prop, value, receiver) { - target[prop] = value; - console.log('property set: ' + prop + ' = ' + value); - return true; - } -}); - -console.log('a' in p); // false - -p.a = 10; // "property set: a = 10" -console.log('a' in p); // true -console.log(p.a); // 10 +var p = new Proxy( + {}, + { + set: function (target, prop, value, receiver) { + target[prop] = value; + console.log("property set: " + prop + " = " + value); + return true; + }, + }, +); + +console.log("a" in p); // false + +p.a = 10; // "property set: a = 10" +console.log("a" in p); // true +console.log(p.a); // 10 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/proxy/proxy/setprototypeof/index.md b/files/fr/web/javascript/reference/global_objects/proxy/proxy/setprototypeof/index.md index 4cc684bf3c96c0..c136ca3ec05cf7 100644 --- a/files/fr/web/javascript/reference/global_objects/proxy/proxy/setprototypeof/index.md +++ b/files/fr/web/javascript/reference/global_objects/proxy/proxy/setprototypeof/index.md @@ -14,8 +14,7 @@ La méthode **`handler.setPrototypeOf()`** est une trappe pour intercepter {{jsx ```js var p = new Proxy(cible, { - setPrototypeOf: function(cible, prototype) { - } + setPrototypeOf: function (cible, prototype) {}, }); ``` @@ -57,12 +56,13 @@ Avec cette première approche, toute opération qui voudra modifier le prototype ```js var handlerReturnsFalse = { - setPrototypeOf(target, newProto) { - return false; - } + setPrototypeOf(target, newProto) { + return false; + }, }; -var newProto = {}, target = {}; +var newProto = {}, + target = {}; var p1 = new Proxy(target, handlerReturnsFalse); Object.setPrototypeOf(p1, newProto); @@ -75,12 +75,13 @@ Avec cette seconde approche, toute tentative de modification génèrera une exce ```js var handlerThrows = { - setPrototypeOf(target, newProto) { - throw new Error("erreur custom"); - } + setPrototypeOf(target, newProto) { + throw new Error("erreur custom"); + }, }; -var newProto = {}, target = {}; +var newProto = {}, + target = {}; var p2 = new Proxy(target, handlerThrows); Object.setPrototypeOf(p2, newProto); diff --git a/files/fr/web/javascript/reference/global_objects/proxy/revocable/index.md b/files/fr/web/javascript/reference/global_objects/proxy/revocable/index.md index d8b05d631379a1..ab177505ad9e70 100644 --- a/files/fr/web/javascript/reference/global_objects/proxy/revocable/index.md +++ b/files/fr/web/javascript/reference/global_objects/proxy/revocable/index.md @@ -41,20 +41,23 @@ Si la fonction `revoke()` est appelée, le proxy devient inutilisable et toutes ### Utiliser `Proxy.revocable()` ```js -let revocable = Proxy.revocable({}, { - get: function(cible, nom) { - return "[[" + nom + "]]"; - } -}); +let revocable = Proxy.revocable( + {}, + { + get: function (cible, nom) { + return "[[" + nom + "]]"; + }, + }, +); let proxy = revocable.proxy; console.log(proxy.toto); // "[[toto]]" revocable.revoke(); console.log(proxy.toto); // TypeError est levée -proxy.toto = 1; // TypeError à nouveau -delete proxy.toto; // TypeError toujours -typeof proxy; // "object", typeof ne déclenche aucune trappe +proxy.toto = 1; // TypeError à nouveau +delete proxy.toto; // TypeError toujours +typeof proxy; // "object", typeof ne déclenche aucune trappe ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/rangeerror/index.md b/files/fr/web/javascript/reference/global_objects/rangeerror/index.md index 54a53dee87e5b3..118b53ec197faf 100644 --- a/files/fr/web/javascript/reference/global_objects/rangeerror/index.md +++ b/files/fr/web/javascript/reference/global_objects/rangeerror/index.md @@ -45,17 +45,18 @@ Par exemple, cela peut être le cas quand : ```js const MIN = 200; const MAX = 300; -function verifier( num ) { - if( num < MIN || num > MAX ) { - throw new RangeError( "Le paramètre doit être compris entre " + MIN + " et " + MAX ); +function verifier(num) { + if (num < MIN || num > MAX) { + throw new RangeError( + "Le paramètre doit être compris entre " + MIN + " et " + MAX, + ); } -}; +} try { verifier(500); -} -catch (e) { - if (e instanceof RangeError ){ +} catch (e) { + if (e instanceof RangeError) { // On gère ce qui se passe en cas d'erreur } } @@ -64,17 +65,18 @@ catch (e) { ### Utiliser `RangeError` avec des valeurs non-numériques ```js -function verifier(valeur){ - if(["pomme", "banane", "carotte"].includes(valeur) === false){ - throw new RangeError("L'argument n'est pas un fruit parmi pomme / banane ou carotte."); +function verifier(valeur) { + if (["pomme", "banane", "carotte"].includes(valeur) === false) { + throw new RangeError( + "L'argument n'est pas un fruit parmi pomme / banane ou carotte.", + ); } } try { verifier("chou"); -} -catch(erreur) { - if(erreur instanceof RangeError){ +} catch (erreur) { + if (erreur instanceof RangeError) { //On gère ce qui se passe en cas d'erreur } } diff --git a/files/fr/web/javascript/reference/global_objects/rangeerror/rangeerror/index.md b/files/fr/web/javascript/reference/global_objects/rangeerror/rangeerror/index.md index facf916ebba1da..5238ffd60188a9 100644 --- a/files/fr/web/javascript/reference/global_objects/rangeerror/rangeerror/index.md +++ b/files/fr/web/javascript/reference/global_objects/rangeerror/rangeerror/index.md @@ -11,10 +11,10 @@ Le constructeur **`RangeError()`** permet de créer une erreur lorsqu'une valeur ## Syntaxe ```js -new RangeError() -new RangeError(message) -new RangeError(message, nomFichier) -new RangeError(message, nomFichier, numeroLigne) +new RangeError(); +new RangeError(message); +new RangeError(message, nomFichier); +new RangeError(message, nomFichier, numeroLigne); ``` ### Parameters @@ -32,15 +32,14 @@ new RangeError(message, nomFichier, numeroLigne) ```js function verifier(n) { - if( !(n >= -500 && n <= 500) ) { + if (!(n >= -500 && n <= 500)) { throw new RangeError("L'argument doit être compris entre -500 et 500."); } } try { verifier(2000); -} -catch(error) { +} catch (error) { if (error instanceof RangeError) { // Gérer l'erreur } @@ -51,16 +50,17 @@ catch(error) { ```js function verifier(valeur) { - if(["pomme", "banane", "carotte"].includes(valeur) === false) { - throw new RangeError("L'argument doit valeur 'pomme', 'banane', ou 'carotte'."); + if (["pomme", "banane", "carotte"].includes(valeur) === false) { + throw new RangeError( + "L'argument doit valeur 'pomme', 'banane', ou 'carotte'.", + ); } } try { verifier("chou"); -} -catch(error) { - if(error instanceof RangeError) { +} catch (error) { + if (error instanceof RangeError) { // Gérer l'erreur } } diff --git a/files/fr/web/javascript/reference/global_objects/referenceerror/index.md b/files/fr/web/javascript/reference/global_objects/referenceerror/index.md index 0dd5d8f6dec7f2..41d262c280f6c1 100644 --- a/files/fr/web/javascript/reference/global_objects/referenceerror/index.md +++ b/files/fr/web/javascript/reference/global_objects/referenceerror/index.md @@ -37,12 +37,12 @@ try { let a = variableNonDefinie; } catch (e) { console.log(e instanceof ReferenceError); // true - console.log(e.message); // "variableNonDefinie is not defined" - console.log(e.name); // "ReferenceError" - console.log(e.fileName); // "Scratchpad/1" - console.log(e.lineNumber); // 2 - console.log(e.columnNumber); // 6 - console.log(e.stack); // "@Scratchpad/2:2:7\n" + console.log(e.message); // "variableNonDefinie is not defined" + console.log(e.name); // "ReferenceError" + console.log(e.fileName); // "Scratchpad/1" + console.log(e.lineNumber); // 2 + console.log(e.columnNumber); // 6 + console.log(e.stack); // "@Scratchpad/2:2:7\n" } ``` @@ -50,15 +50,15 @@ try { ```js try { - throw new ReferenceError('Bonjour', 'unFichier.js', 10); + throw new ReferenceError("Bonjour", "unFichier.js", 10); } catch (e) { console.log(e instanceof ReferenceError); // true - console.log(e.message); // "Bonjour" - console.log(e.name); // "ReferenceError" - console.log(e.fileName); // "unFichier.js" - console.log(e.lineNumber); // 10 - console.log(e.columnNumber); // 0 - console.log(e.stack); // "@Scratchpad/2:2:9\n" + console.log(e.message); // "Bonjour" + console.log(e.name); // "ReferenceError" + console.log(e.fileName); // "unFichier.js" + console.log(e.lineNumber); // 10 + console.log(e.columnNumber); // 0 + console.log(e.stack); // "@Scratchpad/2:2:9\n" } ``` diff --git a/files/fr/web/javascript/reference/global_objects/referenceerror/referenceerror/index.md b/files/fr/web/javascript/reference/global_objects/referenceerror/referenceerror/index.md index c984d76f5214a4..013b0b554eb9f5 100644 --- a/files/fr/web/javascript/reference/global_objects/referenceerror/referenceerror/index.md +++ b/files/fr/web/javascript/reference/global_objects/referenceerror/referenceerror/index.md @@ -11,10 +11,10 @@ Le constructeur **`ReferenceError()`** permet de créer des objets représentant ## Syntaxe ```js -new ReferenceError() -new ReferenceError(message) -new ReferenceError(message, nomFichier) -new ReferenceError(message, nomFichier, numeroLigne) +new ReferenceError(); +new ReferenceError(message); +new ReferenceError(message, nomFichier); +new ReferenceError(message, nomFichier, numeroLigne); ``` ### Paramètres @@ -34,13 +34,13 @@ new ReferenceError(message, nomFichier, numeroLigne) try { let a = variableIndefinie; } catch (e) { - console.log(e instanceof ReferenceError); // true - console.log(e.message); // "variableIndefinie is not defined" - console.log(e.name); // "ReferenceError" - console.log(e.fileName); // "Scratchpad/1" - console.log(e.lineNumber); // 2 - console.log(e.columnNumber); // 6 - console.log(e.stack); // "@Scratchpad/2:2:7\n" + console.log(e instanceof ReferenceError); // true + console.log(e.message); // "variableIndefinie is not defined" + console.log(e.name); // "ReferenceError" + console.log(e.fileName); // "Scratchpad/1" + console.log(e.lineNumber); // 2 + console.log(e.columnNumber); // 6 + console.log(e.stack); // "@Scratchpad/2:2:7\n" } ``` @@ -48,15 +48,15 @@ try { ```js try { - throw new ReferenceError('Coucou', 'unFichier.js', 10); + throw new ReferenceError("Coucou", "unFichier.js", 10); } catch (e) { - console.log(e instanceof ReferenceError); // true - console.log(e.message); // "Coucou" - console.log(e.name); // "ReferenceError" - console.log(e.fileName); // "unFichier.js" - console.log(e.lineNumber); // 10 - console.log(e.columnNumber); // 0 - console.log(e.stack); // "@Scratchpad/2:2:9\n" + console.log(e instanceof ReferenceError); // true + console.log(e.message); // "Coucou" + console.log(e.name); // "ReferenceError" + console.log(e.fileName); // "unFichier.js" + console.log(e.lineNumber); // 10 + console.log(e.columnNumber); // 0 + console.log(e.stack); // "@Scratchpad/2:2:9\n" } ``` 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 index c31e1d9ad4fbc2..69b75be8f7cb80 100644 --- a/files/fr/web/javascript/reference/global_objects/reflect/apply/index.md +++ b/files/fr/web/javascript/reference/global_objects/reflect/apply/index.md @@ -13,7 +13,7 @@ La méthode statique **`Reflect.apply()`** permet d'appeler une fonction cible a ## Syntaxe ```js -Reflect.apply(cible, argumentThis, listeArguments) +Reflect.apply(cible, argumentThis, listeArguments); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/reflect/construct/index.md b/files/fr/web/javascript/reference/global_objects/reflect/construct/index.md index 68f5b68cd9e73b..a5683d89dfaa55 100644 --- a/files/fr/web/javascript/reference/global_objects/reflect/construct/index.md +++ b/files/fr/web/javascript/reference/global_objects/reflect/construct/index.md @@ -70,11 +70,11 @@ Avant l'apparition de `Reflect`, on pouvait construire des objets avec une combi ```js function MaClasseA() { - this.name = 'A'; + this.name = "A"; } function MaClasseB() { - this.name = 'B'; + this.name = "B"; } // Avec cette instruction : @@ -100,11 +100,11 @@ Mais quand on appelle `Reflect.construct()`, `new.target` pointe vers la valeur ```js function MaClasseA() { - console.log('MaClasseA'); + console.log("MaClasseA"); console.log(new.target); } function MaClasseB() { - console.log('MaClasseB'); + console.log("MaClasseB"); console.log(new.target); } diff --git a/files/fr/web/javascript/reference/global_objects/reflect/defineproperty/index.md b/files/fr/web/javascript/reference/global_objects/reflect/defineproperty/index.md index e5e862b0d54c67..d92fc5d29658a3 100644 --- a/files/fr/web/javascript/reference/global_objects/reflect/defineproperty/index.md +++ b/files/fr/web/javascript/reference/global_objects/reflect/defineproperty/index.md @@ -13,7 +13,7 @@ La méthode statique **`Reflect.defineProperty()`** est semblable à {{jsxref("O ## Syntaxe ```js -Reflect.defineProperty(cible, cléPropriété, attributs) +Reflect.defineProperty(cible, cléPropriété, attributs); ``` ### Paramètres @@ -43,7 +43,7 @@ La méthode `Reflect.defineProperty` permet d'ajouter ou de modifier finement un ```js var obj = {}; -Reflect.defineProperty(obj, "x", {value: 7}); // true +Reflect.defineProperty(obj, "x", { value: 7 }); // true obj.x; // 7 ``` diff --git a/files/fr/web/javascript/reference/global_objects/reflect/deleteproperty/index.md b/files/fr/web/javascript/reference/global_objects/reflect/deleteproperty/index.md index 7a31a359acd730..cc675abd278254 100644 --- a/files/fr/web/javascript/reference/global_objects/reflect/deleteproperty/index.md +++ b/files/fr/web/javascript/reference/global_objects/reflect/deleteproperty/index.md @@ -13,7 +13,7 @@ La méthode statique **`Reflect.deleteProperty()`** permet de supprimer des prop ## Syntaxe ```js -Reflect.deleteProperty(cible, cléPropriété) +Reflect.deleteProperty(cible, cléPropriété); ``` ### Paramètres @@ -50,7 +50,7 @@ arr; // [1, 2, 3, , 5] Reflect.deleteProperty({}, "toto"); // true // Renvoie false si une propriété n'est pas configurable -Reflect.deleteProperty(Object.freeze({toto: 1}),"toto"); // false +Reflect.deleteProperty(Object.freeze({ toto: 1 }), "toto"); // false ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/reflect/get/index.md b/files/fr/web/javascript/reference/global_objects/reflect/get/index.md index 9c888c9b05401a..47d53a07fa790f 100644 --- a/files/fr/web/javascript/reference/global_objects/reflect/get/index.md +++ b/files/fr/web/javascript/reference/global_objects/reflect/get/index.md @@ -48,9 +48,11 @@ Reflect.get(obj, "x"); // 1 Reflect.get(["zero", "un"], 1); // "un" // Proxy qui intercepte get -var x = {p: 1}; +var x = { p: 1 }; var obj = new Proxy(x, { - get(t, k, r) { return k + "truc"; } + get(t, k, r) { + return k + "truc"; + }, }); Reflect.get(obj, "toto"); // "tototruc" ``` diff --git a/files/fr/web/javascript/reference/global_objects/reflect/getownpropertydescriptor/index.md b/files/fr/web/javascript/reference/global_objects/reflect/getownpropertydescriptor/index.md index 69522ae0b97923..8c31a32b34c223 100644 --- a/files/fr/web/javascript/reference/global_objects/reflect/getownpropertydescriptor/index.md +++ b/files/fr/web/javascript/reference/global_objects/reflect/getownpropertydescriptor/index.md @@ -13,7 +13,7 @@ La méthode statique **`Reflect.getOwnPropertyDescriptor()`** est similaire à { ## Syntaxe ```js -Reflect.getOwnPropertyDescriptor(cible, cléPropriété) +Reflect.getOwnPropertyDescriptor(cible, cléPropriété); ``` ### Paramètres @@ -40,10 +40,10 @@ La méthode `Reflect.getOwnPropertyDescriptor` renvoie un descripteur pour la pr ### Utiliser `Reflect.getOwnPropertyDescriptor()` ```js -Reflect.getOwnPropertyDescriptor({x: "coucou"}, "x"); +Reflect.getOwnPropertyDescriptor({ x: "coucou" }, "x"); // {value: "coucou", writable: true, enumerable: true, configurable: true} -Reflect.getOwnPropertyDescriptor({x: "coucou"}, "y"); +Reflect.getOwnPropertyDescriptor({ x: "coucou" }, "y"); // undefined Reflect.getOwnPropertyDescriptor([], "length"); diff --git a/files/fr/web/javascript/reference/global_objects/reflect/getprototypeof/index.md b/files/fr/web/javascript/reference/global_objects/reflect/getprototypeof/index.md index c254220d3d1693..f0252c6a9ad360 100644 --- a/files/fr/web/javascript/reference/global_objects/reflect/getprototypeof/index.md +++ b/files/fr/web/javascript/reference/global_objects/reflect/getprototypeof/index.md @@ -13,7 +13,7 @@ La méthode statique **`Reflect.getPrototypeOf()`** est semblable à la méthode ## Syntaxe ```js -Reflect.getPrototypeOf(cible) +Reflect.getPrototypeOf(cible); ``` ### Paramètres @@ -47,21 +47,21 @@ Reflect.getPrototypeOf(Object.create(null)); // null ```js // Résultat identiques pour les objets -Object.getPrototypeOf({}); // Object.prototype +Object.getPrototypeOf({}); // Object.prototype Reflect.getPrototypeOf({}); // Object.prototype // Exception levée avec ES5 pour les valeurs qui ne sont pas des objets -Object.getPrototypeOf('toto'); // Throws TypeError -Reflect.getPrototypeOf('toto'); // Throws TypeError +Object.getPrototypeOf("toto"); // Throws TypeError +Reflect.getPrototypeOf("toto"); // Throws TypeError // Avec ES2015 (ES6), seul Reflect lève une exception // Object convertit automatiquement les valeurs en objets -Object.getPrototypeOf('toto'); // String.prototype -Reflect.getPrototypeOf('toto'); // Throws TypeError +Object.getPrototypeOf("toto"); // String.prototype +Reflect.getPrototypeOf("toto"); // Throws TypeError // Pour obtenir le même effet qu'avec Object en ES2015, il // faut ajouter une opération de conversion explicite -Reflect.getPrototypeOf(Object('toto')); // String.prototype +Reflect.getPrototypeOf(Object("toto")); // String.prototype ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/reflect/has/index.md b/files/fr/web/javascript/reference/global_objects/reflect/has/index.md index 7336cf65c0ab63..d714862f483880 100644 --- a/files/fr/web/javascript/reference/global_objects/reflect/has/index.md +++ b/files/fr/web/javascript/reference/global_objects/reflect/has/index.md @@ -13,7 +13,7 @@ La méthode statique **`Reflect.has()`** fonctionne comme [l'opérateur `in`](/f ## Syntaxe ```js -Reflect.has(cible, cléPropriété) +Reflect.has(cible, cléPropriété); ``` ### Paramètres @@ -38,19 +38,24 @@ La méthode `Reflect.has` vous permet de vérifier si une propriété est prése ## Exemples ```js -Reflect.has({x: 0}, "x"); // true -Reflect.has({x: 0}, "y"); // false +Reflect.has({ x: 0 }, "x"); // true +Reflect.has({ x: 0 }, "y"); // false // renvoie true pour les propriétés présentes // grâce à la chaîne de prototypes -Reflect.has({x: 0}, "toString"); +Reflect.has({ x: 0 }, "toString"); // Proxy avec la méthode .has() -obj = new Proxy({}, { - has(t, k) { return k.startsWith("bou"); } -}); +obj = new Proxy( + {}, + { + has(t, k) { + return k.startsWith("bou"); + }, + }, +); Reflect.has(obj, "bouchon"); // true -Reflect.has(obj, "bonbon"); // false +Reflect.has(obj, "bonbon"); // false ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/reflect/isextensible/index.md b/files/fr/web/javascript/reference/global_objects/reflect/isextensible/index.md index 4f571e9f01f187..dcd6144cea2b1d 100644 --- a/files/fr/web/javascript/reference/global_objects/reflect/isextensible/index.md +++ b/files/fr/web/javascript/reference/global_objects/reflect/isextensible/index.md @@ -13,7 +13,7 @@ La méthode statique **`Reflect.isExtensible()`** permet de déterminer si un ob ## Syntaxe ```js -Reflect.isExtensible(cible) +Reflect.isExtensible(cible); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/reflect/ownkeys/index.md b/files/fr/web/javascript/reference/global_objects/reflect/ownkeys/index.md index 350ccd93a4c1a1..c40a48905a3bd5 100644 --- a/files/fr/web/javascript/reference/global_objects/reflect/ownkeys/index.md +++ b/files/fr/web/javascript/reference/global_objects/reflect/ownkeys/index.md @@ -13,7 +13,7 @@ La méthode statique **`Reflect.ownKeys()`** renvoie un tableau qui contient les ## Syntaxe ```js -Reflect.ownKeys(cible) +Reflect.ownKeys(cible); ``` ### Paramètres @@ -36,13 +36,21 @@ La méthode `Reflect.ownKeys` renvoie un tableau dont les éléments sont les cl ## Exemples ```js -Reflect.ownKeys({z: 3, y: 2, x: 1}); // [ "z", "y", "x" ] +Reflect.ownKeys({ z: 3, y: 2, x: 1 }); // [ "z", "y", "x" ] Reflect.ownKeys([]); // ["length"] var sym = Symbol.for("comète"); var sym2 = Symbol.for("météore"); -var obj = {[sym]: 0, "str1": 0, "773": 0, "0": 0, - [sym2]: 0, "-1": 0, "8": 0, "seconde str": 0}; +var obj = { + [sym]: 0, + str1: 0, + 773: 0, + 0: 0, + [sym2]: 0, + "-1": 0, + 8: 0, + "seconde str": 0, +}; Reflect.ownKeys(obj); // [ "0", "8", "773", "str1", "-1", "seconde str", Symbol(comète), Symbol(météore) ] // Indices dans l'ordre numérique diff --git a/files/fr/web/javascript/reference/global_objects/reflect/preventextensions/index.md b/files/fr/web/javascript/reference/global_objects/reflect/preventextensions/index.md index 9a99418c5c6296..154ac03f0eccbc 100644 --- a/files/fr/web/javascript/reference/global_objects/reflect/preventextensions/index.md +++ b/files/fr/web/javascript/reference/global_objects/reflect/preventextensions/index.md @@ -13,7 +13,7 @@ La méthode statique **`Reflect.preventExtensions()`** permet d'empêcher d'ajou ## Syntaxe ```js -Reflect.preventExtensions(cible) +Reflect.preventExtensions(cible); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/reflect/setprototypeof/index.md b/files/fr/web/javascript/reference/global_objects/reflect/setprototypeof/index.md index 7f53fa5012caad..9daf0249801723 100644 --- a/files/fr/web/javascript/reference/global_objects/reflect/setprototypeof/index.md +++ b/files/fr/web/javascript/reference/global_objects/reflect/setprototypeof/index.md @@ -13,7 +13,7 @@ la méthode statique **`Reflect.setPrototypeOf()`** est semblable à la méthode ## Syntaxe ```js -Reflect.setPrototypeOf(cible, prototype) +Reflect.setPrototypeOf(cible, prototype); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/regexp/@@match/index.md b/files/fr/web/javascript/reference/global_objects/regexp/@@match/index.md index ba5d76d38155d6..7b5b6cc5d7074c 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/@@match/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/@@match/index.md @@ -13,7 +13,7 @@ La méthode **`[@@match]()`** permet de récupérer les correspondances obtenues ## Syntaxe ```js -regexp[Symbol.match](str) +regexp[Symbol.match](str); ``` ### Paramètres @@ -30,9 +30,9 @@ Un tableau ({{jsxref("Array")}}) qui contient les résultats des correspondances Cette méthode est appelée de façon interne lorsqu'on utilise {{jsxref("String.prototype.match()")}}. Ainsi, les deux exemples qui suivent sont équivalents et le second est la version interne du premier : ```js -'abc'.match(/a/); +"abc".match(/a/); -/a/[Symbol.match]('abc'); +/a/[Symbol.match]("abc"); ``` Cette méthode existe afin de permettre d'adapter le comportement de la recherche des correspondances pour les sous-classes de `RegExp`. @@ -45,9 +45,9 @@ Cette méthode peut être utilisée comme {{jsxref("String.prototype.match()")}} ```js var re = /[0-9]+/g; -var str = '2016-01-02'; +var str = "2016-01-02"; var résultat = re[Symbol.match](str); -console.log(résultat); // ["2016", "01", "02"] +console.log(résultat); // ["2016", "01", "02"] ``` ### Utilisation de `@@match` avec une sous-classe @@ -62,13 +62,13 @@ class MaRegExp extends RegExp { return { group(n) { return résultat[n]; - } + }, }; } } -var re = new MaRegExp('([0-9]+)-([0-9]+)-([0-9]+)'); -var str = '2016-01-02'; +var re = new MaRegExp("([0-9]+)-([0-9]+)-([0-9]+)"); +var str = "2016-01-02"; var résultat = str.match(re); // String.prototype.match appelle re[@@match]. console.log(résultat.group(1)); // 2016 console.log(résultat.group(2)); // 01 diff --git a/files/fr/web/javascript/reference/global_objects/regexp/@@matchall/index.md b/files/fr/web/javascript/reference/global_objects/regexp/@@matchall/index.md index e21be9c24c9c0c..a689f6e846591d 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/@@matchall/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/@@matchall/index.md @@ -13,7 +13,7 @@ La méthode **`[@@matchAll]`** renvoie l'ensemble des correspondances d'une expr ## Syntaxe ```js -regexp[Symbol.matchAll](str) +regexp[Symbol.matchAll](str); ``` ### Paramètres @@ -30,9 +30,9 @@ Un [itérateur](/fr/docs/Web/JavaScript/Guide/iterateurs_et_generateurs). Cette méthode est appelée, en interne, par le moteur JavaScript, pendant l'exécution {{jsxref("String.prototype.matchAll()")}}. Les deux lignes qui suivent renverront donc le même résultat. ```js -'abc'.matchAll(/a/); +"abc".matchAll(/a/); -/a/[Symbol.matchAll]('abc'); +/a/[Symbol.matchAll]("abc"); ``` Cette méthode existe afin de personnaliser le comportement des correspondances pour les sous-classes de `RegExp`. @@ -45,10 +45,10 @@ Cette méthode peut être utilisée de façon semblable à {{jsxref("String.prot ```js var re = /[0-9]+/g; -var str = '2016-01-02'; +var str = "2016-01-02"; var resultat = re[Symbol.matchAll](str); -console.log(Array.from(resultat, x => x[0])); +console.log(Array.from(resultat, (x) => x[0])); // ["2016", "01", "02"] ``` @@ -68,8 +68,8 @@ class MaRegExp extends RegExp { } } -var re = new MaRegExp('([0-9]+)-([0-9]+)-([0-9]+)', 'g'); -var str = '2016-01-02|2019-03-07'; +var re = new MaRegExp("([0-9]+)-([0-9]+)-([0-9]+)", "g"); +var str = "2016-01-02|2019-03-07"; var resultat = str.matchAll(re); console.log(resultat[0]); // [ "2016-01-02", "2016", "01", "02" ] console.log(resultat[1]); // [ "2019-03-07", "2019", "03", "07" ] diff --git a/files/fr/web/javascript/reference/global_objects/regexp/@@replace/index.md b/files/fr/web/javascript/reference/global_objects/regexp/@@replace/index.md index 5faaa9b52e21d6..772421c0e5d9b3 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/@@replace/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/@@replace/index.md @@ -34,9 +34,9 @@ Une nouvelle chaîne de caractères pour laquelle les correspondances (toutes ou Cette méthode est appelée de façon interne par la méthode {{jsxref("String.prototype.replace()")}} lorsque l'arugment `pattern` argument est un objet {{jsxref("RegExp")}}. Les deux lignes de code qui suivent sont équivalentes et la seconde est la version interne de la première : ```js -'abc'.replace(/a/, 'A'); +"abc".replace(/a/, "A"); -/a/[Symbol.replace]('abc', 'A'); +/a/[Symbol.replace]("abc", "A"); ``` Cette méthode existe afin de pouvoir personnaliser le comportement du remplacement pour les classes filles de `RegExp`. @@ -51,9 +51,9 @@ Cette méthode peut être utilisée comme {{jsxref("String.prototype.replace()") ```js var re = /-/g; -var str = '2016-01-01'; -var newstr = re[Symbol.replace](str, '.'); -console.log(newstr); // 2016.01.01 +var str = "2016-01-01"; +var newstr = re[Symbol.replace](str, "."); +console.log(newstr); // 2016.01.01 ``` ### Utiliser `@@replace` dans une sous-classe @@ -76,9 +76,9 @@ class MaRegExp extends RegExp { } } -var re = new MaRegExp('\\d', '', 3); -var str = '01234567'; -var newstr = str.replace(re, '#'); // String.prototype.replace appelle re[@@replace]. +var re = new MaRegExp("\\d", "", 3); +var str = "01234567"; +var newstr = str.replace(re, "#"); // String.prototype.replace appelle re[@@replace]. console.log(newstr); // ###34567 ``` diff --git a/files/fr/web/javascript/reference/global_objects/regexp/@@search/index.md b/files/fr/web/javascript/reference/global_objects/regexp/@@search/index.md index b0caf1c94d9788..607e83ab1e61e1 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/@@search/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/@@search/index.md @@ -13,7 +13,7 @@ La méthode **`[@@search]()`** recherche une correspondance entre une expression ## Syntaxe ```js -regexp[Symbol.search](str) +regexp[Symbol.search](str); ``` ### Paramètres @@ -31,9 +31,9 @@ regexp[Symbol.search](str) Cette méthode est appelée en interne lors de l'utilisation de {{jsxref("String.prototype.search()")}}. Ainsi, les deux exemples qui suivent sont équivalents et le second est la version interne du premier : ```js -'abc'.search(/a/); +"abc".search(/a/); -/a/[Symbol.search]('abc'); +/a/[Symbol.search]("abc"); ``` Cette méthode existe afin de pouvoir adapter le comportement de la recherche pour les sous-classes de `RegExp`. @@ -46,9 +46,9 @@ Cette méthode peut être utilisée comme {{jsxref("String.prototype.search()")} ```js var re = /-/g; -var str = '2016-01-02'; +var str = "2016-01-02"; var résultat = re[Symbol.search](str); -console.log(résultat); // 4 +console.log(résultat); // 4 ``` ### Utiliser `@@search` avec une sous-classe @@ -58,7 +58,7 @@ Les sous-classes de {{jsxref("RegExp")}} peuvent surcharger `[@@search]()` afin ```js class MaRegExp extends RegExp { constructor(str) { - super(str) + super(str); this.pattern = str; } [Symbol.search](str) { @@ -66,8 +66,8 @@ class MaRegExp extends RegExp { } } -var re = new MaRegExp('a+b'); -var str = 'ab a+b'; +var re = new MaRegExp("a+b"); +var str = "ab a+b"; var résultat = str.search(re); // String.prototype.search appelle re[@@search]. console.log(résultat); // 3 ``` diff --git a/files/fr/web/javascript/reference/global_objects/regexp/@@species/index.md b/files/fr/web/javascript/reference/global_objects/regexp/@@species/index.md index 3f4e6335e1149d..985c8c7dfb6bbe 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/@@species/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/@@species/index.md @@ -13,7 +13,7 @@ La propriété accesseur **`RegExp[@@species]`** renvoie le constructeur `RegExp ## Syntaxe ```js -RegExp[Symbol.species] +RegExp[Symbol.species]; ``` ## Description @@ -34,7 +34,9 @@ Pour les objets dérivés (par exemple, une classe `MaRegExp`), la valeur de `sp class MaRegExp extends RegExp { // On surcharge species pour renvoyer // le constructeur parent RegExp - static get [Symbol.species]() { return RegExp; } + static get [Symbol.species]() { + return RegExp; + } } ``` diff --git a/files/fr/web/javascript/reference/global_objects/regexp/@@split/index.md b/files/fr/web/javascript/reference/global_objects/regexp/@@split/index.md index d8fc8865b3d4e9..992d20ea61501c 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/@@split/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/@@split/index.md @@ -32,9 +32,9 @@ Un tableau ({{jsxref("Array")}}) dont les éléments sont les sous-chaînes de c Cette méthode est appelée de façon interne par la méthode {{jsxref("String.prototype.split()")}} lorsque l'argument `str` est un objet {{jsxref("RegExp")}}. Ainsi, les deux exemples qui suivent sont équivalents et le second est la version interne du premier : ```js -'a-b-c'.split(/-/); +"a-b-c".split(/-/); -/-/[Symbol.split]('a-b-c'); +/-/[Symbol.split]("a-b-c"); ``` Cette méthode existe afin de pouvoir adapter le fonctionnement de la découpe pour les sous-classes de `RegExp`. @@ -49,9 +49,9 @@ Cette méthode peut être utilisée comme {{jsxref("String.prototype.split()")}} ```js var re = /-/g; -var str = '2016-01-02'; +var str = "2016-01-02"; var résultat = re[Symbol.split](str); -console.log(résultat); // ["2016", "01", "02"] +console.log(résultat); // ["2016", "01", "02"] ``` ### Utiliser `@@split` avec une sous-classe @@ -62,12 +62,12 @@ Les sous-classes de {{jsxref("RegExp")}} peuvent surcharger `[@@split]()` afin d class MaRegExp extends RegExp { [Symbol.split](str, limit) { var résultat = RegExp.prototype[Symbol.split].call(this, str, limit); - return résultat.map(x => "(" + x + ")"); + return résultat.map((x) => "(" + x + ")"); } } -var re = new MaRegExp('-'); -var str = '2016-01-02'; +var re = new MaRegExp("-"); +var str = "2016-01-02"; var résultat = str.split(re); // String.prototype.split appelle re[@@split]. console.log(résultat); // ["(2016)", "(01)", "(02)"] ``` diff --git a/files/fr/web/javascript/reference/global_objects/regexp/compile/index.md b/files/fr/web/javascript/reference/global_objects/regexp/compile/index.md index eba924c7a18325..9b97a56e804df6 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/compile/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/compile/index.md @@ -11,7 +11,7 @@ La méthode dépréciée **`compile()`** est utilisée afin de (re)compiler une ## Syntaxe ```js -regexObj.compile(motif, flags) +regexObj.compile(motif, flags); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/regexp/exec/index.md b/files/fr/web/javascript/reference/global_objects/regexp/exec/index.md index f91669ec8195ef..8d328f705b2b37 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/exec/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/exec/index.md @@ -17,7 +17,7 @@ Les objets représentant des expressions rationnelles gardent un état en mémoi ## Syntaxe ```js -regexObj.exec(chaîne) +regexObj.exec(chaîne); ``` ### Paramètres @@ -39,8 +39,8 @@ Si on a l'exemple suivant : // On a une correspondance si on a "quick brown" suivi par "jumps", on ignore les caractères entre // On garde en mémoire "brown" et "jumps" // On ignore la casse -var re = /quick\s(brown).+?(jumps)/ig; -var result = re.exec('The Quick Brown Fox Jumps Over The Lazy Dog'); +var re = /quick\s(brown).+?(jumps)/gi; +var result = re.exec("The Quick Brown Fox Jumps Over The Lazy Dog"); ``` Le tableau suivant montre l'état résultant suite à ce script : @@ -136,11 +136,11 @@ Par exemple, si on utilise le fragment de code suivant : ```js var maRegex = /ab*/g; -var str = 'abbcdefabh'; +var str = "abbcdefabh"; var monTableau; while ((monTableau = maRegex.exec(str)) !== null) { - var msg = 'Trouvé ' + monTableau[0] + '. '; - msg += 'Prochaine correspondance à partir de ' + maRegex.lastIndex; + var msg = "Trouvé " + monTableau[0] + ". "; + msg += "Prochaine correspondance à partir de " + maRegex.lastIndex; console.log(msg); } ``` @@ -159,7 +159,7 @@ Trouvé ab. Prochaine correspondance à partir de 9 Il est aussi possible d'utiliser `exec()` sans créer d'objet {{jsxref("RegExp")}} explicite : ```js -var matches = /(coucou \S+)/.exec('Ceci est un coucou monde !'); +var matches = /(coucou \S+)/.exec("Ceci est un coucou monde !"); console.log(matches[1]); ``` diff --git a/files/fr/web/javascript/reference/global_objects/regexp/flags/index.md b/files/fr/web/javascript/reference/global_objects/regexp/flags/index.md index d596ac725258a7..da587d968fadc0 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/flags/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/flags/index.md @@ -19,19 +19,19 @@ Les drapeaux de la propriété `flags` sont rangés par ordre alphabétique de g ### Utiliser `flags` ```js -/toto/ig.flags; // "gi" -/truc/myu.flags; // "muy" +/toto/gi.flags; // "gi" +/truc/muy.flags; // "muy" ``` ## Prothèse d'émulation (_polyfill_) ```js if (RegExp.prototype.flags === undefined) { - Object.defineProperty(RegExp.prototype, 'flags', { + Object.defineProperty(RegExp.prototype, "flags", { configurable: true, - get: function() { + get: function () { return this.toString().match(/[gimuy]*$/)[0]; - } + }, }); } ``` diff --git a/files/fr/web/javascript/reference/global_objects/regexp/global/index.md b/files/fr/web/javascript/reference/global_objects/regexp/global/index.md index bc73bed7fdedcd..ae3cd24c6b2f9c 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/global/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/global/index.md @@ -23,15 +23,15 @@ var regex = new RegExp("toto", "g"); console.log(regex.global); // true -var str = 'totoexempletoto'; -var str1 = str.replace(regex, ''); +var str = "totoexempletoto"; +var str1 = str.replace(regex, ""); -console.log(str1); // affichera "exemple" dans la console +console.log(str1); // affichera "exemple" dans la console -var regex1 = new RegExp('toto'); -var str2 = str.replace(regex1, ''); +var regex1 = new RegExp("toto"); +var str2 = str.replace(regex1, ""); -console.log(str2); // affichera "exempletoto" dans la console +console.log(str2); // affichera "exempletoto" dans la console ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/regexp/hasindices/index.md b/files/fr/web/javascript/reference/global_objects/regexp/hasindices/index.md index 0235f0ad76c61a..0fd4949b5b0bae 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/hasindices/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/hasindices/index.md @@ -23,18 +23,18 @@ Cette propriété ne peut être modifiée directement. ### Utiliser `hasIndices` ```js -const str1 = 'toto truc toto'; +const str1 = "toto truc toto"; -const regex1 = new RegExp('toto', 'gd'); +const regex1 = new RegExp("toto", "gd"); console.log(regex1.hasIndices); // Affiche : true console.log(regex1.exec(str1).indices[0]); // Affiche : Array [0, 3] console.log(regex1.exec(str1).indices[0]); // Affiche : Array [8, 11] -const str2 = 'toto truc toto'; +const str2 = "toto truc toto"; -const regex2 = new RegExp('toto'); +const regex2 = new RegExp("toto"); console.log(regex2.hasIndices); // Affiche : false diff --git a/files/fr/web/javascript/reference/global_objects/regexp/index.md b/files/fr/web/javascript/reference/global_objects/regexp/index.md index 9a80928dfc30cd..655c1115f40bda 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/index.md @@ -22,9 +22,9 @@ Il existe deux façons de créer un objet `RegExp` : une _notation littéra Ainsi, les expressions suivantes créent le même objet d'expression rationnelle : ```js -/ab+c/i; // notation littérale -new RegExp('ab+c', 'i'); // constructeur -new RegExp(/ab+c/, 'i'); // notation littérale dans un constructeur +/ab+c/i; // notation littérale +new RegExp("ab+c", "i"); // constructeur +new RegExp(/ab+c/, "i"); // notation littérale dans un constructeur ``` La notation littérale effectue la compilation de l'expression rationnelle lorsque l'expression est évaluée. Utilisez la notation littérale lorsque l'expression rationnelle reste constante. Par exemple, si vous utilisez la notation littérale pour construire une expression rationnelle utilisée dans une boucle, l'expression rationnelle ne sera pas recompilée à chaque itération. @@ -41,7 +41,7 @@ Par exemple, les définitions suivantes sont équivalentes : ```js var re = /\w+/; -var re = new RegExp('\\w+'); +var re = new RegExp("\\w+"); ``` ### Propriétés semblables à Perl @@ -112,8 +112,8 @@ On utilise des parenthèses capturantes pour pouvoir utiliser les correspondance ```js let re = /(\w+)\s(\w+)/; -let chaine = 'Alain Dupont'; -let nouvelleChaine = chaine.replace(re, '$2, $1'); +let chaine = "Alain Dupont"; +let nouvelleChaine = chaine.replace(re, "$2, $1"); console.log(nouvelleChaine); // Dupont, Alain ``` @@ -123,7 +123,7 @@ console.log(nouvelleChaine); La fin de ligne par défaut dépend de la plateforme (Unix, Windows, etc.). Cette méthode de découpage fournie permet de découper indépendamment de la plateforme utilisée. ```js -let texte = 'Un texte\net un autre\r\npuis ensuite\rla fin'; +let texte = "Un texte\net un autre\r\npuis ensuite\rla fin"; let lignes = texte.split(/\r\n|\r|\n/); console.log(lignes); // affiche [ 'Un texte', 'et un autre', 'puis ensuite', 'la fin' ] ``` @@ -133,7 +133,7 @@ On notera que l'ordre des modèles dans l'expression rationnelle est important. ### Utiliser une expression rationnelle sur plusieurs lignes ```js -let s = 'Et voici\nune autre ligne !'; +let s = "Et voici\nune autre ligne !"; s.match(/voici.*ligne/); // Renvoie null @@ -147,7 +147,7 @@ s.match(/voici[^]*ligne/); Cet exemple illustre comment on peut utiliser le marqueur [`sticky`](/fr/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky) qui recherche une correspondance après [`RegExp.prototype.lastIndex`](/fr/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex). ```js -let str = '#toto#'; +let str = "#toto#"; let regex = /toto/y; regex.lastIndex = 1; @@ -163,7 +163,8 @@ Avec le marqueur d'adhérence `y`, la prochaine correspondance doit être placé ```js re = /\d/y; -while (r = re.exec("123 456")) console.log(r, "ET re.lastIndex", re.lastIndex); +while ((r = re.exec("123 456"))) + console.log(r, "ET re.lastIndex", re.lastIndex); // [ '1', index: 0, input: '123 456', groups: undefined ] ET re.lastIndex 1 // [ '2', index: 1, input: '123 456', groups: undefined ] ET re.lastIndex 2 @@ -182,15 +183,15 @@ Pour effectuer des correspondances sur d'autres caractères (par exemple les car Cet exemple illustre comment il est possible de séparer les caractères Unicode d'un mot. ```js -let texte = 'Образец text на русском языке'; +let texte = "Образец text на русском языке"; let regex = /[\u0400-\u04FF]+/g; let corresp = regex.exec(texte); -console.log(corresp[0]); // affiche 'Образец' +console.log(corresp[0]); // affiche 'Образец' console.log(regex.lastIndex); // affiche '7' let corresp2 = regex.exec(texte); -console.log(corresp2[0]); // affiche 'на' (n'affiche pas text +console.log(corresp2[0]); // affiche 'на' (n'affiche pas text console.log(regex.lastIndex); // affiche '15' // et ainsi de suite @@ -201,7 +202,7 @@ Les [échappements de propriété Unicode](/fr/docs/Web/JavaScript/Guide/Regular ### Extraire un sous-domaine d'une URL ```js -let url = 'http://xxx.domaine.com'; +let url = "http://xxx.domaine.com"; console.log(/[^.]+/.exec(url)[0].substr(7)); // affiche 'xxx' ``` @@ -221,12 +222,12 @@ console.log(/[^.]+/.exec(url)[0].substr(7)); // affiche 'xxx' ```js // Firefox 33 ou antérieur -'x'.replace(/x(.)?/g, function(m, group) { +"x".replace(/x(.)?/g, function (m, group) { console.log("'group:" + group + "'"); }); // 'group:' // Firefox 34 ou supérieur -'x'.replace(/x(.)?/g, function(m, group) { +"x".replace(/x(.)?/g, function (m, group) { console.log("'group:" + group + "'"); }); // 'group:undefined' ``` diff --git a/files/fr/web/javascript/reference/global_objects/regexp/input/index.md b/files/fr/web/javascript/reference/global_objects/regexp/input/index.md index d160e93c1f7eb7..148fc0dda853a2 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/input/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/input/index.md @@ -11,8 +11,8 @@ La propriété non-standard **`input`** est une propriété statique de l'expres ## Syntaxe ```js -RegExp.input -RegExp.$_ +RegExp.input; +RegExp.$_; ``` ## Description @@ -28,11 +28,11 @@ La valeur de la propriété **`input`** est modifiée à chaque fois que la cha ```js var re = /coucou/g; re.test("coucou toi !"); -RegExp.input; // "coucou toi !" -re.test("toto"); // nouveau test, pas de correspondance -RegExp.$_; // "coucou toi !" +RegExp.input; // "coucou toi !" +re.test("toto"); // nouveau test, pas de correspondance +RegExp.$_; // "coucou toi !" re.test("coucou monde !"); // nouveau test avec correspondance -RegExp.$_; // "coucou monde !" +RegExp.$_; // "coucou monde !" ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/regexp/lastindex/index.md b/files/fr/web/javascript/reference/global_objects/regexp/lastindex/index.md index 08010ed618baf4..3b6071ece2fc88 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/lastindex/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/lastindex/index.md @@ -13,7 +13,7 @@ La propriété **`lastIndex`** est un entier en lecture/écriture qui permet de ## Syntaxe ```js -regExpObj.lastIndex +regExpObj.lastIndex; ``` ## Description @@ -36,14 +36,14 @@ var re = /(hi)?/g; Correspond à la chaîne vide. ```js -console.log(re.exec('hi')); +console.log(re.exec("hi")); console.log(re.lastIndex); ``` Renvoie `["hi", "hi"]` avec `lastIndex` égal à 2. ```js -console.log(re.exec('hi')); +console.log(re.exec("hi")); console.log(re.lastIndex); ``` diff --git a/files/fr/web/javascript/reference/global_objects/regexp/lastmatch/index.md b/files/fr/web/javascript/reference/global_objects/regexp/lastmatch/index.md index cb9eb9cd93bae3..924d7afebad6b8 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/lastmatch/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/lastmatch/index.md @@ -11,8 +11,8 @@ La propriété non-standard **`lastMatch`** est une propriété statique en lect ## Syntaxe ```js -RegExp.lastMatch -RegExp['$&'] +RegExp.lastMatch; +RegExp["$&"]; ``` ## Description @@ -31,7 +31,7 @@ Il n'est pas possible d'utiliser l'alias avec la notation utilisant le point pou var re = /coucou/g; re.test("coucou toi!"); RegExp.lastMatch; // "coucou" -RegExp['$&']; // "coucou" +RegExp["$&"]; // "coucou" ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/regexp/lastparen/index.md b/files/fr/web/javascript/reference/global_objects/regexp/lastparen/index.md index ea89418fa711dc..60ee88f557f3cc 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/lastparen/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/lastparen/index.md @@ -11,8 +11,8 @@ La propriété **`lastParen`** est une propriété statique accessible en lectur ## Syntaxe ```js -RegExp.lastParen -RegExp['$+'] +RegExp.lastParen; +RegExp["$+"]; ``` ## Description @@ -31,7 +31,7 @@ Cet alias ne peut pas être utilisé avec la notation utilisant le point pour l' var re = /(coucou)/g; re.test("coucou toi !"); RegExp.lastParen; // "coucou" -RegExp['$+']; // "coucou" +RegExp["$+"]; // "coucou" ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/regexp/leftcontext/index.md b/files/fr/web/javascript/reference/global_objects/regexp/leftcontext/index.md index 32952cf3983d67..bd15aa0ec43cce 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/leftcontext/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/leftcontext/index.md @@ -11,13 +11,13 @@ La propriété non-standard **`leftContext`** est une propriété statique acces ## Syntaxe ```js -RegExp.leftContext -RegExp['$`'] +RegExp.leftContext; +RegExp["$`"]; ``` ## Description -La propriété `leftContext` est une propriété statique, elle n'est donc pas distincte entre les différents objets représentants les expressions rationnelles. Il faut donc toujours utiliser la syntaxe `RegExp.leftContext` ou `` RegExp['$`']. `` +La propriété `leftContext` est une propriété statique, elle n'est donc pas distincte entre les différents objets représentants les expressions rationnelles. Il faut donc toujours utiliser la syntaxe `RegExp.leftContext` ou ``RegExp['$`'].`` La valeur de la propriété `leftContext` n'est accessible uniquement qu'en lecture. Elle est modifiée par le moteur à chaque fois qu'une nouvelle correspondance est trouvée. @@ -29,7 +29,7 @@ L'alias ne peut pas être utilisé avec la notation utilisant le point (`` RegEx var re = /monde/g; re.test("coucou monde !"); RegExp.leftContext; // "coucou " -RegExp['$`']; // "coucou " +RegExp["$`"]; // "coucou " ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/regexp/n/index.md b/files/fr/web/javascript/reference/global_objects/regexp/n/index.md index 1dc5651d2bd88b..ebc619d6fab90c 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/n/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/n/index.md @@ -11,15 +11,15 @@ Les propriétés non-standard **$1, $2, $3, $4, $5, $6, $7, $8, $9** sont des pr ## Syntaxe ```js -RegExp.$1 -RegExp.$2 -RegExp.$3 -RegExp.$4 -RegExp.$5 -RegExp.$6 -RegExp.$7 -RegExp.$8 -RegExp.$9 +RegExp.$1; +RegExp.$2; +RegExp.$3; +RegExp.$4; +RegExp.$5; +RegExp.$6; +RegExp.$7; +RegExp.$8; +RegExp.$9; ``` ## Description @@ -38,8 +38,8 @@ Dans le script qui suit, on utilise {{jsxref("String.prototype.replace()", "repl ```js var re = /(\w+)\s(\w+)/; -var str = 'Jean Biche'; -str.replace(re, '$2, $1'); // "Biche, Jean" +var str = "Jean Biche"; +str.replace(re, "$2, $1"); // "Biche, Jean" RegExp.$1; // "Jean" RegExp.$2; // "Biche" ``` diff --git a/files/fr/web/javascript/reference/global_objects/regexp/regexp/index.md b/files/fr/web/javascript/reference/global_objects/regexp/regexp/index.md index 20d7e8599a1033..10fa30b8c2411a 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/regexp/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/regexp/index.md @@ -72,9 +72,9 @@ Il existe deux façons de créer un objet `RegExp` : en utilisant _une nota Les trois expressions suivantes permettent de créer la même expression rationnelle : ```js -/ab+c/i -new RegExp(/ab+c/, 'i') // Notation littérale -new RegExp('ab+c', 'i') // Constructeur +/ab+c/i; +new RegExp(/ab+c/, "i"); // Notation littérale +new RegExp("ab+c", "i"); // Constructeur ``` La notation littérale provoque la compilation de l'expression rationnelle lorsque l'expression est évaluée. On utilisera la notation littérale lorsque l'expression rationnelle demeure constante. Ainsi, si on utilise une notation littérale pour construire une expression rationnelle utilisée dans une boucle, l'expression rationnelle ne sera pas recompilée à chaque itération. diff --git a/files/fr/web/javascript/reference/global_objects/regexp/rightcontext/index.md b/files/fr/web/javascript/reference/global_objects/regexp/rightcontext/index.md index e4ea7eb8cc4f19..d3bc0d28104f5e 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/rightcontext/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/rightcontext/index.md @@ -11,8 +11,8 @@ La propriété non-standard **`rightContext`** est une propriété statique, acc ## Syntaxe ```js -RegExp.rightContext -RegExp["$'"] +RegExp.rightContext; +RegExp["$'"]; ``` ## Description @@ -29,7 +29,7 @@ L'alias ne peut pas être utilisé avec la syntaxe utilisant le point (`RegExp.$ var re = /coucou/g; re.test("coucou monde !"); RegExp.rightContext; // " monde !" -RegExp["$'"]; // " monde !" +RegExp["$'"]; // " monde !" ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/regexp/source/index.md b/files/fr/web/javascript/reference/global_objects/regexp/source/index.md index 225aafe7e6f8d7..0450f4eaa0b447 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/source/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/source/index.md @@ -15,7 +15,7 @@ La propriété **`source`** renvoie une chaîne de caractères qui contient le t ### Utiliser `source` ```js -var regex = /totoMachin/ig; +var regex = /totoMachin/gi; console.log(regex.source); // "totoMachin" ``` @@ -27,8 +27,8 @@ console.log(regex.source); // "totoMachin" ```js new RegExp().source; // "(?:)" -new RegExp('\n').source === "\n"; // true avant ES5 -new RegExp('\n').source === "\\n"; // true à partir d'ES5 +new RegExp("\n").source === "\n"; // true avant ES5 +new RegExp("\n").source === "\\n"; // true à partir d'ES5 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/regexp/sticky/index.md b/files/fr/web/javascript/reference/global_objects/regexp/sticky/index.md index 891f80d6e9aee5..947a7e4a53cf4f 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/sticky/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/sticky/index.md @@ -21,7 +21,7 @@ La propriété `sticky` ne peut pas être modifiée directement. Elle est unique ### Utiliser une expression rationnelle avec le _flag_ _sticky_ ```js -var str = '#toto#'; +var str = "#toto#"; var regex = /toto/y; regex.lastIndex = 1; diff --git a/files/fr/web/javascript/reference/global_objects/regexp/test/index.md b/files/fr/web/javascript/reference/global_objects/regexp/test/index.md index 621b4de42db176..b7d9c5526aae60 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/test/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/test/index.md @@ -13,7 +13,7 @@ La méthode **`test()`** vérifie s'il y a une correspondance entre un texte et ## Syntaxe ```js -regexObj.test(chaîne) +regexObj.test(chaîne); ``` ### Paramètres @@ -44,18 +44,18 @@ console.log(resultat); // true L'exemple ci-dessous affiche un message qui dépend du succès du test : ```js -function testinput(regex, chaine){ - var midstring; - if (regex.test(chaine)) { - midstring = " contient "; - } else { - midstring = " ne contient pas "; - } - console.log(str + midstring + re.source); +function testinput(regex, chaine) { + var midstring; + if (regex.test(chaine)) { + midstring = " contient "; + } else { + midstring = " ne contient pas "; + } + console.log(str + midstring + re.source); } testinput(/^coucou/, "coucou le monde"); // coucou le monde contient coucou -testinput(/^coucou/, "salut le monde") // salut le monde ne contient pas coucou +testinput(/^coucou/, "salut le monde"); // salut le monde ne contient pas coucou ``` ### Utiliser `test()` avec le marqueur global (`/g`) diff --git a/files/fr/web/javascript/reference/global_objects/regexp/tostring/index.md b/files/fr/web/javascript/reference/global_objects/regexp/tostring/index.md index 75dc047a6ae476..aa2e8664750d04 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/tostring/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/tostring/index.md @@ -32,10 +32,10 @@ L'exemple qui suit affiche la chaîne correspondant à la valeur de l'objet {{js ```js var maRegExp = new RegExp("a+b+c"); -console.log(maRegExp.toString()); // affiche "/a+b+c/" +console.log(maRegExp.toString()); // affiche "/a+b+c/" var toto = new RegExp("truc", "g"); -console.log(toto.toString()); // affiche "/truc/g" +console.log(toto.toString()); // affiche "/truc/g" ``` ### Les expressions ratonnelles vides et l'échappement @@ -45,8 +45,8 @@ console.log(toto.toString()); // affiche "/truc/g" ```js new RegExp().toString(); // "(?:)" -new RegExp('\n').toString() === "/\n/"; // true avant ES5 -new RegExp('\n').toString() === "/\\n/"; // true à partir d'ES5 +new RegExp("\n").toString() === "/\n/"; // true avant ES5 +new RegExp("\n").toString() === "/\\n/"; // true à partir d'ES5 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/regexp/unicode/index.md b/files/fr/web/javascript/reference/global_objects/regexp/unicode/index.md index a43fe41c9dbbeb..dce725d0279126 100644 --- a/files/fr/web/javascript/reference/global_objects/regexp/unicode/index.md +++ b/files/fr/web/javascript/reference/global_objects/regexp/unicode/index.md @@ -19,7 +19,7 @@ Cette propriété ne peut pas être modifiée directement. ## Exemples ```js -var regex = new RegExp('\u{61}', 'u'); +var regex = new RegExp("\u{61}", "u"); console.log(regex.unicode); // true ``` diff --git a/files/fr/web/javascript/reference/global_objects/set/@@iterator/index.md b/files/fr/web/javascript/reference/global_objects/set/@@iterator/index.md index 44f6a5d78e7f42..69e19ece30cbff 100644 --- a/files/fr/web/javascript/reference/global_objects/set/@@iterator/index.md +++ b/files/fr/web/javascript/reference/global_objects/set/@@iterator/index.md @@ -13,7 +13,7 @@ La valeur initiale de la propriété **`@@iterator`** est le même objet fonctio ## Syntaxe ```js -monSet[Symbol.iterator] +monSet[Symbol.iterator]; ``` ### Valeur de retour @@ -40,7 +40,7 @@ console.log(setIter.next().value); // {} ### Utiliser `[@@iterator]()` avec une boucle `for..of` ```js -const monSet= new Set(); +const monSet = new Set(); monSet.add("0"); monSet.add(1); monSet.add({}); diff --git a/files/fr/web/javascript/reference/global_objects/set/@@species/index.md b/files/fr/web/javascript/reference/global_objects/set/@@species/index.md index 08da15a15b9bb5..09a5f50814bcef 100644 --- a/files/fr/web/javascript/reference/global_objects/set/@@species/index.md +++ b/files/fr/web/javascript/reference/global_objects/set/@@species/index.md @@ -11,7 +11,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Set/@@species ## Syntaxe ```js -Set[Symbol.species] +Set[Symbol.species]; ``` ## Description diff --git a/files/fr/web/javascript/reference/global_objects/set/clear/index.md b/files/fr/web/javascript/reference/global_objects/set/clear/index.md index e5c4ce590e1627..11789a5dbe855f 100644 --- a/files/fr/web/javascript/reference/global_objects/set/clear/index.md +++ b/files/fr/web/javascript/reference/global_objects/set/clear/index.md @@ -27,13 +27,13 @@ var monSet = new Set(); monSet.add(1); monSet.add("toto"); -monSet.size; // 2 +monSet.size; // 2 monSet.has("toto"); // true monSet.clear(); -monSet.size; // 0 -monSet.has("truc") // false +monSet.size; // 0 +monSet.has("truc"); // false ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/set/delete/index.md b/files/fr/web/javascript/reference/global_objects/set/delete/index.md index e1088844a0f0fa..7028a9ab8d1762 100644 --- a/files/fr/web/javascript/reference/global_objects/set/delete/index.md +++ b/files/fr/web/javascript/reference/global_objects/set/delete/index.md @@ -36,20 +36,20 @@ monSet.add("toto"); monSet.delete("truc"); // Renvoie false. Aucun élément "truc" n'a pu être supprimé. monSet.delete("toto"); // Renvoie true. L'élément a pu être supprimé. -monSet.has("toto"); // Renvoie false. L'élément "toto" ne fait plus partie de l'ensemble. +monSet.has("toto"); // Renvoie false. L'élément "toto" ne fait plus partie de l'ensemble. ``` ### Utiliser `delete()` avec `forEach()` ```js var objetSet = new Set(); -objetSet.add({x: 10, y: 20}); // On ajoute un nouvel objet dans l'ensemble -objetSet.add({x: 20, y: 30}); // On ajoute un nouvel objet dans l'ensemble +objetSet.add({ x: 10, y: 20 }); // On ajoute un nouvel objet dans l'ensemble +objetSet.add({ x: 20, y: 30 }); // On ajoute un nouvel objet dans l'ensemble // On supprime les points de l'ensemble pour lesquels // x est supérieur à 10 -objetSet.forEach(function(point){ - if(point.x > 10){ +objetSet.forEach(function (point) { + if (point.x > 10) { objetSet.delete(point); } }); diff --git a/files/fr/web/javascript/reference/global_objects/set/entries/index.md b/files/fr/web/javascript/reference/global_objects/set/entries/index.md index 81d9fe9813aded..2b28b059099a31 100644 --- a/files/fr/web/javascript/reference/global_objects/set/entries/index.md +++ b/files/fr/web/javascript/reference/global_objects/set/entries/index.md @@ -13,7 +13,7 @@ La méthode **`entries()`** renvoie un nouvel objet [`Iterator`](/fr/docs/Web/Ja ## Syntaxe ```js -monSet.entries() +monSet.entries(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/set/foreach/index.md b/files/fr/web/javascript/reference/global_objects/set/foreach/index.md index 158be8a9367278..6ea7cd5c4b469e 100644 --- a/files/fr/web/javascript/reference/global_objects/set/foreach/index.md +++ b/files/fr/web/javascript/reference/global_objects/set/foreach/index.md @@ -58,7 +58,7 @@ Le code qui suit permet d'enregistrer une ligne pour chaque élément contenu da ```js function logSetElements(valeur1, valeur2, set) { - console.log("s[" + valeur1 + "] = " + valeur2); + console.log("s[" + valeur1 + "] = " + valeur2); } new Set(["toto", "truc", undefined]).forEach(logSetElements); diff --git a/files/fr/web/javascript/reference/global_objects/set/has/index.md b/files/fr/web/javascript/reference/global_objects/set/has/index.md index 2b8a0ccac847a5..7fff4bd113a3fc 100644 --- a/files/fr/web/javascript/reference/global_objects/set/has/index.md +++ b/files/fr/web/javascript/reference/global_objects/set/has/index.md @@ -33,16 +33,16 @@ Un booléen : `true` s'il existe un élément avec la valeur donnée au sein du var monSet = new Set(); monSet.add("toto"); -monSet.has("toto"); // renvoie true -monSet.has("truc"); // renvoie false +monSet.has("toto"); // renvoie true +monSet.has("truc"); // renvoie false var set1 = new Set(); -var obj1 = {'cle1': 1}; +var obj1 = { cle1: 1 }; set1.add(obj1); -set1.has(obj1); // renvoie true -set1.has({'cle1': 1}); // renvoie false car ce sont deux objets distincts -set1.add({'cle1': 1}); // set1 contient désormais 2 éléments +set1.has(obj1); // renvoie true +set1.has({ cle1: 1 }); // renvoie false car ce sont deux objets distincts +set1.add({ cle1: 1 }); // set1 contient désormais 2 éléments ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/set/index.md b/files/fr/web/javascript/reference/global_objects/set/index.md index 3886c06d586d17..7db4785c693810 100644 --- a/files/fr/web/javascript/reference/global_objects/set/index.md +++ b/files/fr/web/javascript/reference/global_objects/set/index.md @@ -57,6 +57,7 @@ Chaque valeur d'un `Set` doit être unique, il faut donc tester l'égalité des - [`Set.prototype.keys()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Set/values) - : Un alias pour [`Set.prototype.values()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Set/values). - [`Set.prototype.entries()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Set/entries) + - : Renvoie un nouvel objet itérateur qui contient **un tableau `[valeur, valeur]`** pour chaque élément de l'objet `Set`, selon leur ordre d'insertion. Il s'agit d'une méthode analogue à celle disponible pour [`Map`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Map), c'est pour ça qu'on a le doublonnement de la valeur à la place de la clé. @@ -71,29 +72,29 @@ Chaque valeur d'un `Set` doit être unique, il faut donc tester l'égalité des ```js const monSet = new Set(); -monSet.add(1); // { 1 } -monSet.add(5); // { 1, 5 } -monSet.add(5); // { 1, 5 } -monSet.add('du texte'); // { 1, 5, 'du texte' } +monSet.add(1); // { 1 } +monSet.add(5); // { 1, 5 } +monSet.add(5); // { 1, 5 } +monSet.add("du texte"); // { 1, 5, 'du texte' } -const o = {a: 1, b: 2}; +const o = { a: 1, b: 2 }; monSet.add(o); -monSet.add({a: 1, b: 2}); +monSet.add({ a: 1, b: 2 }); // o fait référence à un objet différent // il n'y a pas de problème pour cet ajout monSet.has(1); // true monSet.has(3); // false, 3 n'a pas été ajouté à l'ensemble -monSet.has(5); // true -monSet.has(Math.sqrt(25)); // true -monSet.has('Du Texte'.toLowerCase()); // true +monSet.has(5); // true +monSet.has(Math.sqrt(25)); // true +monSet.has("Du Texte".toLowerCase()); // true monSet.has(o); // true monSet.size; // 5 monSet.delete(5); // retire 5 du set -monSet.has(5); // false, 5 a été retiré de l'ensemble +monSet.has(5); // false, 5 a été retiré de l'ensemble monSet.size; // 4, on a retiré une valeur de l'ensemble console.log(monSet); @@ -119,11 +120,11 @@ for (let item of monSet.values()) console.log(item); for (let [clé, valeur] of monSet.entries()) console.log(clé); // Une méthode de conversion avec Array.from -const monTableau = Array.from(monSet); // [1, "du texte", {"a": 1, "b": 2}, {"a": 1, "b": 2}] +const monTableau = Array.from(monSet); // [1, "du texte", {"a": 1, "b": 2}, {"a": 1, "b": 2}] // Cela fonctionnera également dans un document HTML monSet.add(document.body); -monSet.has(document.querySelector('body')); // true +monSet.has(document.querySelector("body")); // true // convertir un tableau (Array) en ensemble (Set) et vice versa const monSet2 = new Set([1, 2, 3, 4]); @@ -131,13 +132,13 @@ monSet2.size; // 4 [...monSet2]; // [1, 2, 3, 4] // L'intersection peut être calculée avec -const intersection = new Set([...set1].filter(x => set2.has(x))); +const intersection = new Set([...set1].filter((x) => set2.has(x))); // La différence pourra être simulée avec -const différence = new Set([...set1].filter(x => !set2.has(x))); +const différence = new Set([...set1].filter((x) => !set2.has(x))); // On peut itérer sur les entrées d'un ensemble avec forEach -mySet.forEach(function(value) { +mySet.forEach(function (value) { console.log(value); }); @@ -202,11 +203,11 @@ const setA = new Set([1, 2, 3, 4]); const setB = new Set([2, 3]); const setC = new Set([3, 4, 5, 6]); -isSuperset(setA, setB); // => true -union(setA, setC); // => Set [1, 2, 3, 4, 5, 6] -intersection(setA, setC); // => Set [3, 4] +isSuperset(setA, setB); // => true +union(setA, setC); // => Set [1, 2, 3, 4, 5, 6] +intersection(setA, setC); // => Set [3, 4] symmetricDifference(setA, setC); // => Set {1, 2, 5, 6} -difference(setA, setC); // => Set [1, 2] +difference(setA, setC); // => Set [1, 2] ``` ### Relations avec les objets `Array` @@ -218,9 +219,9 @@ let monTableau = ["valeur1", "valeur2", "valeur3"]; // un Array en Set let monSet = new Set(monTableau); -monSet.has('valeur1'); // renvoie true +monSet.has("valeur1"); // renvoie true -// Et utiliser l'opérateur de décomposition pour +// Et utiliser l'opérateur de décomposition pour // transformer un Set en Array. console.log([...monSet]); // affichera la même chose que monTableau ``` @@ -228,7 +229,7 @@ console.log([...monSet]); // affichera la même chose que monTableau ### Dédoublonner un tableau ```js -const nombres = [2,3,4,4,2,2,2,4,4,5,5,6,6,7,5,32,3,4,5]; +const nombres = [2, 3, 4, 4, 2, 2, 2, 4, 4, 5, 5, 6, 6, 7, 5, 32, 3, 4, 5]; console.log([...new Set(nombres)]); @@ -238,7 +239,7 @@ console.log([...new Set(nombres)]); ### Les relations avec les objets `String` ```js -let texte = 'India'; +let texte = "India"; const monSet = new Set(texte); // Set(5) {'I', 'n', 'd', 'i', 'a'} @@ -247,21 +248,19 @@ monSet.size; // 5 // Sensibilité à la casse -new Set('Firefox'); +new Set("Firefox"); // Set(7) { "F", "i", "r", "e", "f", "o", "x" } -new Set('firefox'); +new Set("firefox"); // Set(6) { "f", "i", "r", "e", "o", "x" } ``` ### Utilisation de `Set` pour vérifier l'unicité des valeurs d'une liste ```js -const tableau = Array - .from(document.querySelectorAll('[id]')) - .map(function(e) { - return e.id; - }); +const tableau = Array.from(document.querySelectorAll("[id]")).map(function (e) { + return e.id; +}); const set = new Set(tableau); console.assert(set.size == tableau.length); diff --git a/files/fr/web/javascript/reference/global_objects/set/set/index.md b/files/fr/web/javascript/reference/global_objects/set/set/index.md index a416d94265d8e3..7c723f345810fe 100644 --- a/files/fr/web/javascript/reference/global_objects/set/set/index.md +++ b/files/fr/web/javascript/reference/global_objects/set/set/index.md @@ -13,8 +13,8 @@ Le **constructeur `Set()`** permet de créer des objets `Set` qui sont des ensem ## Syntaxe ```js -new Set() -new Set(iterable) +new Set(); +new Set(iterable); ``` ### Paramètres @@ -34,13 +34,13 @@ Un nouvel objet `Set`. ### Utiliser `Set()` ```js -let monSet = new Set() +let monSet = new Set(); -monSet.add(1); // Set [ 1 ] -monSet.add(5); // Set [ 1, 5 ] -monSet.add(5); // Set [ 1, 5 ] -monSet.add('du texte'); // Set [ 1, 5, 'du texte' ] -let o = {a: 1, b: 2}; +monSet.add(1); // Set [ 1 ] +monSet.add(5); // Set [ 1, 5 ] +monSet.add(5); // Set [ 1, 5 ] +monSet.add("du texte"); // Set [ 1, 5, 'du texte' ] +let o = { a: 1, b: 2 }; monSet.add(o); ``` diff --git a/files/fr/web/javascript/reference/global_objects/set/size/index.md b/files/fr/web/javascript/reference/global_objects/set/size/index.md index 8e3fc6ab55363e..58bf23973bc430 100644 --- a/files/fr/web/javascript/reference/global_objects/set/size/index.md +++ b/files/fr/web/javascript/reference/global_objects/set/size/index.md @@ -20,7 +20,7 @@ La valeur de `size` est un entier représentant le nombre d'éléments contenus var monSet = new Set(); monSet.add(1); monSet.add(5); -monSet.add("du texte") +monSet.add("du texte"); monSet.size; // 3 ``` diff --git a/files/fr/web/javascript/reference/global_objects/sharedarraybuffer/bytelength/index.md b/files/fr/web/javascript/reference/global_objects/sharedarraybuffer/bytelength/index.md index d0ad50c5bd0701..8b9c1248df000f 100644 --- a/files/fr/web/javascript/reference/global_objects/sharedarraybuffer/bytelength/index.md +++ b/files/fr/web/javascript/reference/global_objects/sharedarraybuffer/bytelength/index.md @@ -13,7 +13,7 @@ La propriété d'accesseur **`byteLength`** représente la longueur d'un {{jsxre ## Syntaxe ```js -sab.byteLength +sab.byteLength; ``` ## Description diff --git a/files/fr/web/javascript/reference/global_objects/sharedarraybuffer/index.md b/files/fr/web/javascript/reference/global_objects/sharedarraybuffer/index.md index 5916cc69a60d8c..bef9a0b17beba1 100644 --- a/files/fr/web/javascript/reference/global_objects/sharedarraybuffer/index.md +++ b/files/fr/web/javascript/reference/global_objects/sharedarraybuffer/index.md @@ -34,7 +34,7 @@ La mémoire partagée peut être créée et mise à jour de façon simultanée e ### Contraintes de sécurité -La mémoire partagée et les chronomètres de haute précision ont été [désactivés début 2018](https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/) suite à la vulnérabilité [Spectre](https://fr.wikipedia.org/wiki/Spectre_(vulnérabilité)). En 2020, une nouvelle approche, sécurisée, a été mise en place afin de réactiver la mémoire partagée. En suivant quelques règles de sécurité, [`postMessage()`](/fr/docs/Web/API/Window/postMessage) ne lève plus d'exception pour les objets `SharedArrayBuffer` et une mémoire partagée entre les threads est disponible. +La mémoire partagée et les chronomètres de haute précision ont été [désactivés début 2018](https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/) suite à la vulnérabilité [Spectre](). En 2020, une nouvelle approche, sécurisée, a été mise en place afin de réactiver la mémoire partagée. En suivant quelques règles de sécurité, [`postMessage()`](/fr/docs/Web/API/Window/postMessage) ne lève plus d'exception pour les objets `SharedArrayBuffer` et une mémoire partagée entre les threads est disponible. Pour commencer, le document doit être mis à disposition dans [un contexte sécurisé](/fr/docs/Web/Security/Secure_Contexts). @@ -100,17 +100,17 @@ let sab = new SharedArrayBuffer(1024); ### Découper un objet `SharedArrayBuffer` ```js -sab.slice(); // SharedArrayBuffer { byteLength: 1024 } -sab.slice(2); // SharedArrayBuffer { byteLength: 1022 } -sab.slice(-2); // SharedArrayBuffer { byteLength: 2 } +sab.slice(); // SharedArrayBuffer { byteLength: 1024 } +sab.slice(2); // SharedArrayBuffer { byteLength: 1022 } +sab.slice(-2); // SharedArrayBuffer { byteLength: 2 } sab.slice(0, 1); // SharedArrayBuffer { byteLength: 1 } ``` ### Utiliser un tampon WebGL ```js -const canvas = document.querySelector('canvas'); -const gl = canvas.getContext('webgl'); +const canvas = document.querySelector("canvas"); +const gl = canvas.getContext("webgl"); const buffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, buffer); gl.bufferData(gl.ARRAY_BUFFER, sab, gl.STATIC_DRAW); diff --git a/files/fr/web/javascript/reference/global_objects/sharedarraybuffer/sharedarraybuffer/index.md b/files/fr/web/javascript/reference/global_objects/sharedarraybuffer/sharedarraybuffer/index.md index 191095eb3ad628..1e6adff935bab3 100644 --- a/files/fr/web/javascript/reference/global_objects/sharedarraybuffer/sharedarraybuffer/index.md +++ b/files/fr/web/javascript/reference/global_objects/sharedarraybuffer/sharedarraybuffer/index.md @@ -15,8 +15,8 @@ Le **constructeur `SharedArrayBuffer()`** permet de créer un objet [`SharedArra ## Syntaxe ```js -new SharedArrayBuffer() -new SharedArrayBuffer(longueur) +new SharedArrayBuffer(); +new SharedArrayBuffer(longueur); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/sharedarraybuffer/slice/index.md b/files/fr/web/javascript/reference/global_objects/sharedarraybuffer/slice/index.md index 716f9f6560aa63..cd60e6cc102531 100644 --- a/files/fr/web/javascript/reference/global_objects/sharedarraybuffer/slice/index.md +++ b/files/fr/web/javascript/reference/global_objects/sharedarraybuffer/slice/index.md @@ -13,9 +13,9 @@ La méthode **`SharedArrayBuffer.prototype.slice()`** renvoie un nouvel objet {{ ## Syntaxe ```js -sab.slice() -sab.slice(début) -sab.slice(début, fin) +sab.slice(); +sab.slice(début); +sab.slice(début, fin); ``` ### Paramètres @@ -46,10 +46,10 @@ Un nouvel objet {{jsxref("SharedArrayBuffer")}} qui contient les éléments extr ```js var sab = new SharedArrayBuffer(1024); -sab.slice(); // SharedArrayBuffer { byteLength: 1024 } -sab.slice(2); // SharedArrayBuffer { byteLength: 1022 } -sab.slice(-2); // SharedArrayBuffer { byteLength: 2 } -sab.slice(0,1); // SharedArrayBuffer { byteLength: 1 } +sab.slice(); // SharedArrayBuffer { byteLength: 1024 } +sab.slice(2); // SharedArrayBuffer { byteLength: 1022 } +sab.slice(-2); // SharedArrayBuffer { byteLength: 2 } +sab.slice(0, 1); // SharedArrayBuffer { byteLength: 1 } ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/string/@@iterator/index.md b/files/fr/web/javascript/reference/global_objects/string/@@iterator/index.md index 452fe4b506a692..4c0fff69a0187a 100644 --- a/files/fr/web/javascript/reference/global_objects/string/@@iterator/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/@@iterator/index.md @@ -13,7 +13,7 @@ La méthode **`[@@iterator]()`** renvoie un nouvel objet [`Iterator`](/fr/docs/W ## Syntaxe ```js -chaîneDeCaractères[Symbol.iterator] +chaîneDeCaractères[Symbol.iterator]; ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/string/anchor/index.md b/files/fr/web/javascript/reference/global_objects/string/anchor/index.md index 47de9953e0f17a..1adc51ff722e27 100644 --- a/files/fr/web/javascript/reference/global_objects/string/anchor/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/anchor/index.md @@ -11,7 +11,7 @@ La méthode **`anchor()`** permet de créer une ancre HTML {{HTMLElement("a")}} ## Syntaxe ```js -str.anchor(name) +str.anchor(name); ``` ### Paramètres @@ -48,9 +48,9 @@ produira le code HTML suivant : ## Prothèse d'émulation (_polyfill_) ```js -if (!String.prototype.anchor){ - String.prototype.anchor = function(x){ - return '' + this + '' +if (!String.prototype.anchor) { + String.prototype.anchor = function (x) { + return '' + this + ""; }; } ``` diff --git a/files/fr/web/javascript/reference/global_objects/string/at/index.md b/files/fr/web/javascript/reference/global_objects/string/at/index.md index f4e2885f15b733..ac55266034cb58 100644 --- a/files/fr/web/javascript/reference/global_objects/string/at/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/at/index.md @@ -13,7 +13,7 @@ La méthode **`at()`** prend un entier en argument et renvoie une nouvelle chaî ## Syntaxe ```js -at(indice) +at(indice); ``` ### Paramètres @@ -37,12 +37,12 @@ function dernierCar(str) { return str.at(-1); } -let refFacture = 'maFacture01'; +let refFacture = "maFacture01"; console.log(dernierCar(refFacture)); // Affiche '1' dans la console -refFacture = 'maFacture02'; +refFacture = "maFacture02"; console.log(dernierCar(refFacture)); // Affiche '2' dans la console @@ -56,7 +56,7 @@ On compare ici différentes méthodes pour sélectionner l'avant-dernier caract const maChaine = "Vers l'infini et au-delà !"; // En utilisant la propriété length et la méthode charAt() -const avecLength = maChaine.charAt(maChaine.length-2); +const avecLength = maChaine.charAt(maChaine.length - 2); console.log(avecLength); // Affiche 'à' dans la console // En utilisant la méthode slice() diff --git a/files/fr/web/javascript/reference/global_objects/string/big/index.md b/files/fr/web/javascript/reference/global_objects/string/big/index.md index 4c0a63bac65167..9fc48c3d731a3c 100644 --- a/files/fr/web/javascript/reference/global_objects/string/big/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/big/index.md @@ -13,7 +13,7 @@ La méthode **`big()`** crée un élément HTML {{HTMLElement("big")}} qui affic ## Syntaxe ```js -str.big() +str.big(); ``` ### Valeur de retour @@ -32,15 +32,15 @@ L'exemple suivant montre les méthodes de `String` pour changer la taille d'une ```js var chaîneMonde = "Coucou monde"; -console.log( chaîneMonde.small() ); // Coucou monde -console.log( chaîneMonde.big() ); // Coucou monde -console.log( chaîneMonde.fontsize(7) ); // Coucou monde +console.log(chaîneMonde.small()); // Coucou monde +console.log(chaîneMonde.big()); // Coucou monde +console.log(chaîneMonde.fontsize(7)); // Coucou monde ``` Avec l'objet {{domxref("HTMLElement.style", "element.style")}}, il est possible d'accéder à l'attribut `style` de l'élément et de le manipuler. Par exemple : ```js -document.getElementById('idÉlément').style.fontSize = '2em' +document.getElementById("idÉlément").style.fontSize = "2em"; ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/string/blink/index.md b/files/fr/web/javascript/reference/global_objects/string/blink/index.md index 2aa641bea14950..938538f45bf107 100644 --- a/files/fr/web/javascript/reference/global_objects/string/blink/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/blink/index.md @@ -13,7 +13,7 @@ La méthode **`blink()`** crée un élément HTML {{HTMLElement("blink")}} qui a ## Syntaxe ```js -str.blink() +str.blink(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/string/bold/index.md b/files/fr/web/javascript/reference/global_objects/string/bold/index.md index a43dcc2ebe1edf..1e5e385e971e0a 100644 --- a/files/fr/web/javascript/reference/global_objects/string/bold/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/bold/index.md @@ -11,7 +11,7 @@ La méthode **`bold()`** crée un élément HTML {{HTMLElement("b")}} qui affich ## Syntaxe ```js -str.bold() +str.bold(); ``` ### Valeur de retour @@ -30,10 +30,10 @@ L'exemple suivant utilise des méthodes de `String` pour changer l'affichage de ```js var chaîneMonde = "Coucou monde"; -console.log( chaîneMonde.blink() ); -console.log( chaîneMonde.bold() ); -console.log( chaîneMonde.italics() ); -console.log( chaîneMonde.strike() ); +console.log(chaîneMonde.blink()); +console.log(chaîneMonde.bold()); +console.log(chaîneMonde.italics()); +console.log(chaîneMonde.strike()); ``` Cet exemple produit le même HTML que le code suivant : diff --git a/files/fr/web/javascript/reference/global_objects/string/charat/index.md b/files/fr/web/javascript/reference/global_objects/string/charat/index.md index e39e34a9c5803a..564aa1da272958 100644 --- a/files/fr/web/javascript/reference/global_objects/string/charat/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/charat/index.md @@ -13,7 +13,7 @@ La méthode **`charAt()`** renvoie une nouvelle chaîne contenant le caractère ## Syntaxe ```js -str.charAt(index) +str.charAt(index); ``` ### Paramètres @@ -38,11 +38,11 @@ L'exemple suivant affiche les caractères à différentes positions de la chaîn ```js var uneChaîne = "Coucou tout le monde"; -console.log("La caractère d'indice 0 est '" + uneChaîne.charAt(0) + "'"); -console.log("La caractère d'indice 1 est '" + uneChaîne.charAt(1) + "'"); -console.log("La caractère d'indice 2 est '" + uneChaîne.charAt(2) + "'"); -console.log("La caractère d'indice 3 est '" + uneChaîne.charAt(3) + "'"); -console.log("La caractère d'indice 4 est '" + uneChaîne.charAt(4) + "'"); +console.log("La caractère d'indice 0 est '" + uneChaîne.charAt(0) + "'"); +console.log("La caractère d'indice 1 est '" + uneChaîne.charAt(1) + "'"); +console.log("La caractère d'indice 2 est '" + uneChaîne.charAt(2) + "'"); +console.log("La caractère d'indice 3 est '" + uneChaîne.charAt(3) + "'"); +console.log("La caractère d'indice 4 est '" + uneChaîne.charAt(4) + "'"); console.log("La caractère d'indice 999 est '" + uneChaîne.charAt(999) + "'"); ``` @@ -115,8 +115,8 @@ function getWholeChar(str, i) { Dans un environnement ECMAScript 2016 qui permet d'utiliser l'affectation par décomposition, on peut obtenir une version plus succincte et flexible : ```js -var str = 'A\uD87E\uDC04Z'; // We could also use a non-BMP character directly -for (var i=0, chr; i < str.length; i++) { +var str = "A\uD87E\uDC04Z"; // We could also use a non-BMP character directly +for (var i = 0, chr; i < str.length; i++) { [chr, i] = getWholeCharAndI(str, i); // Adapt this line at the top of each loop, passing in the whole string and // the current iteration and returning an array with the individual character @@ -129,37 +129,37 @@ function getWholeCharAndI(str, i) { var code = str.charCodeAt(i); if (Number.isNaN(code)) { - return ''; // Position not found + return ""; // Position not found } - if (code < 0xD800 || code > 0xDFFF) { + if (code < 0xd800 || code > 0xdfff) { return [str.charAt(i), i]; // Normal character, keeping 'i' the same } // High surrogate (could change last hex to 0xDB7F to treat high private // surrogates as single characters) - if (0xD800 <= code && code <= 0xDBFF) { - if (str.length <= (i+1)) { - throw 'High surrogate without following low surrogate'; + if (0xd800 <= code && code <= 0xdbff) { + if (str.length <= i + 1) { + throw "High surrogate without following low surrogate"; } - var next = str.charCodeAt(i+1); - if (0xDC00 > next || next > 0xDFFF) { - throw 'High surrogate without following low surrogate'; - } - return [str.charAt(i)+str.charAt(i+1), i+1]; + var next = str.charCodeAt(i + 1); + if (0xdc00 > next || next > 0xdfff) { + throw "High surrogate without following low surrogate"; + } + return [str.charAt(i) + str.charAt(i + 1), i + 1]; } // Low surrogate (0xDC00 <= code && code <= 0xDFFF) if (i === 0) { - throw 'Low surrogate without preceding high surrogate'; + throw "Low surrogate without preceding high surrogate"; } - var prev = str.charCodeAt(i-1); + var prev = str.charCodeAt(i - 1); // (could change last hex to 0xDB7F to treat high private surrogates // as single characters) - if (0xD800 > prev || prev > 0xDBFF) { - throw 'Low surrogate without preceding high surrogate'; + if (0xd800 > prev || prev > 0xdbff) { + throw "Low surrogate without preceding high surrogate"; } // Return the next character instead (and increment) - return [str.charAt(i+1), i+1]; + return [str.charAt(i + 1), i + 1]; } ``` @@ -168,13 +168,13 @@ function getWholeCharAndI(str, i) { Si on souhaite récupérer les paires de codets des caractères hors du plan classique, on peut utiliser le code suivant : ```js -function fixedCharAt (str, idx) { - var ret = ''; - str += ''; +function fixedCharAt(str, idx) { + var ret = ""; + str += ""; var end = str.length; var surrogatePairs = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g; - while ((surrogatePairs.exec(str)) != null) { + while (surrogatePairs.exec(str) != null) { var li = surrogatePairs.lastIndex; if (li - 2 < idx) { idx++; @@ -184,14 +184,17 @@ function fixedCharAt (str, idx) { } if (idx >= end || idx < 0) { - return ''; + return ""; } ret += str.charAt(idx); - if (/[\uD800-\uDBFF]/.test(ret) && /[\uDC00-\uDFFF]/.test(str.charAt(idx+1))) { + if ( + /[\uD800-\uDBFF]/.test(ret) && + /[\uDC00-\uDFFF]/.test(str.charAt(idx + 1)) + ) { // On avance d'un puisque l'un des caractères fait partie de la paire - ret += str.charAt(idx+1); + ret += str.charAt(idx + 1); } return ret; } diff --git a/files/fr/web/javascript/reference/global_objects/string/charcodeat/index.md b/files/fr/web/javascript/reference/global_objects/string/charcodeat/index.md index 1a7581b48137ba..f54d43c3bcdab8 100644 --- a/files/fr/web/javascript/reference/global_objects/string/charcodeat/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/charcodeat/index.md @@ -15,7 +15,7 @@ Le codet UTF-16 renvoyé correspond au codet Unicode si le caractère peut être ## Syntaxe ```js -str.charCodeAt(indice) +str.charCodeAt(indice); ``` ### Paramètres @@ -44,7 +44,7 @@ Dans les anciennes versions (JavaScript 1.2 par exemple) la méthode `charCodeAt L'exemple suivant retourne 65, la valeur Unicode de A. ```js -"ABC".charCodeAt(0) // returns 65 +"ABC".charCodeAt(0); // returns 65 ``` ### Utiliser charCodeAt pour gérer les caractères hors du plan multilingue de base sans hypothèse sur leur présence @@ -52,71 +52,72 @@ L'exemple suivant retourne 65, la valeur Unicode de A. Cette fonction peut être utilisée dans des boucles ou autres dans les cas où on ne sait pas si des caractères représentés sur deux demi-codets (hors du plan BMP) existent avant la position indiquée. ```js -function fixedCharCodeAt (str, idx) { - // ex. fixedCharCodeAt ('\uD800\uDC00', 0); // 65536 - // ex. fixedCharCodeAt ('\uD800\uDC00', 1); // false - idx = idx || 0; - var code = str.charCodeAt(idx); - var hi, low; - - // On gère le demi-codet supérieur (la borne supérieure - // utilisée pourrait être 0xDB7F afin de traiter les - // paires surrogates privées comme des caractères uniques) - if (0xD800 <= code && code <= 0xDBFF) { - hi = code; - low = str.charCodeAt(idx+1); - if (isNaN(low)) { - throw "Le demi-codet supérieur n'est pas suivi "+ - "par un demi-codet inférieur dans fixedCharCodeAt()"; - } - return ((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000; +function fixedCharCodeAt(str, idx) { + // ex. fixedCharCodeAt ('\uD800\uDC00', 0); // 65536 + // ex. fixedCharCodeAt ('\uD800\uDC00', 1); // false + idx = idx || 0; + var code = str.charCodeAt(idx); + var hi, low; + + // On gère le demi-codet supérieur (la borne supérieure + // utilisée pourrait être 0xDB7F afin de traiter les + // paires surrogates privées comme des caractères uniques) + if (0xd800 <= code && code <= 0xdbff) { + hi = code; + low = str.charCodeAt(idx + 1); + if (isNaN(low)) { + throw ( + "Le demi-codet supérieur n'est pas suivi " + + "par un demi-codet inférieur dans fixedCharCodeAt()" + ); } - if (0xDC00 <= code && code <= 0xDFFF) { + return (hi - 0xd800) * 0x400 + (low - 0xdc00) + 0x10000; + } + if (0xdc00 <= code && code <= 0xdfff) { // Demi-codet inférieur - // On renvoie false pour permettre aux boucles - // car le cas a normalement déjà été géré avec - // l'étape précédente - return false; - } - return code; + // On renvoie false pour permettre aux boucles + // car le cas a normalement déjà été géré avec + // l'étape précédente + return false; + } + return code; } ``` ### Utiliser `charCodeAt()` pour gérer les caractères du plan multilingue de base (en sachant qu'ils sont présents) ```js -function knownCharCodeAt (str, idx) { - str += ''; - var code, - end = str.length; - - var surrogatePairs = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g; - while ((surrogatePairs.exec(str)) != null) { - var li = surrogatePairs.lastIndex; - if (li - 2 < idx) { - idx++; - } - else { - break; - } - } - - if (idx >= end || idx < 0) { - return NaN; - } - - code = str.charCodeAt(idx); - - var hi, low; - if (0xD800 <= code && code <= 0xDBFF) { - hi = code; - low = str.charCodeAt(idx+1); - // On prend un caractère de plus - // car on a deux demi-codets à récupérer - return ((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000; +function knownCharCodeAt(str, idx) { + str += ""; + var code, + end = str.length; + + var surrogatePairs = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g; + while (surrogatePairs.exec(str) != null) { + var li = surrogatePairs.lastIndex; + if (li - 2 < idx) { + idx++; + } else { + break; } - return code; + } + + if (idx >= end || idx < 0) { + return NaN; + } + + code = str.charCodeAt(idx); + + var hi, low; + if (0xd800 <= code && code <= 0xdbff) { + hi = code; + low = str.charCodeAt(idx + 1); + // On prend un caractère de plus + // car on a deux demi-codets à récupérer + return (hi - 0xd800) * 0x400 + (low - 0xdc00) + 0x10000; + } + return code; } ``` diff --git a/files/fr/web/javascript/reference/global_objects/string/codepointat/index.md b/files/fr/web/javascript/reference/global_objects/string/codepointat/index.md index 6c46f15ba3d2c2..e5ca6cccf6414c 100644 --- a/files/fr/web/javascript/reference/global_objects/string/codepointat/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/codepointat/index.md @@ -13,7 +13,7 @@ La méthode **`codePointAt()`** renvoie un entier positif qui correspond au code ## Syntaxe ```js -str.codePointAt(pos) +str.codePointAt(pos); ``` ### Paramètres @@ -32,10 +32,10 @@ S'il n'y a pas d'élément à la position donnée, la valeur renvoyée sera {{js ## Exemples ```js -'ABC'.codePointAt(1); // 66 -'\uD800\uDC00'.codePointAt(0); // 65536 +"ABC".codePointAt(1); // 66 +"\uD800\uDC00".codePointAt(0); // 65536 -'XYZ'.codePointAt(42); // undefined +"XYZ".codePointAt(42); // undefined ``` ## Prothèse d'émulation (_polyfill_) @@ -45,18 +45,18 @@ Le fragment de code suivant permet d'ajouter la méthode `codePointAt()` pour le ```js /*! https://mths.be/codepointat v0.2.0 by @mathias */ if (!String.prototype.codePointAt) { - (function() { - 'use strict'; // needed to support `apply`/`call` with `undefined`/`null` - var defineProperty = (function() { + (function () { + "use strict"; // needed to support `apply`/`call` with `undefined`/`null` + var defineProperty = (function () { // IE 8 only supports `Object.defineProperty` on DOM elements try { var object = {}; var $defineProperty = Object.defineProperty; var result = $defineProperty(object, object, object) && $defineProperty; - } catch(error) {} + } catch (error) {} return result; - }()); - var codePointAt = function(position) { + })(); + var codePointAt = function (position) { if (this == null) { throw TypeError(); } @@ -64,7 +64,8 @@ if (!String.prototype.codePointAt) { var size = string.length; // `ToInteger` var index = position ? Number(position) : 0; - if (index != index) { // better `isNaN` + if (index != index) { + // better `isNaN` index = 0; } // Account for out-of-bounds indices: @@ -74,28 +75,31 @@ if (!String.prototype.codePointAt) { // Get the first code unit var first = string.charCodeAt(index); var second; - if ( // check if it’s the start of a surrogate pair - first >= 0xD800 && first <= 0xDBFF && // high surrogate + if ( + // check if it’s the start of a surrogate pair + first >= 0xd800 && + first <= 0xdbff && // high surrogate size > index + 1 // there is a next code unit ) { second = string.charCodeAt(index + 1); - if (second >= 0xDC00 && second <= 0xDFFF) { // low surrogate + if (second >= 0xdc00 && second <= 0xdfff) { + // low surrogate // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae - return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + return (first - 0xd800) * 0x400 + second - 0xdc00 + 0x10000; } } return first; }; if (defineProperty) { - defineProperty(String.prototype, 'codePointAt', { - 'value': codePointAt, - 'configurable': true, - 'writable': true + defineProperty(String.prototype, "codePointAt", { + value: codePointAt, + configurable: true, + writable: true, }); } else { String.prototype.codePointAt = codePointAt; } - }()); + })(); } ``` diff --git a/files/fr/web/javascript/reference/global_objects/string/concat/index.md b/files/fr/web/javascript/reference/global_objects/string/concat/index.md index f271e7aeaccb2d..e8aca628a4948b 100644 --- a/files/fr/web/javascript/reference/global_objects/string/concat/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/concat/index.md @@ -39,11 +39,11 @@ console.log(coucou.concat("Tristan,", " bonne journée.")); /* Bonjour Tristan, bonne journée. */ -var salutation = ['Bonjour', ' ', 'Alfred', ' ', '!']; +var salutation = ["Bonjour", " ", "Alfred", " ", "!"]; "".concat(...salutation); // "Bonjour Alfred !" -"".concat({}); // [object Object] -"".concat([]); // "" +"".concat({}); // [object Object] +"".concat([]); // "" "".concat(null); // "null" "".concat(true); // "true" "".concat(4, 5); // "45" diff --git a/files/fr/web/javascript/reference/global_objects/string/endswith/index.md b/files/fr/web/javascript/reference/global_objects/string/endswith/index.md index ea5e9e67d53223..6e3e466bb325e4 100644 --- a/files/fr/web/javascript/reference/global_objects/string/endswith/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/endswith/index.md @@ -36,9 +36,9 @@ Cette méthode permet de savoir si une chaine de caractères se termine avec une ```js var str = "Être, ou ne pas être : telle est la question."; -console.log(str.endsWith("question.")); // true -console.log(str.endsWith("pas être")); // false -console.log(str.endsWith("pas être", 20)); // true +console.log(str.endsWith("question.")); // true +console.log(str.endsWith("pas être")); // false +console.log(str.endsWith("pas être", 20)); // true ``` ## Prothèse d'émulation (_polyfill_) @@ -47,9 +47,14 @@ Cette méthode a été ajoutée dans la spécification ECMAScript 6 et peut ne p ```js if (!String.prototype.endsWith) { - String.prototype.endsWith = function(searchString, position) { + String.prototype.endsWith = function (searchString, position) { var subjectString = this.toString(); - if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) { + if ( + typeof position !== "number" || + !isFinite(position) || + Math.floor(position) !== position || + position > subjectString.length + ) { position = subjectString.length; } position -= searchString.length; diff --git a/files/fr/web/javascript/reference/global_objects/string/fixed/index.md b/files/fr/web/javascript/reference/global_objects/string/fixed/index.md index 73c2d126862aed..90654d4c373bf1 100644 --- a/files/fr/web/javascript/reference/global_objects/string/fixed/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/fixed/index.md @@ -11,7 +11,7 @@ La méthode **`fixed()`** permet de créer un élément HTML {{HTMLElement("tt") ## Syntaxe ```js -str.fixed() +str.fixed(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/string/fontcolor/index.md b/files/fr/web/javascript/reference/global_objects/string/fontcolor/index.md index f869318b6c0799..5d1ad4d8919049 100644 --- a/files/fr/web/javascript/reference/global_objects/string/fontcolor/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/fontcolor/index.md @@ -13,7 +13,7 @@ La méthode **`fontcolor()`** permet de créer un élément {{HTMLElement("font" ## Syntaxe ```js -str.fontcolor(couleur) +str.fontcolor(couleur); ``` ### Paramètres @@ -36,17 +36,22 @@ L'exemple qui suit illustre comment utiliser la méthode `fontcolor()` pour modi ```js var worldString = "Coucou monde"; -console.log(worldString.fontcolor("red") + " avec le littéral red sur cette ligne"); +console.log( + worldString.fontcolor("red") + " avec le littéral red sur cette ligne", +); // 'Coucou monde avec le littéral red sur cette ligne' -console.log(worldString.fontcolor("FF00") + " avec la valeur hexadécimale sur cette ligne"); +console.log( + worldString.fontcolor("FF00") + + " avec la valeur hexadécimale sur cette ligne", +); // 'Coucou monde avec la valeur hexadécimale sur cette ligne' ``` L'objet {{domxref("HTMLElement.style", "element.style")}} permet d'utiliser l'attribut `style` de l'élément et de le manipuler de façon générique. Par exemple : ```js -document.getElementById('IDdeVotreElement').style.color = 'red' +document.getElementById("IDdeVotreElement").style.color = "red"; ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/string/fontsize/index.md b/files/fr/web/javascript/reference/global_objects/string/fontsize/index.md index de1f0e51ee3af3..6950ae973f7511 100644 --- a/files/fr/web/javascript/reference/global_objects/string/fontsize/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/fontsize/index.md @@ -13,7 +13,7 @@ La propriété **`fontsize()`** permet de créer un élément HTML {{HTMLElement ## Syntaxe ```js -str.fontsize(taille) +str.fontsize(taille); ``` ### Paramètres @@ -44,7 +44,7 @@ console.log(worldString.fontsize(7)); // Coucou monde L'objet {{domxref("HTMLElement.style", "element.style")}} permet d'utiliser l'attribut `style` de l'élément et de le manipuler de façon générique. Par exemple : ```js -document.getElementById('IdElement').style.fontSize = '0.7em' +document.getElementById("IdElement").style.fontSize = "0.7em"; ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/string/fromcharcode/index.md b/files/fr/web/javascript/reference/global_objects/string/fromcharcode/index.md index ff171a3c8d139d..16e87fa0683d42 100644 --- a/files/fr/web/javascript/reference/global_objects/string/fromcharcode/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/fromcharcode/index.md @@ -36,22 +36,22 @@ La méthode `fromCharCode()` étant une méthode statique de l'objet `String`, e Pour les caractères du plan multilingue de base, UTF-16 utilise une seule unité de code : ```js -String.fromCharCode(65,66,67); // ABC -String.fromCharCode(0x2014); // "—" -String.fromCharCode(0x12014); // "—" également, le 1 a été tronqué -String.fromCharCode(8212); // renvoie également "—" car 8212 - // est la forme décimale +String.fromCharCode(65, 66, 67); // ABC +String.fromCharCode(0x2014); // "—" +String.fromCharCode(0x12014); // "—" également, le 1 a été tronqué +String.fromCharCode(8212); // renvoie également "—" car 8212 +// est la forme décimale ``` Les caractères hors de ce plan utilisent deux unités de code (on parle de _surrogate pair_) : ```js -String.fromCharCode(0xD83C, 0xDF03); // Point de code U+1F303 pour l'émoji nuit étoilée +String.fromCharCode(0xd83c, 0xdf03); // Point de code U+1F303 pour l'émoji nuit étoilée // Forme décimale équivalente : String.fromCharCode(55356, 57091); -String.fromCharCode(0xD834, 0xDF06, 0x61, 0xD834, 0xDF07); +String.fromCharCode(0xd834, 0xdf06, 0x61, 0xd834, 0xdf07); // "\uD834\uDF06a\uD834\uDF07" ``` diff --git a/files/fr/web/javascript/reference/global_objects/string/fromcodepoint/index.md b/files/fr/web/javascript/reference/global_objects/string/fromcodepoint/index.md index dacac72917ce59..99b8bd614ac022 100644 --- a/files/fr/web/javascript/reference/global_objects/string/fromcodepoint/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/fromcodepoint/index.md @@ -38,19 +38,19 @@ Une chaîne de caractères créée à partir de la séquence de codets indiquée ### Utiliser `fromCodePoint()` ```js -String.fromCodePoint(42); // "*" -String.fromCodePoint(65, 90); // "AZ" -String.fromCodePoint(0x404); // "\u0404" -String.fromCodePoint(0x2F804); // "\uD87E\uDC04" -String.fromCodePoint(194564); // "\uD87E\uDC04" -String.fromCodePoint(0x1D306, 0x61, 0x1D307) // "\uD834\uDF06a\uD834\uDF07" - -String.fromCodePoint('_'); // RangeError +String.fromCodePoint(42); // "*" +String.fromCodePoint(65, 90); // "AZ" +String.fromCodePoint(0x404); // "\u0404" +String.fromCodePoint(0x2f804); // "\uD87E\uDC04" +String.fromCodePoint(194564); // "\uD87E\uDC04" +String.fromCodePoint(0x1d306, 0x61, 0x1d307); // "\uD834\uDF06a\uD834\uDF07" + +String.fromCodePoint("_"); // RangeError String.fromCodePoint(Infinity); // RangeError -String.fromCodePoint(-1); // RangeError -String.fromCodePoint(3.14); // RangeError -String.fromCodePoint(3e-2); // RangeError -String.fromCodePoint(NaN); // RangeError +String.fromCodePoint(-1); // RangeError +String.fromCodePoint(3.14); // RangeError +String.fromCodePoint(3e-2); // RangeError +String.fromCodePoint(NaN); // RangeError ``` ### Comparaison avec `fromCharCode()` @@ -58,14 +58,14 @@ String.fromCodePoint(NaN); // RangeError La méthode {{jsxref("String.fromCharCode()")}} ne peut pas renvoyer les caractères de l'intervalle 0x010000 à 0X10FFFF avec un seul codet, il est nécessaire de lui fournir la paire décomposée (_surrogate pair_) pour obtenr un tel caractère : ```js -String.fromCharCode(0xD83C, 0xDF03); // émoji « nuit étoilée » -String.fromCharCode(55356, 57091); // équivalent en notation décimale +String.fromCharCode(0xd83c, 0xdf03); // émoji « nuit étoilée » +String.fromCharCode(55356, 57091); // équivalent en notation décimale ``` `String.fromCodePoint()`, en revanche, peut renvoyer les caractères qui s'expriment sur plus d'un codet de 16 bits grâce à leur codet « simple » : ```js -String.fromCodePoint(0x1F303); // ou 127747 en notation décimale +String.fromCodePoint(0x1f303); // ou 127747 en notation décimale ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/string/includes/index.md b/files/fr/web/javascript/reference/global_objects/string/includes/index.md index 975d0e5ffb6c51..c78f19502166ec 100644 --- a/files/fr/web/javascript/reference/global_objects/string/includes/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/includes/index.md @@ -37,7 +37,7 @@ Cette méthode détermine si une chaîne de caractères est contenue dans une au `includes()` est sensible à la casse. Par exemple, l'expression suivante nous retournera `false` : ```js -'Baleine bleue'.includes('baleine'); // false +"Baleine bleue".includes("baleine"); // false ``` ## Exemples @@ -47,12 +47,12 @@ Cette méthode détermine si une chaîne de caractères est contenue dans une au ```js const str = "Être ou ne pas être, telle est la question."; -console.log(str.includes("Être")); // true -console.log(str.includes("question")); // true -console.log(str.includes("pléonasme")); // false -console.log(str.includes("Être", 1)); // false -console.log(str.includes("ÊTRE")); // false -console.log(str.includes("")); // true +console.log(str.includes("Être")); // true +console.log(str.includes("question")); // true +console.log(str.includes("pléonasme")); // false +console.log(str.includes("Être", 1)); // false +console.log(str.includes("ÊTRE")); // false +console.log(str.includes("")); // true ``` ## Prothèse d'émulation (_polyfill_) @@ -63,13 +63,15 @@ Cependant, vous pouvez facilement {{Glossary('polyfill')}} cette méthode pour d ```js if (!String.prototype.includes) { - String.prototype.includes = function(search, start) { - 'use strict'; + String.prototype.includes = function (search, start) { + "use strict"; if (search instanceof RegExp) { - throw TypeError('first argument must not be a RegExp'); + throw TypeError("first argument must not be a RegExp"); + } + if (start === undefined) { + start = 0; } - if (start === undefined) { start = 0; } return this.indexOf(search, start) !== -1; }; } diff --git a/files/fr/web/javascript/reference/global_objects/string/index.md b/files/fr/web/javascript/reference/global_objects/string/index.md index 25a131e70c0eb8..2627dc245992e3 100644 --- a/files/fr/web/javascript/reference/global_objects/string/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/index.md @@ -18,7 +18,7 @@ Il est possible de créer des chaînes de caractères comme des valeurs primitiv ```js const string1 = "Une chaîne de caractères primitive"; -const string2 = 'Là encore une valeur de chaîne de caractères primitive'; +const string2 = "Là encore une valeur de chaîne de caractères primitive"; const string3 = `Et ici aussi`; ``` @@ -35,13 +35,13 @@ Les valeurs littérales pour les chaînes de caractères peuvent être indiquée Il existe deux façons d'accéder à un caractère dans une chaîne. La première façon consiste à utiliser la méthode [`charAt()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/String/charAt) : ```js -return 'chat'.charAt(2); // renvoie "a" +return "chat".charAt(2); // renvoie "a" ``` La seconde méthode, introduite avec ECMAScript 5, est de manipuler la chaîne comme un tableau, où les caractères sont les éléments du tableau et ont un indice correspondant à leur position : ```js -return 'chat'[2]; // renvoie "a" +return "chat"[2]; // renvoie "a" ``` En utilisant la seconde notation, il est impossible de supprimer ou d'affecter une valeur à ces propriétés. En effet, les propriétés concernées ne sont ni accessibles en écriture ni configurables. Pour plus d'informations, voir la page de [`Object.defineProperty()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty). @@ -53,7 +53,8 @@ Les développeurs C utilisent la fonction `strcmp()` pour comparer des chaînes ```js let a = "a"; let b = "b"; -if (a < b) { // true +if (a < b) { + // true console.log(a + " est inférieure à " + b); } else if (a > b) { console.log(a + " est supérieure à " + b); @@ -68,7 +69,7 @@ On notera que `a == b` compare les chaînes de caractères `a` et `b` de façon ```js function isEqual(str1, str2) { - return str1.toUpperCase() === str2.toUpperCase() + return str1.toUpperCase() === str2.toUpperCase(); } ``` @@ -85,16 +86,16 @@ let s_prim = "toto"; let s_obj = new String(s_prim); console.log(typeof s_prim); // affiche "string" -console.log(typeof s_obj); // affiche "object" +console.log(typeof s_obj); // affiche "object" ``` Les chaînes primitives et les objets `String` renvoient des résultats différents lorsqu'ils sont évalués avec [`eval()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/eval). Les chaînes primitives sont traitées comme du code source, tandis que les objets `String` sont traités comme tous les autres objets, en renvoyant l'objet. Par exemple : ```js -let s1 = "2 + 2"; // crée une chaîne primitive -let s2 = new String("2 + 2"); // crée un objet String -console.log(eval(s1)); // renvoie le nombre 4 -console.log(eval(s2)); // renvoie la chaîne "2 + 2" +let s1 = "2 + 2"; // crée une chaîne primitive +let s2 = new String("2 + 2"); // crée un objet String +console.log(eval(s1)); // renvoie le nombre 4 +console.log(eval(s2)); // renvoie la chaîne "2 + 2" ``` Pour ces raisons, il peut y avoir certains problèmes quand le code attend une chaîne primitive plutôt qu'un objet `String`. Toutefois, cette distinction est rarement nécessaire en pratique. @@ -132,9 +133,10 @@ Il peut arriver que le code contienne des chaînes plutôt longues. Plutôt que #### Méthode 1 ```js -let chaineLongue = "Voici une très longue chaîne qui a besoin " + - " d'être passée à la ligne parce que sinon " + - " ça risque de devenir illisible."; +let chaineLongue = + "Voici une très longue chaîne qui a besoin " + + " d'être passée à la ligne parce que sinon " + + " ça risque de devenir illisible."; ``` #### Méthode 2 @@ -142,7 +144,8 @@ let chaineLongue = "Voici une très longue chaîne qui a besoin " + On peut sinon utiliser le caractère barre oblique inversée "\\" à la fin de chaque ligne pour indiquer que la chaîne continue sur la ligne suivante. Il faut bien faire attention à ce que la barre oblique soit bien le dernier caractère de la ligne avant le saut de ligne. Sinon, cela ne fonctionnera pas. Voilà comment se présente cette forme : ```js -let chaineLongue = "Voici une très longue chaîne qui a besoin \ +let chaineLongue = + "Voici une très longue chaîne qui a besoin \ d'être passée à la ligne parce que sinon \ ça risque de devenir illisible."; ``` @@ -294,7 +297,7 @@ d'être passée à la ligne parce que sinon Il est possible d'utiliser `String` comme une alternative à [`toString()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/String/toString) car cela permet de traiter les valeurs [`null`](/fr/docs/Web/JavaScript/Reference/Global_Objects/null), [`undefined`](/fr/docs/Web/JavaScript/Reference/Global_Objects/undefined) et les [symboles](/fr/docs/Web/JavaScript/Reference/Global_Objects/Symbol). Ainsi : ```js -let chainesSortie = [] +let chainesSortie = []; for (let i = 0, n = valeursEntree.length; i < n; ++i) { chainesSortie.push(String(valeursEntree[i])); } diff --git a/files/fr/web/javascript/reference/global_objects/string/indexof/index.md b/files/fr/web/javascript/reference/global_objects/string/indexof/index.md index aa9c5ae830e164..18b7f85c444515 100644 --- a/files/fr/web/javascript/reference/global_objects/string/indexof/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/indexof/index.md @@ -15,8 +15,8 @@ La méthode **`indexOf()`** renvoie l'indice de la première occurence de la val ## Syntaxe ```js -str.indexOf(valeurRecherchée) -str.indexOf(valeurRecherchée, indexDébut) +str.indexOf(valeurRecherchée); +str.indexOf(valeurRecherchée, indexDébut); ``` ### Paramètres @@ -35,14 +35,14 @@ L'indice de la première occurrence de la valeur indiquée, `-1` si elle n'est p Les caractères dans une chaîne de caractères sont indexés de la gauche à la droite. L'indice du premier caractère est 0, celui du dernier caractère (d'une chaîne `str`) est `str.length - 1.` ```js -"Blue Whale".indexOf("Blue"); // retourne 0 -"Blue Whale".indexOf("Blute"); // retourne -1 +"Blue Whale".indexOf("Blue"); // retourne 0 +"Blue Whale".indexOf("Blute"); // retourne -1 "Blue Whale".indexOf("Whale", 0); // retourne 5 "Blue Whale".indexOf("Whale", 5); // retourne 5 -"Blue Whale".indexOf(""); // retourne 0 -"Blue Whale".indexOf("", 9); // retourne 9 -"Blue Whale".indexOf("", 10); // retourne 10 -"Blue Whale".indexOf("", 11); // retourne 10 +"Blue Whale".indexOf(""); // retourne 0 +"Blue Whale".indexOf("", 9); // retourne 9 +"Blue Whale".indexOf("", 10); // retourne 10 +"Blue Whale".indexOf("", 11); // retourne 10 ``` ### Sensibilité à la casse @@ -50,7 +50,7 @@ Les caractères dans une chaîne de caractères sont indexés de la gauche à la La méthode `indexOf()` est sensible à la casse. Par exemple, l'expression suivante retourne -1 : ```js -"Blue Whale".indexOf("blue") // retourne -1 +"Blue Whale".indexOf("blue"); // retourne -1 ``` Attention : `0` n'est pas une valeur qui peut être évaluée à `true` et `-1` n'est pas une valeur qui peut être évaluée à `false`. Ainsi, si on souhaite tester si une chaîne de caractères existe au sein d'une autre chaîne de caractères, on procèdera de cette façon (ou on utilisera {{jsxref("String.prototype.includes()")}} @@ -67,7 +67,7 @@ Attention : `0` n'est pas une valeur qui peut être évaluée à `true` et `-1` L'exemple suivant utilise `indexOf()` et `lastIndexOf()` pour localiser différentes valeurs dans la chaîne de caractères "`Brave new world`". ```js -const uneChaîne = "Brave new world" +const uneChaîne = "Brave new world"; console.log("Indice du premier w " + uneChaîne.indexOf("w")); // Affiche 8 @@ -88,9 +88,12 @@ L'exemple suivant définit 2 chaînes de caractères. Ces variables contiennent const maChaîne = "brie, reblochon, cheddar"; const maChaîneMajuscules = "Brie, Reblochon, Cheddar"; -console.log('maChaîne.indexOf("cheddar") is '+ maChaîne.indexOf("cheddar")); +console.log('maChaîne.indexOf("cheddar") is ' + maChaîne.indexOf("cheddar")); // Affiche 19 -console.log('maChaîneMajuscules.indexOf("cheddar") is ' + maChaîneMajuscules.indexOf("cheddar")); +console.log( + 'maChaîneMajuscules.indexOf("cheddar") is ' + + maChaîneMajuscules.indexOf("cheddar"), +); // Affiche -1 ``` @@ -103,9 +106,9 @@ const str = "Chaîne x de test x"; let count = 0; let pos = str.indexOf("x"); -while ( pos != -1 ) { - count++; - pos = str.indexOf( "x",pos + 1 ); +while (pos != -1) { + count++; + pos = str.indexOf("x", pos + 1); } console.log(count); // Affiche 2 ``` diff --git a/files/fr/web/javascript/reference/global_objects/string/italics/index.md b/files/fr/web/javascript/reference/global_objects/string/italics/index.md index 0fc4cdeaefdc0c..2f4a9a03f19e35 100644 --- a/files/fr/web/javascript/reference/global_objects/string/italics/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/italics/index.md @@ -11,7 +11,7 @@ La méthode **`italics()`** permet de créer un élément HTML {{HTMLElement("i" ## Syntaxe ```js -str.italics() +str.italics(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/string/lastindexof/index.md b/files/fr/web/javascript/reference/global_objects/string/lastindexof/index.md index 089e606932985e..bb2968a328029e 100644 --- a/files/fr/web/javascript/reference/global_objects/string/lastindexof/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/lastindexof/index.md @@ -32,14 +32,14 @@ L'indice de la dernière occurrence de la valeur indiquée, `-1` si elle n'est p Les caractères d'une chaîne de caractères sont indexés de gauche à droite. L'indice du premier caractère vaut 0 et l'indice du dernier caractère vaut `maChaîne.length - 1`. ```js -'canal'.lastIndexOf('a'); // renvoie 3 -'canal'.lastIndexOf('a', 2); // renvoie 1 -'canal'.lastIndexOf('a', 0); // renvoie -1 -'canal'.lastIndexOf('x'); // renvoie -1 -'canal'.lastIndexOf('c', -5); // renvoie 0 -'canal'.lastIndexOf('c', 0); // renvoie 0 -'canal'.lastIndexOf(''); // renvoie 5 -'canal'.lastIndexOf('', 2); // renvoie 2 +"canal".lastIndexOf("a"); // renvoie 3 +"canal".lastIndexOf("a", 2); // renvoie 1 +"canal".lastIndexOf("a", 0); // renvoie -1 +"canal".lastIndexOf("x"); // renvoie -1 +"canal".lastIndexOf("c", -5); // renvoie 0 +"canal".lastIndexOf("c", 0); // renvoie 0 +"canal".lastIndexOf(""); // renvoie 5 +"canal".lastIndexOf("", 2); // renvoie 2 ``` > **Note :** `'abab'.lastIndexOf('ab', 2)` renvoie `2` et pas `0` car l'argument `indiceDébut` ne limite que le début de la correspondance recherchée ( qui est `'ab'`) @@ -49,7 +49,7 @@ Les caractères d'une chaîne de caractères sont indexés de gauche à droite. La méthode `lastIndexOf()` est sensible à la casse (une lettre en minuscule (i) est différente d'une lettre en majuscule (I)). Ainsi, le résultat de l'expression suivante sera -1 : ```js -'Blue Whale, Killer Whale'.lastIndexOf('blue'); // renvoie -1 +"Blue Whale, Killer Whale".lastIndexOf("blue"); // renvoie -1 ``` ## Exemples @@ -57,16 +57,16 @@ La méthode `lastIndexOf()` est sensible à la casse (une lettre en minuscule (i Dans l'exemple suivant, on utilise {{jsxref("String.prototype.indexOf()", "indexOf()")}} et `lastIndexOf()` pour situer certaines valeurs dans la chaîne `"Brave new world"`. ```js -var maChaîne = 'Brave new world'; +var maChaîne = "Brave new world"; -console.log('Indice du premier w ' + maChaîne.indexOf('w')); +console.log("Indice du premier w " + maChaîne.indexOf("w")); // Affiche 8 -console.log('Indice du dernier w ' + maChaîne.lastIndexOf('w')); +console.log("Indice du dernier w " + maChaîne.lastIndexOf("w")); // Affiche 10 -console.log('Indice du premier "new" ' + maChaîne.indexOf('new')); +console.log('Indice du premier "new" ' + maChaîne.indexOf("new")); // Affiche 6 -console.log('Indice du dernier "new" ' + maChaîne.lastIndexOf('new')); +console.log('Indice du dernier "new" ' + maChaîne.lastIndexOf("new")); // Affiche 6 ``` diff --git a/files/fr/web/javascript/reference/global_objects/string/length/index.md b/files/fr/web/javascript/reference/global_objects/string/length/index.md index dc89601ac698b9..8ddde4b043a3ac 100644 --- a/files/fr/web/javascript/reference/global_objects/string/length/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/length/index.md @@ -13,7 +13,7 @@ La propriété **`length`** représente la longueur d'une chaine de caractères, ## Syntaxe ```js -str.length +str.length; ``` ## Description diff --git a/files/fr/web/javascript/reference/global_objects/string/link/index.md b/files/fr/web/javascript/reference/global_objects/string/link/index.md index ab6447c810b6d1..377d7a48b343b1 100644 --- a/files/fr/web/javascript/reference/global_objects/string/link/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/link/index.md @@ -11,7 +11,7 @@ La méthode **`link()`** permet de créer une chaîne de caractères représenta ## Syntaxe ```js -str.link(url) +str.link(url); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/string/localecompare/index.md b/files/fr/web/javascript/reference/global_objects/string/localecompare/index.md index f18da81ea8a045..d94c6878af9c55 100644 --- a/files/fr/web/javascript/reference/global_objects/string/localecompare/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/localecompare/index.md @@ -15,14 +15,15 @@ Les arguments `locales` et `options` permettent de définir la locale et des opt ## Syntaxe ```js -localeCompare(chaineAComparer) -localeCompare(chaineAComparer, locales) -localeCompare(chaineAComparer, locales, options) +localeCompare(chaineAComparer); +localeCompare(chaineAComparer, locales); +localeCompare(chaineAComparer, locales, options); ``` ### Paramètres - `chaineAComparer` + - : La chaîne avec laquelle on souhaite comparer la chaîne de caractères courante. - `locales` et `options` @@ -77,8 +78,8 @@ L'exemple qui suit illustre les différents cas de figures lors de la comparaiso `localeCompare()` permet de trier un tableau sans tenir compte de la casse : ```js -var items = ['réservé', 'Premier', 'Cliché', 'communiqué', 'café', 'Adieu']; -items.sort((a, b) => a.localeCompare(b, 'fr', {ignorePunctuation: true})); +var items = ["réservé", "Premier", "Cliché", "communiqué", "café", "Adieu"]; +items.sort((a, b) => a.localeCompare(b, "fr", { ignorePunctuation: true })); // ['Adieu', 'café', 'Cliché', 'communiqué', 'Premier', 'réservé'] ``` @@ -91,9 +92,9 @@ Pour vérifier qu'une implémentation implémente ces paramètres, il est possib ```js function localeCompareSupportsLocales() { try { - 'toto'.localeCompare('truc', 'i'); + "toto".localeCompare("truc", "i"); } catch (e) { - return e.name === 'RangeError'; + return e.name === "RangeError"; } return false; } @@ -104,8 +105,8 @@ function localeCompareSupportsLocales() { Les résultats fournis par la méthode `localeCompare()` peuvent varier selon les locales utilisées. Pour spécifier la locale à utiliser pour votre application, utilisez l'argument `locales` (éventuellement en incluant des locales de recours) : ```js -console.log('ä'.localeCompare('z', 'de')); // une valeur négative : en allemand ä est avant z -console.log('ä'.localeCompare('z', 'sv')); // une valeur positive : en suédois, ä arrive après z +console.log("ä".localeCompare("z", "de")); // une valeur négative : en allemand ä est avant z +console.log("ä".localeCompare("z", "sv")); // une valeur positive : en suédois, ä arrive après z ``` ### Utiliser le paramètre `options` @@ -114,10 +115,10 @@ Les résultats construits par la méthode `localeCompare()` peuvent être adapt ```js // en allemand, ä et a ont la même lettre de base -console.log('ä'.localeCompare('a', 'de', {sensitivity: "base"})); // 0 +console.log("ä".localeCompare("a", "de", { sensitivity: "base" })); // 0 // en suédois, ä et a n'ont pas la même lettre de base -console.log('ä'.localeCompare('a', 'sv', {sensitivity: "base"})); // une valeur positive +console.log("ä".localeCompare("a", "sv", { sensitivity: "base" })); // une valeur positive ``` ### Tri numérique @@ -127,10 +128,10 @@ console.log('ä'.localeCompare('a', 'sv', {sensitivity: "base"})); // une valeur console.log("2".localeCompare("10")); // 1 // En utilisant un ordre numérique -console.log("2".localeCompare("10", undefined, {numeric: true})); // -1 +console.log("2".localeCompare("10", undefined, { numeric: true })); // -1 // En utilisant une balise de locale -console.log("2".localeCompare("10","en-u-kn-true")); // -1 +console.log("2".localeCompare("10", "en-u-kn-true")); // -1 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/string/match/index.md b/files/fr/web/javascript/reference/global_objects/string/match/index.md index 22377f2377c13b..9894bfbdeecf4c 100644 --- a/files/fr/web/javascript/reference/global_objects/string/match/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/match/index.md @@ -13,7 +13,7 @@ La méthode **`match()`** permet d'obtenir le tableau des correspondances entre ## Syntaxe ```js -str.match(regexp) +str.match(regexp); ``` ### Paramètres @@ -53,7 +53,7 @@ Si l'expression n'utilise pas le drapeau (_flag_) `g`, le résultat obtenu sera Dans l'exemple suivant, on utilise `match()` afin de trouver la chaîne `'Chapitre'` suivie par un ou plusieurs chiffres séparés par des points. L'expression utilisée active le drapeau `i` afin que la casse ne soit pas prise en compte. ```js -var str = 'Pour plus d\'informations, voir le chapitre 3.4.5.1'; +var str = "Pour plus d'informations, voir le chapitre 3.4.5.1"; var re = /(chapitre \d+(\.\d)*)/i; var trouvé = str.match(re); @@ -72,7 +72,7 @@ console.log(trouvé); Dans cet exemple, on illustre comment utiliser des drapeaux avec l'expression rationnelle qui est un argument de `match()`. Chaque lettre de A à E et de a à e est renvoyée, chacune dans un élément du tableau de résultat. ```js -var str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; +var str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; var regexp = /[A-E]/gi; var tableau_correspondances = str.match(regexp); @@ -86,11 +86,11 @@ Lorsque le paramètre passé à la fonction est une chaîne de caractères ou un ```js var str1 = "NaN signifie : qui n'est pas un nombre."; -var str2 = "Mon père a 65 ans." -str1.match("nombre"); // "nombre" est une chaîne, renvoie ["nombre"] -str1.match(NaN); // NaN est de type number, renvoie ["NaN"] -str2.match(65); // Renvoie ["65"] -str2.match(+65); // Renvoie également ["65"] +var str2 = "Mon père a 65 ans."; +str1.match("nombre"); // "nombre" est une chaîne, renvoie ["nombre"] +str1.match(NaN); // NaN est de type number, renvoie ["NaN"] +str2.match(65); // Renvoie ["65"] +str2.match(+65); // Renvoie également ["65"] ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/string/matchall/index.md b/files/fr/web/javascript/reference/global_objects/string/matchall/index.md index 5900da52fde15e..1c9df3b6216aa2 100644 --- a/files/fr/web/javascript/reference/global_objects/string/matchall/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/matchall/index.md @@ -13,7 +13,7 @@ La méthode **`matchAll()`** renvoie un itérateur contenant l'ensemble des corr ## Syntaxe ```js -str.matchAll(regexp) +str.matchAll(regexp); ``` ### Paramètres @@ -32,11 +32,13 @@ Un [itérateur](/fr/docs/Web/JavaScript/Guide/Iterators_and_Generators). Avant l'apparition de `matchAll()` en JavaScript, il était possible d'utiliser {{jsxref("RegExp.exec")}} (et des expressions rationnelles utilisant le marqueur `/g`) dans une boucle afin d'obtenir l'ensemble des correspondances : ```js -const regexp = RegExp('foo*','g'); -const str = 'table football, foosball'; +const regexp = RegExp("foo*", "g"); +const str = "table football, foosball"; while ((matches = regexp.exec(str)) !== null) { - console.log(`${matches[0]} trouvé. Prochaine recherche à partir de ${regexp.lastIndex}.`); + console.log( + `${matches[0]} trouvé. Prochaine recherche à partir de ${regexp.lastIndex}.`, + ); // dans la console : "foo trouvé. Prochaine recherche à partir de 9." // dans la console : "foo trouvé. Prochaine recherche à partir de 19." } @@ -45,8 +47,8 @@ while ((matches = regexp.exec(str)) !== null) { Avec `matchAll()`, on peut éviter la boucle `while` et le marqueur global. On récupère l'itérateur et on utilise une boucle [`for...of`](/fr/docs/Web/JavaScript/Reference/Instructions/for...of), [la décomposition de tableau](/fr/docs/Web/JavaScript/Reference/Opérateurs/Syntaxe_décomposition) ou encore {{jsxref("Array.from()")}} : ```js -const regexp = RegExp('foo*','g'); -const str = 'table football, foosball'; +const regexp = RegExp("foo*", "g"); +const str = "table football, foosball"; let matches = str.matchAll(regexp); for (const match of matches) { @@ -59,7 +61,7 @@ for (const match of matches) { // On rappelle matchAll afin de créer un nouvel itérateur matches = str.matchAll(regexp); -Array.from(matches, m => m[0]); +Array.from(matches, (m) => m[0]); // Array [ "foo", "foo" ] ``` @@ -69,7 +71,7 @@ Un autre avantage de `matchAll()` est un meilleur accès aux groupes capturants. ```js var regexp = /t(e)(st(\d?))/g; -var str = 'test1test2'; +var str = "test1test2"; str.match(regexp); // Array ['test1', 'test2'] diff --git a/files/fr/web/javascript/reference/global_objects/string/normalize/index.md b/files/fr/web/javascript/reference/global_objects/string/normalize/index.md index 62228d5cea2efe..2e928dd7bd6348 100644 --- a/files/fr/web/javascript/reference/global_objects/string/normalize/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/normalize/index.md @@ -49,7 +49,6 @@ La méthode `normalize()` renvoie la forme normalisée Unicode de la chaîne de // U+0323: COMBINING DOT BELOW var str = "\u1E9B\u0323"; - // Forme canonique composée (Canonically-composed form) (NFC) // U+1E9B: LATIN SMALL LETTER LONG S WITH DOT ABOVE @@ -57,7 +56,6 @@ var str = "\u1E9B\u0323"; str.normalize("NFC"); // "\u1E9B\u0323" str.normalize(); // la même chaîne que précédemment - // Forme canonique décomposée (Canonically-decomposed form) (NFD) // U+017F: LATIN SMALL LETTER LONG S @@ -65,13 +63,11 @@ str.normalize(); // la même chaîne que précédemment // U+0307: COMBINING DOT ABOVE str.normalize("NFD"); // "\u017F\u0323\u0307" - // Forme composée compatible (NFKC) // U+1E69: LATIN SMALL LETTER S WITH DOT BELOW AND DOT ABOVE str.normalize("NFKC"); // "\u1E69" - // Forme décomposée compatible (NFKD) // U+0073: LATIN SMALL LETTER S diff --git a/files/fr/web/javascript/reference/global_objects/string/padend/index.md b/files/fr/web/javascript/reference/global_objects/string/padend/index.md index 8a4dc3d1478643..a4cfc8cdb596fc 100644 --- a/files/fr/web/javascript/reference/global_objects/string/padend/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/padend/index.md @@ -30,10 +30,10 @@ Une chaîne de caractères ({{jsxref("String")}}) dont la longueur est celle ind ## Exemples ```js -'abc'.padEnd(10); // "abc " -'abc'.padEnd(10, "toto"); // "abctototot" -'abc'.padEnd(6,"123456"); // "abc123" -'abc'.padEnd(1); // "abc" +"abc".padEnd(10); // "abc " +"abc".padEnd(10, "toto"); // "abctototot" +"abc".padEnd(6, "123456"); // "abc123" +"abc".padEnd(1); // "abc" ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/string/padstart/index.md b/files/fr/web/javascript/reference/global_objects/string/padstart/index.md index 5adc6b65983579..b9cf9978aa013a 100644 --- a/files/fr/web/javascript/reference/global_objects/string/padstart/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/padstart/index.md @@ -30,11 +30,11 @@ Une chaîne de caractères ({{jsxref("String")}}) dont la longueur est celle ind ## Exemples ```js -'abc'.padStart(10); // " abc" -'abc'.padStart(10, "toto"); // "totototabc" -'abc'.padStart(6,"123465"); // "123abc" -'abc'.padStart(8, "0"); // "00000abc" -'abc'.padStart(1); // "abc" +"abc".padStart(10); // " abc" +"abc".padStart(10, "toto"); // "totototabc" +"abc".padStart(6, "123465"); // "123abc" +"abc".padStart(8, "0"); // "00000abc" +"abc".padStart(1); // "abc" ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/string/raw/index.md b/files/fr/web/javascript/reference/global_objects/string/raw/index.md index ce6d060803f135..a9c245e6515224 100644 --- a/files/fr/web/javascript/reference/global_objects/string/raw/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/raw/index.md @@ -13,9 +13,9 @@ La méthode statique **`String.raw()`** est une fonction d'étiquetage (_tag fun ## Syntaxe ```js -String.raw(callSite, ...substitutions) +String.raw(callSite, ...substitutions); -String.raw`gabaritChaîne` +String.raw`gabaritChaîne`; ``` ### Paramètres @@ -45,7 +45,7 @@ La méthode `String.raw()` est la seule méthode d'étiquetage native pour les c ## Exemples ```js -String.raw`Hi\n${2+3}!`; +String.raw`Hi\n${2 + 3}!`; // "Hi\n5!", le caractère après "Hi" n'est pas // le caractère de nouvelle ligne // "\" et "n" sont bien deux caractères distincts @@ -66,7 +66,7 @@ String.raw`Hi\n${nom}!`; // Généralement, on n'appelle pas String.raw // comme une fonction, mais c'est possible : -String.raw({raw: "test"}, 0, 1, 2); +String.raw({ raw: "test" }, 0, 1, 2); // "t0e1s2t" ``` diff --git a/files/fr/web/javascript/reference/global_objects/string/repeat/index.md b/files/fr/web/javascript/reference/global_objects/string/repeat/index.md index f95f06af52d0e4..4e14cee9564dad 100644 --- a/files/fr/web/javascript/reference/global_objects/string/repeat/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/repeat/index.md @@ -13,7 +13,7 @@ La méthode **`repeat()`** construit et renvoie une nouvelle chaine de caractèr ## Syntaxe ```js -str.repeat(compte) +str.repeat(compte); ``` ### Paramètres @@ -38,14 +38,19 @@ Une nouvelle chaîne de caractères composée du nombre indiqué de copies de la ## Exemples ```js -"abc".repeat(-1) // RangeError -"abc".repeat(0) // "" -"abc".repeat(1) // "abc" -"abc".repeat(2) // "abcabc" -"abc".repeat(3.5) // "abcabcabc" (le compteur est converti en un nombre entier) -"abc".repeat(1/0) // RangeError - -({toString : () => "abc", repeat : String.prototype.repeat}).repeat(2) +"abc".repeat(-1); // RangeError +"abc".repeat(0); // "" +"abc".repeat(1); // "abc" +"abc".repeat(2); // "abcabc" +"abc".repeat(3.5); // "abcabcabc" (le compteur est converti en un nombre entier) +"abc" + .repeat(1 / 0) + ( + // RangeError + + { toString: () => "abc", repeat: String.prototype.repeat }, + ) + .repeat(2); // "abcabc" (repeat() est une méthode générique) ``` diff --git a/files/fr/web/javascript/reference/global_objects/string/replace/index.md b/files/fr/web/javascript/reference/global_objects/string/replace/index.md index 59ae32c73ee0a6..21ee14e662c4c3 100644 --- a/files/fr/web/javascript/reference/global_objects/string/replace/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/replace/index.md @@ -15,7 +15,7 @@ La chaîne de caractère originale reste inchangée. ## Syntaxe ```js -chn.replace(regexp|souschn, nouvSouschn|fonction) +chn.replace(regexp | souschn, nouvSouschn | fonction); ``` ### Paramètres @@ -143,9 +143,12 @@ L'exemple suivant affectera `'abc - 12345 - #$*%'` à la variable `nouvelleChain ```js function remplaceur(correspondance, p1, p2, p3, decalage, chaine) { // p1 est non numérique, p2 numérique, et p3 non-alphanumérique - return [p1, p2, p3].join(' - '); + return [p1, p2, p3].join(" - "); } -var nouvelleChaine = 'abc12345#$*%'.replace(/([^\d]*)(\d*)([^\w]*)/, remplaceur); +var nouvelleChaine = "abc12345#$*%".replace( + /([^\d]*)(\d*)([^\w]*)/, + remplaceur, +); console.log(nouvelleChaine); // abc - 12345 - #$*% ``` @@ -156,8 +159,8 @@ console.log(nouvelleChaine); // abc - 12345 - #$*% Dans l'exemple suivant, l'expression régulière est définie dans `replace()` et inclut l'indicateur d'indifférence à la casse. ```js -var chn = 'Twas the night before Xmas...'; -var nouvChn = chn.replace(/xmas/i, 'Christmas'); +var chn = "Twas the night before Xmas..."; +var nouvChn = chn.replace(/xmas/i, "Christmas"); console.log(nouvChn); // Twas the night before Christmas... ``` @@ -171,8 +174,8 @@ Le remplacement global ne peut être fait qu'avec une expression régulière. Da ```js var re = /pommes/gi; -var chn = 'Les pommes sont rondes, et les pommes sont juteuses.'; -var nouvChn = chn.replace(re, 'oranges'); +var chn = "Les pommes sont rondes, et les pommes sont juteuses."; +var nouvChn = chn.replace(re, "oranges"); console.log(nouvChn); // Les oranges sont rondes, et les oranges sont juteuses. ``` @@ -184,7 +187,7 @@ Le script suivant intervertit les mots dans la chaîne de caractères. Pour le t ```js var re = /(\w+)\s(\w+)/; -var chn = 'Jean Martin'; +var chn = "Jean Martin"; var nouvChn = chn.replace(re, "$2, $1"); console.log(nouvChn); // Martin, Jean ``` @@ -200,7 +203,7 @@ La fonction de remplacement accepte le fragment en correspondance comme paramèt ```js function styleFormatTiret(nomPropriete) { function majusculesEnTiretMinuscules(correspondance, decalage, chaine) { - return (decalage > 0 ? '-' : '') + correspondance.toLowerCase(); + return (decalage > 0 ? "-" : "") + correspondance.toLowerCase(); } return nomPropriete.replace(/[A-Z]/g, majusculesEnTiretMinuscules); } @@ -211,7 +214,7 @@ Avec `styleFormatTiret('borderTop')`, cela renvoie 'border-top'. Du fait que nous voulons transformer davantage le résultat de la correspondance avant la substitution finale, nous devons utiliser une fonction. Cela force l'évaluation de la correspondance avant la méthode {{jsxref ("String.prototype.toLowerCase()", "toLowerCase()")}}. Si nous avions essayé de le faire en utilisant la correspondance sans fonction, le {{jsxref ("String.prototype.toLowerCase()", "toLowerCase()")}} n'aurait eu aucun effet. ```js -var nouvChn = nomPropriete.replace(/[A-Z]/g, '-' + '$&'.toLowerCase()); // ne fonctionne pas +var nouvChn = nomPropriete.replace(/[A-Z]/g, "-" + "$&".toLowerCase()); // ne fonctionne pas ``` Ceci est dû au fait que `'$&'.toLowerCase()` serait d'abord évalué comme un littéral de chaîne (résultant en le même `'$&'`) avant d'utiliser les caractères comme modèle. @@ -225,7 +228,7 @@ L'expression régulière `test` vérifie tout nombre se terminant par F. Le nomb ```js function f2c(x) { function convertir(chn, p1, decalage, s) { - return ((p1-32) * 5/9) + 'C'; + return ((p1 - 32) * 5) / 9 + "C"; } var s = String(x); var test = /(-?\d+(?:\.\d*)?)F\b/g; @@ -241,7 +244,7 @@ L'exemple suivant accepte un modèle chaîne et le convertit en un tableau d'obj Une chaîne de caractères composée des caractères `x`, `-` et `_` -```js +```plain x-x_ x---x---x---x--- @@ -251,7 +254,7 @@ x_x_x___x___x___ **Sortie :**Un tableau d'objets. Un `'x'` dénote un état `'marche'`, un `'-'` symbolise un état '`arret`' et un `'_'` (blanc souligné) symbolise la longueur d'un état `'marche'`. -```json +```js [ { marche: true, longueur: 1 }, { marche: false, longueur: 1 }, @@ -263,11 +266,11 @@ x_x_x___x___x___ **Fragment :** ```js -var chn = 'x-x_'; +var chn = "x-x_"; var tabRet = []; -chn.replace(/(x_*)|(-)/g, function(correspondance, $1, $2){ - if($1) tabRet.push({ marche: true, longueur: $1.length }); - if($2) tabRet.push({ marche: false, longueur: 1 }); +chn.replace(/(x_*)|(-)/g, function (correspondance, $1, $2) { + if ($1) tabRet.push({ marche: true, longueur: $1.length }); + if ($2) tabRet.push({ marche: false, longueur: 1 }); }); console.log(tabRet); diff --git a/files/fr/web/javascript/reference/global_objects/string/replaceall/index.md b/files/fr/web/javascript/reference/global_objects/string/replaceall/index.md index 0ea4d226b50e9d..297900b5f75894 100644 --- a/files/fr/web/javascript/reference/global_objects/string/replaceall/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/replaceall/index.md @@ -112,7 +112,7 @@ Le nombre d'arguments exact dépend du premier argument de `replaceAll()` : si c ### Utiliser replaceAll() ```js -'aabbcc'.replaceAll('b', '.'); +"aabbcc".replaceAll("b", "."); // 'aa..cc' ``` @@ -128,8 +128,8 @@ TypeError: replaceAll must be called with a global RegExp L'exemple suivant, utilisant le marqueur `g`, fonctionnera : ```js example-good -'aabbcc'.replaceAll(/b/g, '.'); -"aa..cc" +"aabbcc".replaceAll(/b/g, "."); +("aa..cc"); ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/string/search/index.md b/files/fr/web/javascript/reference/global_objects/string/search/index.md index 26c3940b8c986b..83222587624838 100644 --- a/files/fr/web/javascript/reference/global_objects/string/search/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/search/index.md @@ -13,7 +13,7 @@ La méthode **`search()`** éxecute une recherche dans une chaine de caractères ## Syntaxe ```js -str.search(regexp) +str.search(regexp); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/string/slice/index.md b/files/fr/web/javascript/reference/global_objects/string/slice/index.md index 0ee0886fb67f5e..db649bc739f644 100644 --- a/files/fr/web/javascript/reference/global_objects/string/slice/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/slice/index.md @@ -42,11 +42,11 @@ Par exemple, `chn.slice(2, -1)` extrait du troisième caractère jusqu'à l'avan L'exemple suivant utilise `slice()` pour créer une nouvelle chaîne de caractères. ```js -var chn1 = 'Le matin est sur nous.', // la longueur de chn1 est de 22 - chn2 = chn1.slice(1, 8), - chn3 = chn1.slice(3, -2), - chn4 = chn1.slice(13), - chn5 = chn1.slice(30); +var chn1 = "Le matin est sur nous.", // la longueur de chn1 est de 22 + chn2 = chn1.slice(1, 8), + chn3 = chn1.slice(3, -2), + chn4 = chn1.slice(13), + chn5 = chn1.slice(30); console.log(chn2); // SORTIE : e matin console.log(chn3); // SORTIE : matin est sur nou console.log(chn4); // SORTIE : sur nous. @@ -58,10 +58,10 @@ console.log(chn5); // SORTIE : "" L'exemple suivant utilise `slice()` avec des indices négatifs. ```js -var chn = 'Le matin est sur nous.'; -chn.slice(-3); // retourne "us." +var chn = "Le matin est sur nous."; +chn.slice(-3); // retourne "us." chn.slice(-3, -1); // retourne "us" -chn.slice(0, -1); // retourne "Le matin est sur nous" +chn.slice(0, -1); // retourne "Le matin est sur nous" ``` Dans l'exemple qui suit, on commence à chercher l'indice de début à partir de la fin de la chaîne avec l'argument `-11` et on utilise un indice de fin positif avec `16` : diff --git a/files/fr/web/javascript/reference/global_objects/string/small/index.md b/files/fr/web/javascript/reference/global_objects/string/small/index.md index f5d16dfd285e40..aeca3046f5cc0c 100644 --- a/files/fr/web/javascript/reference/global_objects/string/small/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/small/index.md @@ -11,7 +11,7 @@ La méthode **`small()`** permet de créer un élément HTML {{HTMLElement("smal ## Syntaxe ```js -str.small() +str.small(); ``` ### Valeur de retour @@ -32,15 +32,15 @@ L'exemple suivant illustre les différentes méthodes de `String` permettant de ```js var worldString = "Coucou monde"; -console.log(worldString.small()); // Coucou monde -console.log(worldString.big()); // Coucou monde +console.log(worldString.small()); // Coucou monde +console.log(worldString.big()); // Coucou monde console.log(worldString.fontsize(7)); // Coucou monde ``` L'objet {{domxref("HTMLElement.style", "element.style")}} permet d'utiliser l'attribut `style` de l'élément et de le manipuler de façon générique. Par exemple : ```js -document.getElementById('IDélément').style.fontSize = '0.7em' +document.getElementById("IDélément").style.fontSize = "0.7em"; ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/string/split/index.md b/files/fr/web/javascript/reference/global_objects/string/split/index.md index 357d43232ddf4c..8c5bb11e86ef12 100644 --- a/files/fr/web/javascript/reference/global_objects/string/split/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/split/index.md @@ -56,10 +56,10 @@ Si le séparateur est un tableau, alors ce tableau est converti en une chaîne d Lorsque la chaîne de caractères est vide, `split()` retourne un tableau contenant une chaîne de caractères vide, plutôt qu'un tableau vide. Si la chaîne et le séparateur sont tous deux des chaînes vides, un tableau vide est retourné. ```js -const myString = '' -const splits = myString.split() +const myString = ""; +const splits = myString.split(); -console.log(splits) +console.log(splits); // ↪ [""] ``` @@ -72,7 +72,10 @@ function splitString(stringToSplit, separator) { console.log(`La chaine d'origine est : ${stringToSplit}`); console.log(`Le délimiteur est : ${separator}`); - console.log(`Le tableau comporte ${arrayOfStrings.length} elements : `, arrayOfStrings.join(' / ')); + console.log( + `Le tableau comporte ${arrayOfStrings.length} elements : `, + arrayOfStrings.join(" / "), + ); } var tempestString = "Oh brave new world that has such people in it."; @@ -138,7 +141,7 @@ console.log(splits); Ce script affichera : ```js -["Hello", "World.", "How"] +["Hello", "World.", "How"]; ``` ### Découper une expression rationnelle - Parenthèses capturantes @@ -155,7 +158,7 @@ console.log(splits); Ce script affichera : ```js -[ "Hello ", "1", " word. Sentence number ", "2", "." ] +["Hello ", "1", " word. Sentence number ", "2", "."]; ``` > **Note :** `\d` correspond à la [classe de caractères](/fr/docs/Web/JavaScript/Guide/Regular_Expressions/Character_Classes) pour les chiffres compris entre 0 et 9. @@ -165,8 +168,8 @@ Ce script affichera : > **Attention :** Ce n'est pas une façon robuste d'inverser une chaîne : > > ```js example-bad -> const str = 'asdfghjkl' -> const strReverse = str.split('').reverse().join('') +> const str = "asdfghjkl"; +> const strReverse = str.split("").reverse().join(""); > // 'lkjhgfdsa' > > // split() retourne un tableau sur lequel reverse() et join() peuvent être appliqués. @@ -175,8 +178,8 @@ Ce script affichera : > Cela ne fonctionne pas si la chaîne de caractères contient des groupes de graphèmes, même en utilisant une division sensible aux unicodes. (Utilisez, par exemple, [esrever](https://github.com/mathiasbynens/esrever) à la place). > > ```js example-bad -> const str = 'résumé' -> const strReverse = str.split(/(?:)/u).reverse().join('') +> const str = "résumé"; +> const strReverse = str.split(/(?:)/u).reverse().join(""); > // => "́emuśer" > ``` > diff --git a/files/fr/web/javascript/reference/global_objects/string/startswith/index.md b/files/fr/web/javascript/reference/global_objects/string/startswith/index.md index bf9da05e741c36..cee082815a52c5 100644 --- a/files/fr/web/javascript/reference/global_objects/string/startswith/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/startswith/index.md @@ -36,8 +36,8 @@ Cette méthode permet de savoir si une chaine de caractères commence avec une a ```js var str = "Être, ou ne pas être : telle est la question."; -console.log(str.startsWith("Être")); // true -console.log(str.startsWith("pas être")); // false +console.log(str.startsWith("Être")); // true +console.log(str.startsWith("pas être")); // false console.log(str.startsWith("pas être", 12)); // true ``` diff --git a/files/fr/web/javascript/reference/global_objects/string/strike/index.md b/files/fr/web/javascript/reference/global_objects/string/strike/index.md index 2b3def1b6ee29a..ff46454dcc2563 100644 --- a/files/fr/web/javascript/reference/global_objects/string/strike/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/strike/index.md @@ -11,7 +11,7 @@ La méthode **`strike()`** permet de créer un élément HTML {{HTMLElement("str ## Syntaxe ```js -str.strike() +str.strike(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/string/string/index.md b/files/fr/web/javascript/reference/global_objects/string/string/index.md index 9afb06910f0d64..9f3d7a01e07c17 100644 --- a/files/fr/web/javascript/reference/global_objects/string/string/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/string/index.md @@ -11,8 +11,8 @@ Le constructeur **`String`** est utilisé afin de créer un nouvel objet [`Strin ## Syntaxe ```js -new String(truc) -String(truc) +new String(truc); +String(truc); ``` ### Paramètres @@ -27,8 +27,8 @@ String(truc) Selon qu'on utilise `String()` comme une fonction ou comme un constructeur, cela produira différents résultats : ```js -typeof String('Coucou monde'); // string -typeof new String('Coucou monde'); // object +typeof String("Coucou monde"); // string +typeof new String("Coucou monde"); // object ``` Ici, la fonction produit une chaîne de caractères (une valeur primitive). Toutefois, le constructeur produit une instance objet de `String`. From 670eb49c0564a679f94b7b2921db0b7875ccd981 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 01:48:22 -0700 Subject: [PATCH 13/30] fr: Format /web/javascript using Prettier (part 9) (#14648) --- .../global_objects/string/sub/index.md | 2 +- .../global_objects/string/substr/index.md | 34 +++-- .../global_objects/string/substring/index.md | 31 ++-- .../global_objects/string/sup/index.md | 2 +- .../string/tolocaleuppercase/index.md | 4 +- .../string/tolowercase/index.md | 4 +- .../global_objects/string/tostring/index.md | 2 +- .../string/touppercase/index.md | 10 +- .../global_objects/string/trim/index.md | 8 +- .../global_objects/string/trimend/index.md | 4 +- .../global_objects/string/trimstart/index.md | 2 +- .../global_objects/string/valueof/index.md | 2 +- .../symbol/asynciterator/index.md | 22 +-- .../symbol/description/index.md | 18 +-- .../reference/global_objects/symbol/index.md | 36 ++--- .../symbol/isconcatspreadable/index.md | 12 +- .../global_objects/symbol/iterator/index.md | 10 +- .../global_objects/symbol/match/index.md | 2 +- .../global_objects/symbol/matchall/index.md | 4 +- .../global_objects/symbol/species/index.md | 10 +- .../global_objects/symbol/symbol/index.md | 16 +- .../symbol/toprimitive/index.md | 6 +- .../global_objects/symbol/tostring/index.md | 8 +- .../symbol/tostringtag/index.md | 14 +- .../symbol/unscopables/index.md | 8 +- .../global_objects/syntaxerror/index.md | 28 ++-- .../syntaxerror/syntaxerror/index.md | 24 +-- .../typedarray/@@iterator/index.md | 2 +- .../typedarray/@@species/index.md | 10 +- .../global_objects/typedarray/at/index.md | 4 +- .../global_objects/typedarray/buffer/index.md | 2 +- .../typedarray/bytelength/index.md | 2 +- .../typedarray/byteoffset/index.md | 2 +- .../typedarray/bytes_per_element/index.md | 16 +- .../typedarray/copywithin/index.md | 4 +- .../typedarray/entries/index.md | 2 +- .../global_objects/typedarray/every/index.md | 6 +- .../global_objects/typedarray/fill/index.md | 8 +- .../global_objects/typedarray/filter/index.md | 2 +- .../typedarray/foreach/index.md | 2 +- .../global_objects/typedarray/from/index.md | 7 +- .../typedarray/includes/index.md | 8 +- .../global_objects/typedarray/index.md | 36 ++--- .../typedarray/indexof/index.md | 6 +- .../global_objects/typedarray/join/index.md | 14 +- .../global_objects/typedarray/keys/index.md | 2 +- .../typedarray/lastindexof/index.md | 10 +- .../global_objects/typedarray/length/index.md | 2 +- .../global_objects/typedarray/map/index.md | 2 +- .../global_objects/typedarray/of/index.md | 6 +- .../global_objects/typedarray/reduce/index.md | 2 +- .../typedarray/reduceright/index.md | 10 +- .../global_objects/typedarray/slice/index.md | 16 +- .../global_objects/typedarray/some/index.md | 10 +- .../global_objects/typedarray/sort/index.md | 2 +- .../typedarray/subarray/index.md | 6 +- .../typedarray/tolocalestring/index.md | 10 +- .../typedarray/tostring/index.md | 6 +- .../global_objects/typedarray/values/index.md | 2 +- .../global_objects/typeerror/index.md | 30 ++-- .../typeerror/typeerror/index.md | 38 ++--- .../global_objects/uint16array/index.md | 6 +- .../uint16array/uint16array/index.md | 6 +- .../global_objects/uint32array/index.md | 6 +- .../uint32array/uint32array/index.md | 6 +- .../global_objects/uint8array/index.md | 14 +- .../uint8array/uint8array/index.md | 6 +- .../global_objects/uint8clampedarray/index.md | 14 +- .../uint8clampedarray/index.md | 6 +- .../global_objects/undefined/index.md | 40 ++--- .../global_objects/unescape/index.md | 8 +- .../global_objects/urierror/index.md | 32 ++-- .../global_objects/urierror/urierror/index.md | 40 ++--- .../global_objects/weakmap/delete/index.md | 2 +- .../global_objects/weakmap/get/index.md | 2 +- .../global_objects/weakmap/has/index.md | 2 +- .../reference/global_objects/weakmap/index.md | 28 ++-- .../global_objects/weakmap/weakmap/index.md | 8 +- .../global_objects/weakref/deref/index.md | 2 +- .../reference/global_objects/weakref/index.md | 2 +- .../global_objects/weakset/delete/index.md | 4 +- .../global_objects/weakset/has/index.md | 4 +- .../reference/global_objects/weakset/index.md | 27 ++-- .../global_objects/weakset/weakset/index.md | 12 +- .../reference/iteration_protocols/index.md | 144 ++++++++++-------- .../reference/lexical_grammar/index.md | 94 ++++++------ .../reference/operators/addition/index.md | 14 +- .../operators/addition_assignment/index.md | 10 +- .../reference/operators/assignment/index.md | 2 +- .../operators/async_function/index.md | 19 +-- .../operators/async_function_star_/index.md | 4 +- .../reference/operators/await/index.md | 14 +- .../reference/operators/bitwise_and/index.md | 4 +- .../operators/bitwise_and_assignment/index.md | 4 +- .../reference/operators/bitwise_not/index.md | 8 +- .../reference/operators/bitwise_or/index.md | 6 +- .../operators/bitwise_or_assignment/index.md | 4 +- .../reference/operators/bitwise_xor/index.md | 6 +- .../operators/bitwise_xor_assignment/index.md | 12 +- .../reference/operators/class/index.md | 8 +- 100 files changed, 637 insertions(+), 603 deletions(-) diff --git a/files/fr/web/javascript/reference/global_objects/string/sub/index.md b/files/fr/web/javascript/reference/global_objects/string/sub/index.md index 13776e8b62cd36..0a9fe7ec388335 100644 --- a/files/fr/web/javascript/reference/global_objects/string/sub/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/sub/index.md @@ -11,7 +11,7 @@ La méthode **`sub()`** crée un élément HTML {{HTMLElement("sub")}} qui entra ## Syntaxe ```js -str.sub() +str.sub(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/string/substr/index.md b/files/fr/web/javascript/reference/global_objects/string/substr/index.md index cab2bb413039f0..ac989da252aa07 100644 --- a/files/fr/web/javascript/reference/global_objects/string/substr/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/substr/index.md @@ -50,16 +50,16 @@ Pour `début` comme pour `longueur`, NaN est traité comme 0. ## Exemples ```js -var uneChaine = 'Mozilla'; - -console.log(uneChaine.substr(0, 1)); // 'M' -console.log(uneChaine.substr(1, 0)); // '' -console.log(uneChaine.substr(-1, 1)); // 'a' -console.log(uneChaine.substr(1, -1)); // '' -console.log(uneChaine.substr(-3)); // 'lla' -console.log(uneChaine.substr(1)); // 'ozilla' +var uneChaine = "Mozilla"; + +console.log(uneChaine.substr(0, 1)); // 'M' +console.log(uneChaine.substr(1, 0)); // '' +console.log(uneChaine.substr(-1, 1)); // 'a' +console.log(uneChaine.substr(1, -1)); // '' +console.log(uneChaine.substr(-3)); // 'lla' +console.log(uneChaine.substr(1)); // 'ozilla' console.log(uneChaine.substr(-20, 2)); // 'Mo' -console.log(uneChaine.substr(20, 2)); // '' +console.log(uneChaine.substr(20, 2)); // '' ``` ## Prothèse d'émulation (_polyfill_) @@ -68,23 +68,25 @@ JScript de Microsoft ne supporte pas les valeurs négatives pour l'indice de dé ```js // N'appliquer que lorsque la fonction est incomplète -if ('ab'.substr(-1) != 'b') { +if ("ab".substr(-1) != "b") { /** * Obtenir la sous-chaîne d'une chaîne * @param {entier} début où démarrer la sous-chaîne * @param {entier} longueur combien de caractères à retourner * @return {chaîne} */ - String.prototype.substr = function(substr) { - return function(début, longueur) { + String.prototype.substr = (function (substr) { + return function (début, longueur) { // Appel de la méthode originale - return substr.call(this, + return substr.call( + this, // Si on a un début négatif, calculer combien il vaut à partir du début de la chaîne // Ajuster le paramètre pour une valeur négative début < 0 ? this.length + début : début, - longueur) - } - }(String.prototype.substr); + longueur, + ); + }; + })(String.prototype.substr); } ``` diff --git a/files/fr/web/javascript/reference/global_objects/string/substring/index.md b/files/fr/web/javascript/reference/global_objects/string/substring/index.md index 8225320be57d88..057be67f544df6 100644 --- a/files/fr/web/javascript/reference/global_objects/string/substring/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/substring/index.md @@ -48,20 +48,20 @@ Les exemples suivants utilisent la méthode `substring()` pour extraire et affic var uneChaîne = "Mozilla"; // Affiche "Moz" -console.log(uneChaîne.substring(0,3)); -console.log(uneChaîne.substring(3,0)); +console.log(uneChaîne.substring(0, 3)); +console.log(uneChaîne.substring(3, 0)); // Affiche "lla" -console.log(uneChaîne.substring(4,7)); +console.log(uneChaîne.substring(4, 7)); console.log(uneChaîne.substring(4)); -console.log(uneChaîne.substring(7,4)); +console.log(uneChaîne.substring(7, 4)); // Affiche "Mozill" -console.log(uneChaîne.substring(0,6)); +console.log(uneChaîne.substring(0, 6)); // Affiche "Mozilla" -console.log(uneChaîne.substring(0,7)); -console.log(uneChaîne.substring(0,10)); +console.log(uneChaîne.substring(0, 7)); +console.log(uneChaîne.substring(0, 10)); ``` ### Remplacer une sous-chaîne dans une chaîne @@ -70,10 +70,13 @@ L'exemple suivant remplace une partie d'une chaine. Elle remplace à la fois les ```js function replaceString(oldS, newS, fullS) { -// On remplace oldS avec newS dans fullS + // On remplace oldS avec newS dans fullS for (var i = 0; i < fullS.length; i++) { if (fullS.substring(i, i + oldS.length) == oldS) { - fullS = fullS.substring(0, i) + newS + fullS.substring(i + oldS.length, fullS.length); + fullS = + fullS.substring(0, i) + + newS + + fullS.substring(i + oldS.length, fullS.length); } } return fullS; @@ -85,7 +88,7 @@ replaceString("World", "Web", "Brave New World"); Attention : ceci peut résulter en une boucle infinie si `oldS` est elle-même une sous-chaine de `newS` — par exemple, si on essaie de remplacer "World" par "OtherWorld". Une meilleure solution serait de remplacer les chaines de cette manière : ```js -function replaceString(oldS, newS,fullS){ +function replaceString(oldS, newS, fullS) { return fullS.split(oldS).join(newS); } ``` @@ -100,8 +103,8 @@ Les arguments de la méthode `substring()` représentent les indices de début e ```js var texte = "Mozilla"; -console.log(texte.substring(2,5)); // => "zil" -console.log(texte.substr(2,3)); // => "zil" +console.log(texte.substring(2, 5)); // => "zil" +console.log(texte.substr(2, 3)); // => "zil" ``` ### Différences entre `substring()` et `slice()` @@ -111,9 +114,9 @@ Les méthodes `substring()` et {{jsxref("String.slice", "slice()")}} sont très La méthode `substring()` échangera les deux arguments si `indiceA` est supérieur à `indiceB` et renverra donc une chaîne de caractères. La méthode {{jsxref("String.slice", "slice()")}} n'échange pas les arguments et renvoie donc une chaîne vide si le premier est supérieur au second : ```js -var text = 'Mozilla'; +var text = "Mozilla"; console.log(text.substring(5, 2)); // => "zil" -console.log(text.slice(5, 2)); // => "" +console.log(text.slice(5, 2)); // => "" ``` Si l'un ou l'autre des arguments sont négatifs ou valent `NaN`, la méthode `substring()` les traitera comme s'ils valaient `0`. diff --git a/files/fr/web/javascript/reference/global_objects/string/sup/index.md b/files/fr/web/javascript/reference/global_objects/string/sup/index.md index 9c2ca878f924ae..b5429282a91cc9 100644 --- a/files/fr/web/javascript/reference/global_objects/string/sup/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/sup/index.md @@ -11,7 +11,7 @@ La méthode **`sup()`** crée un élément HTML {{HTMLElement("sup")}} qui entra ## Syntaxe ```js -str.sup() +str.sup(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/string/tolocaleuppercase/index.md b/files/fr/web/javascript/reference/global_objects/string/tolocaleuppercase/index.md index 75a502ae3eab14..2acc0365396539 100644 --- a/files/fr/web/javascript/reference/global_objects/string/tolocaleuppercase/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/tolocaleuppercase/index.md @@ -43,8 +43,8 @@ On notera également que la conversion ne repose pas sur une correspondance un ## Exemples ```js -"alphabet".toLocaleUpperCase(); // "ALPHABET" -'Gesäß'.toLocaleUpperCase(); // 'GESÄSS' +"alphabet".toLocaleUpperCase(); // "ALPHABET" +"Gesäß".toLocaleUpperCase(); // 'GESÄSS' "i\u0307".toLocaleUpperCase("lt-LT"); // "I" ``` diff --git a/files/fr/web/javascript/reference/global_objects/string/tolowercase/index.md b/files/fr/web/javascript/reference/global_objects/string/tolowercase/index.md index 258fd67f16a8ff..bdcf04d8cb072c 100644 --- a/files/fr/web/javascript/reference/global_objects/string/tolowercase/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/tolowercase/index.md @@ -13,7 +13,7 @@ La méthode **`toLowerCase()`** retourne la chaîne de caractères courante en m ## Syntaxe ```js -str.toLowerCase() +str.toLowerCase(); ``` ### Valeur de retour @@ -27,7 +27,7 @@ La méthode `toLowerCase()` renvoie la valeur de la chaîne convertie en minuscu ## Exemples ```js -console.log( "ALPHABET".toLowerCase() ); // "alphabet" +console.log("ALPHABET".toLowerCase()); // "alphabet" ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/string/tostring/index.md b/files/fr/web/javascript/reference/global_objects/string/tostring/index.md index 606fc0b2b6e41c..be500553bacd74 100644 --- a/files/fr/web/javascript/reference/global_objects/string/tostring/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/tostring/index.md @@ -13,7 +13,7 @@ La méthode **`toString()`** renvoie une chaine de caractères représentant l'o ## Syntaxe ```js -str.toString() +str.toString(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/string/touppercase/index.md b/files/fr/web/javascript/reference/global_objects/string/touppercase/index.md index 991ccf03d51be4..4d9cfd5619658b 100644 --- a/files/fr/web/javascript/reference/global_objects/string/touppercase/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/touppercase/index.md @@ -13,7 +13,7 @@ La méthode **`toUpperCase()`** retourne la valeur de la chaîne courante, conve ## Syntaxe ```js -str.toUpperCase() +str.toUpperCase(); ``` ### Valeur de retour @@ -34,7 +34,7 @@ La méthode `toUpperCase()` retourne la valeur de la chaîne convertie en majusc ### Utiliser `toUpperCase()` ```js -console.log( "alphabet".toUpperCase() ); // "ALPHABET" +console.log("alphabet".toUpperCase()); // "ALPHABET" ``` ### Convertir une valeur `this` en chaîne de caractères @@ -43,9 +43,9 @@ Cette peut être utilisée pour convertir une valeur qui n'est pas une chaîne d ```js var obj = { - toString: function toString(){ - return 'abcdef'; - } + toString: function toString() { + return "abcdef"; + }, }; var a = String.prototype.toUpperCase.call(obj); var b = String.prototype.toUpperCase.call(true); diff --git a/files/fr/web/javascript/reference/global_objects/string/trim/index.md b/files/fr/web/javascript/reference/global_objects/string/trim/index.md index 81e055413861ae..b776e33371bf7e 100644 --- a/files/fr/web/javascript/reference/global_objects/string/trim/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/trim/index.md @@ -13,7 +13,7 @@ La méthode **`trim()`** permet de retirer les blancs en début et fin de chaîn ## Syntaxe ```js -str.trim() +str.trim(); ``` ### Valeur de retour @@ -29,12 +29,12 @@ La méthode `trim()` renvoie la chaîne sans blanc au début et à la fin. La m L'exemple qui suit affiche la chaîne `'toto'` : ```js -var chaîneOriginale = ' toto '; +var chaîneOriginale = " toto "; console.log(chaîneOriginale.trim()); // 'toto' // Un autre exemple de .trim() qui enlève les espaces juste d'un côté -var chaîneOriginale = 'toto '; +var chaîneOriginale = "toto "; console.log(chaîneOriginale.trim()); // 'toto' ``` @@ -45,7 +45,7 @@ Si l'environnement utilisé ne possède pas cette méthode, il est possible de l ```js if (!String.prototype.trim) { String.prototype.trim = function () { - return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); + return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""); }; } ``` diff --git a/files/fr/web/javascript/reference/global_objects/string/trimend/index.md b/files/fr/web/javascript/reference/global_objects/string/trimend/index.md index cd9a69a4d47543..66796b9434175a 100644 --- a/files/fr/web/javascript/reference/global_objects/string/trimend/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/trimend/index.md @@ -35,7 +35,7 @@ String.prototype.trimRight.name === "trimEnd"; ## Exemples -L'exemple qui suit illustre comment afficher la chaîne " toto": +L'exemple qui suit illustre comment afficher la chaîne " toto": ```js var str = " toto "; @@ -44,7 +44,7 @@ console.log(str.length); // 9 str = str.trimEnd(); console.log(str.length); // 7 -console.log(str); // " toto" +console.log(str); // " toto" ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/string/trimstart/index.md b/files/fr/web/javascript/reference/global_objects/string/trimstart/index.md index eaa6026a44b293..da5753ec3d1956 100644 --- a/files/fr/web/javascript/reference/global_objects/string/trimstart/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/trimstart/index.md @@ -44,7 +44,7 @@ console.log(str.length); // 8 str = str.trimStart(); console.log(str.length); // 5 -console.log(str); // "toto " +console.log(str); // "toto " ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/string/valueof/index.md b/files/fr/web/javascript/reference/global_objects/string/valueof/index.md index bdf350289cbc82..e52e45217178bc 100644 --- a/files/fr/web/javascript/reference/global_objects/string/valueof/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/valueof/index.md @@ -13,7 +13,7 @@ La méthode **`valueOf()`** renvoie la valeur primitive de l'objet {{jsxref("Str ## Syntaxe ```js -str.valueOf() +str.valueOf(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/symbol/asynciterator/index.md b/files/fr/web/javascript/reference/global_objects/symbol/asynciterator/index.md index 1aab021694d49a..23ab566588d8d7 100644 --- a/files/fr/web/javascript/reference/global_objects/symbol/asynciterator/index.md +++ b/files/fr/web/javascript/reference/global_objects/symbol/asynciterator/index.md @@ -22,20 +22,20 @@ Il est possible de définir son propre itérable en définissant la propriété ```js const myAsyncIterable = new Object(); -myAsyncIterable[Symbol.asyncIterator] = async function*() { - yield "coucou"; - yield "l'itération"; - yield "asynchrone !"; +myAsyncIterable[Symbol.asyncIterator] = async function* () { + yield "coucou"; + yield "l'itération"; + yield "asynchrone !"; }; (async () => { - for await (const x of myAsyncIterable) { - console.log(x); - // expected output: - // "coucou" - // "l'itération" - // "asynchrone !" - } + for await (const x of myAsyncIterable) { + console.log(x); + // expected output: + // "coucou" + // "l'itération" + // "asynchrone !" + } })(); ``` diff --git a/files/fr/web/javascript/reference/global_objects/symbol/description/index.md b/files/fr/web/javascript/reference/global_objects/symbol/description/index.md index b983ed006a8ab5..0035def4774874 100644 --- a/files/fr/web/javascript/reference/global_objects/symbol/description/index.md +++ b/files/fr/web/javascript/reference/global_objects/symbol/description/index.md @@ -13,9 +13,9 @@ La propriété en lecture seule **`description`** est une chaîne de caractères ## Syntaxe ```js -Symbol('maDescription').description; +Symbol("maDescription").description; Symbol.iterator.description; -Symbol.for('toto').description; +Symbol.for("toto").description; ``` ## Description @@ -25,18 +25,18 @@ Les objets {{jsxref("Symbol")}} peuvent être créés avec une description facul ## Exemples ```js -Symbol('desc').toString(); // "Symbol(desc)" -Symbol('desc').description; // "desc" -Symbol('').description; // "" -Symbol().description; // undefined +Symbol("desc").toString(); // "Symbol(desc)" +Symbol("desc").description; // "desc" +Symbol("").description; // "" +Symbol().description; // undefined // symboles connus -Symbol.iterator.toString(); // "Symbol(Symbol.iterator)" +Symbol.iterator.toString(); // "Symbol(Symbol.iterator)" Symbol.iterator.description; // "Symbol.iterator" // symboles globaux -Symbol.for('toto').toString(); // "Symbol(toto)" -Symbol.for('toto').description; // "toto" +Symbol.for("toto").toString(); // "Symbol(toto)" +Symbol.for("toto").description; // "toto" ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/symbol/index.md b/files/fr/web/javascript/reference/global_objects/symbol/index.md index 6b1eed66f7a770..43bbdb5c6f5922 100644 --- a/files/fr/web/javascript/reference/global_objects/symbol/index.md +++ b/files/fr/web/javascript/reference/global_objects/symbol/index.md @@ -16,14 +16,14 @@ Pour créer une nouvelle valeur primitive symbole, il suffit d'appeler `Symbol() ```js let sym1 = Symbol(); -let sym2 = Symbol('toto'); -let sym3 = Symbol('toto'); +let sym2 = Symbol("toto"); +let sym3 = Symbol("toto"); ``` Le fragment de code ci-dessus permet de créer trois nouveaux symboles. On notera que l'instruction `Symbol('toto')` ne convertit pas la chaîne `'toto'` en un symbole. On crée bien un nouveau symbole pour chaque instruction ci-avant. ```js -Symbol('toto') === Symbol('toto'); // false +Symbol("toto") === Symbol("toto"); // false ``` La syntaxe suivante, utilisant l'opérateur [`new`](/fr/docs/Web/JavaScript/Reference/Operators/new), entraînera une exception [`TypeError`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypeError) : @@ -37,10 +37,10 @@ Cela est fait pour empêcher d'écrire une enveloppe (wrapper) Si on souhaite obtenir un object contenant un symbole, on pourra toujours utiliser la fonction `Object()` : ```js -let sym = Symbol('toto'); -typeof sym; // "symbol" +let sym = Symbol("toto"); +typeof sym; // "symbol" let symObj = Object(sym); -typeof symObj; // "object" +typeof symObj; // "object" ``` ### Symboles partagés et registre global des symboles @@ -113,9 +113,9 @@ La méthode [`Object.getOwnPropertySymbols()`](/fr/docs/Web/JavaScript/Reference L'opérateur [`typeof`](/fr/docs/Web/JavaScript/Reference/Operators/typeof) permet d'identifier des symboles : ```js -typeof Symbol() === 'symbol' -typeof Symbol('toto') === 'symbol' -typeof Symbol.iterator === 'symbol' +typeof Symbol() === "symbol"; +typeof Symbol("toto") === "symbol"; +typeof Symbol.iterator === "symbol"; ``` ### Les symboles et les conversions @@ -134,10 +134,10 @@ Les symboles ne peuvent pas être énumérés dans les boucles [`for…in`](/fr/ ```js let obj = {}; -obj[Symbol('a')] = 'a'; -obj[Symbol.for('b')] = 'b'; -obj['c'] = 'c'; -obj.d = 'd'; +obj[Symbol("a")] = "a"; +obj[Symbol.for("b")] = "b"; +obj["c"] = "c"; +obj.d = "d"; for (let i in obj) { console.log(i); // affiche "c" et "d" @@ -149,7 +149,7 @@ for (let i in obj) { Les propriétés identifiées par des symboles seront totalement ignorées par `JSON.stringify()` : ```js -JSON.stringify({[Symbol('toto')]: 'toto'}); +JSON.stringify({ [Symbol("toto")]: "toto" }); // '{}' ``` @@ -160,10 +160,10 @@ Pour plus de détails, voir la page [`JSON.stringify()`](/fr/docs/Web/JavaScript Lorsqu'on utilise un objet pour contenir la valeur du symbole et faire référence à une propriété, l'objet sera ramené au symbole d'origine : ```js -let sym = Symbol('toto') -let obj = {[sym]: 1}; -obj[sym]; // 1 -obj[Object(sym)]; // toujours 1 +let sym = Symbol("toto"); +let obj = { [sym]: 1 }; +obj[sym]; // 1 +obj[Object(sym)]; // toujours 1 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/symbol/isconcatspreadable/index.md b/files/fr/web/javascript/reference/global_objects/symbol/isconcatspreadable/index.md index cb7c9b327ec222..ba50223d022281 100644 --- a/files/fr/web/javascript/reference/global_objects/symbol/isconcatspreadable/index.md +++ b/files/fr/web/javascript/reference/global_objects/symbol/isconcatspreadable/index.md @@ -26,8 +26,8 @@ Le symbole `@@isConcatSpreadable` (`Symbol.isConcatSpreadable`) peut être défi Par défaut, {{jsxref("Array.prototype.concat()")}} aplatit les tableaux pour le résultat de la concaténation : ```js -var alpha = ['a', 'b', 'c'], - numérique = [1, 2, 3]; +var alpha = ["a", "b", "c"], + numérique = [1, 2, 3]; var alphaNumérique = alpha.concat(numérique); @@ -38,8 +38,8 @@ console.log(alphaNumérique); En définissant `Symbol.isConcatSpreadable` avec `false`, on peut désactiver le comportement par défaut : ```js -var alpha = ['a', 'b', 'c'], - numérique = [1, 2, 3]; +var alpha = ["a", "b", "c"], + numérique = [1, 2, 3]; numérique[Symbol.isConcatSpreadable] = false; var alphaNumérique = alpha.concat(numérique); @@ -59,8 +59,8 @@ var fauxTableau = { [Symbol.isConcatSpreadable]: true, length: 2, 0: "coucou", - 1: "monde" -} + 1: "monde", +}; x.concat(fauxTableau); // [1, 2, 3, "coucou", "monde"] ``` diff --git a/files/fr/web/javascript/reference/global_objects/symbol/iterator/index.md b/files/fr/web/javascript/reference/global_objects/symbol/iterator/index.md index 13e65ccf471248..651d89f0383de2 100644 --- a/files/fr/web/javascript/reference/global_objects/symbol/iterator/index.md +++ b/files/fr/web/javascript/reference/global_objects/symbol/iterator/index.md @@ -33,13 +33,13 @@ Pour plus d'informations, voir aussi [la page sur les protocoles d'itération](/ Il est possible de construire un itérable de la façon suivante : ```js -var monItérable = {} +var monItérable = {}; monItérable[Symbol.iterator] = function* () { - yield 1; - yield 2; - yield 3; + yield 1; + yield 2; + yield 3; }; -[...monItérable] // [1, 2, 3] +[...monItérable]; // [1, 2, 3] ``` On peut également définir ces itérables via des propriétés calculées dans des déclarations de classe ou dans des littéraux objets : diff --git a/files/fr/web/javascript/reference/global_objects/symbol/match/index.md b/files/fr/web/javascript/reference/global_objects/symbol/match/index.md index c18bcf2e9da2db..6776052c92ce41 100644 --- a/files/fr/web/javascript/reference/global_objects/symbol/match/index.md +++ b/files/fr/web/javascript/reference/global_objects/symbol/match/index.md @@ -34,7 +34,7 @@ Cependant, si `Symbol.match` vaut `false`, cette vérification `isRegExp` indiqu var re = /toto/; re[Symbol.match] = false; "/toto/".startsWith(re); // true -"/truc/".endsWith(re); // false +"/truc/".endsWith(re); // false ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/symbol/matchall/index.md b/files/fr/web/javascript/reference/global_objects/symbol/matchall/index.md index 252cf9cc19d7ca..7f57c25dadc580 100644 --- a/files/fr/web/javascript/reference/global_objects/symbol/matchall/index.md +++ b/files/fr/web/javascript/reference/global_objects/symbol/matchall/index.md @@ -15,9 +15,9 @@ Le symbole connu **`Symbol.matchAll`** renvoie un itérateur qui fournit l'ensem Ce symbole est utilisé par {{jsxref("String.prototype.matchAll()")}} et plus particulièrement par {{jsxref("RegExp.@@matchAll", "RegExp.prototype[@@matchAll]()")}}. Les deux lignes qui suivent renverront le même résultat : ```js -'abc'.matchAll(/a/); +"abc".matchAll(/a/); -/a/[Symbol.matchAll]('abc'); +/a/[Symbol.matchAll]("abc"); ``` Cette méthode existe afin de personnaliser le comportement des correspondances pour les sous-classes de {{jsxref("RegExp")}}. diff --git a/files/fr/web/javascript/reference/global_objects/symbol/species/index.md b/files/fr/web/javascript/reference/global_objects/symbol/species/index.md index df24dd06a9d750..5c77cb90e61447 100644 --- a/files/fr/web/javascript/reference/global_objects/symbol/species/index.md +++ b/files/fr/web/javascript/reference/global_objects/symbol/species/index.md @@ -23,13 +23,15 @@ Dans certains cas, vous pouvez avoir besoin de renvoyer {{jsxref("Array")}} pour ```js class MonArray extends Array { // On surcharge species avec le constructeur parent Array - static get [Symbol.species]() { return Array; } + static get [Symbol.species]() { + return Array; + } } -var a = new MonArray(1,2,3); -var mapped = a.map(x => x * x); +var a = new MonArray(1, 2, 3); +var mapped = a.map((x) => x * x); console.log(mapped instanceof MonArray); // false -console.log(mapped instanceof Array); // true +console.log(mapped instanceof Array); // true ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/symbol/symbol/index.md b/files/fr/web/javascript/reference/global_objects/symbol/symbol/index.md index 843ca7250ee91f..ddff02aa76685f 100644 --- a/files/fr/web/javascript/reference/global_objects/symbol/symbol/index.md +++ b/files/fr/web/javascript/reference/global_objects/symbol/symbol/index.md @@ -13,8 +13,8 @@ Le constructeur `Symbol()` renvoie une valeur de type **`symbol`**. Ce n'est pas ## Syntaxe ```js -Symbol() -Symbol(description) +Symbol(); +Symbol(description); ``` ### Paramètres @@ -30,14 +30,14 @@ Pour créer un nouveau symbole primitif, on écrit `Symbol()` en fournissant év ```js let sym1 = Symbol(); -let sym2 = Symbol('toto'); -let sym3 = Symbol('toto'); +let sym2 = Symbol("toto"); +let sym3 = Symbol("toto"); ``` Dans le code précédent, on crée trois nouveaux symboles. On notera que `Symbol("toto")` ne convertit pas la chaîne de caractères `"toto"` en un symbole. C'est bien un nouveau symbole qui est créé chaque fois : ```js -Symbol('toto') === Symbol('toto'); // false +Symbol("toto") === Symbol("toto"); // false ``` ### `new Symbol(…)` @@ -45,7 +45,7 @@ Symbol('toto') === Symbol('toto'); // false La syntaxe qui suit, utilisant l'opérateur [`new`](/fr/docs/Web/JavaScript/Reference/Operators/new), déclenchera une exception [`TypeError`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypeError) : ```js -let sym = new Symbol(); // TypeError +let sym = new Symbol(); // TypeError ``` Cela permet d'éviter aux développeuses et développeurs de créer un objet enveloppant une valeur symbole primitive plutôt qu'un nouveau symbole. Ce comportement se distingue des autres types de données primitifs pour lesquels c'est possible (par exemple `new Boolean()`, `new String()` et `new Number()`). @@ -53,9 +53,9 @@ Cela permet d'éviter aux développeuses et développeurs de créer un objet env Si on souhaite vraiment envelopper un symbole dans une valeur objet, il faudra utiliser la fonction `Object()` : ```js -let sym = Symbol('toto'); +let sym = Symbol("toto"); let symObj = Object(sym); -typeof sym; // => "symbol" +typeof sym; // => "symbol" typeof symObj; // => "object" ``` diff --git a/files/fr/web/javascript/reference/global_objects/symbol/toprimitive/index.md b/files/fr/web/javascript/reference/global_objects/symbol/toprimitive/index.md index ec47891bb6bc48..0d9ac0eba692a5 100644 --- a/files/fr/web/javascript/reference/global_objects/symbol/toprimitive/index.md +++ b/files/fr/web/javascript/reference/global_objects/symbol/toprimitive/index.md @@ -23,7 +23,7 @@ Dans l'exemple qui suit, on voit comment la propriété `Symbol.toPrimitive` peu ```js // Premier cas avec un objet sans Symbol.toPrimitive. let obj1 = {}; -console.log(+obj1); // NaN +console.log(+obj1); // NaN console.log(`${obj1}`); // "[object Object]" console.log(obj1 + ""); // "[object Object]" @@ -37,9 +37,9 @@ var obj2 = { return "coucou"; } return true; - } + }, }; -console.log(+obj2); // 10 -- hint vaut "number" +console.log(+obj2); // 10 -- hint vaut "number" console.log(`${obj2}`); // "coucou" -- hint vaut "string" console.log(obj2 + ""); // true -- hint vaut "default" ``` diff --git a/files/fr/web/javascript/reference/global_objects/symbol/tostring/index.md b/files/fr/web/javascript/reference/global_objects/symbol/tostring/index.md index 1beb5bdb5ac868..ed07311b5239b5 100644 --- a/files/fr/web/javascript/reference/global_objects/symbol/tostring/index.md +++ b/files/fr/web/javascript/reference/global_objects/symbol/tostring/index.md @@ -29,19 +29,19 @@ L'objet {{jsxref("Symbol")}} surcharge la méthode `toString()` d'{{jsxref("Obje Bien qu'il soit possible d'appeler `toString()` pour les symboles, il n'est pas possible de concaténer une chaîne de caractères avec ce type d'objet : ```js -Symbol("toto") + "machin"; // TypeError : Impossible de convertir un symbole en chaîne de caractères +Symbol("toto") + "machin"; // TypeError : Impossible de convertir un symbole en chaîne de caractères ``` ## Exemples ```js -Symbol("desc").toString(); // "Symbol(desc)" +Symbol("desc").toString(); // "Symbol(desc)" // symboles connus -Symbol.iterator.toString(); // "Symbol(Symbol.iterator) +Symbol.iterator.toString(); // "Symbol(Symbol.iterator) // symboles globaux -Symbol.for("toto").toString() // "Symbol(toto)" +Symbol.for("toto").toString(); // "Symbol(toto)" ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/symbol/tostringtag/index.md b/files/fr/web/javascript/reference/global_objects/symbol/tostringtag/index.md index 0b9c81d0353c74..0005a89c92cc04 100644 --- a/files/fr/web/javascript/reference/global_objects/symbol/tostringtag/index.md +++ b/files/fr/web/javascript/reference/global_objects/symbol/tostringtag/index.md @@ -15,20 +15,20 @@ Le symbole connu **`Symbol.toStringTag`** est une propriété qui est une chaîn La plupart des types JavaScript ont des étiquettes par défaut : ```js -Object.prototype.toString.call('toto'); // "[object String]" -Object.prototype.toString.call([1, 2]); // "[object Array]" -Object.prototype.toString.call(3); // "[object Number]" -Object.prototype.toString.call(true); // "[object Boolean]" +Object.prototype.toString.call("toto"); // "[object String]" +Object.prototype.toString.call([1, 2]); // "[object Array]" +Object.prototype.toString.call(3); // "[object Number]" +Object.prototype.toString.call(true); // "[object Boolean]" Object.prototype.toString.call(undefined); // "[object Undefined]" -Object.prototype.toString.call(null); // "[object Null]" +Object.prototype.toString.call(null); // "[object Null]" // etc. ``` D'autres ont le symbole natif `toStringTag` défini : ```js -Object.prototype.toString.call(new Map()); // "[object Map]" -Object.prototype.toString.call(function* () {}); // "[object GeneratorFunction]" +Object.prototype.toString.call(new Map()); // "[object Map]" +Object.prototype.toString.call(function* () {}); // "[object GeneratorFunction]" Object.prototype.toString.call(Promise.resolve()); // "[object Promise]" // etc. ``` diff --git a/files/fr/web/javascript/reference/global_objects/symbol/unscopables/index.md b/files/fr/web/javascript/reference/global_objects/symbol/unscopables/index.md index 29c8728884e4ae..b175dbe3ca66b6 100644 --- a/files/fr/web/javascript/reference/global_objects/symbol/unscopables/index.md +++ b/files/fr/web/javascript/reference/global_objects/symbol/unscopables/index.md @@ -25,7 +25,7 @@ Le code qui suit fonctionne bien pour ES5 et les versions antérieures. En revan ```js var keys = []; -with(Array.prototype) { +with (Array.prototype) { keys.push("something"); } @@ -39,15 +39,15 @@ On peut également manipuler `unscopables` sur ses propres objets : ```js var obj = { toto: 1, - truc: 2 + truc: 2, }; obj[Symbol.unscopables] = { toto: false, - truc: true + truc: true, }; -with(obj) { +with (obj) { console.log(toto); // 1 console.log(truc); // ReferenceError: truc is not defined } diff --git a/files/fr/web/javascript/reference/global_objects/syntaxerror/index.md b/files/fr/web/javascript/reference/global_objects/syntaxerror/index.md index ff7d8880851e81..d78886784a70b3 100644 --- a/files/fr/web/javascript/reference/global_objects/syntaxerror/index.md +++ b/files/fr/web/javascript/reference/global_objects/syntaxerror/index.md @@ -32,15 +32,15 @@ L'objet **`SyntaxError`** représente une erreur qui se produit lors de l'interp ```js try { - eval('toto truc'); + eval("toto truc"); } catch (e) { console.log(e instanceof SyntaxError); // true - console.log(e.message); // "missing ; before statement" - console.log(e.name); // "SyntaxError" - console.log(e.fileName); // "Scratchpad/1" - console.log(e.lineNumber); // 1 - console.log(e.columnNumber); // 4 - console.log(e.stack); // "@Scratchpad/1:2:3\n" + console.log(e.message); // "missing ; before statement" + console.log(e.name); // "SyntaxError" + console.log(e.fileName); // "Scratchpad/1" + console.log(e.lineNumber); // 1 + console.log(e.columnNumber); // 4 + console.log(e.stack); // "@Scratchpad/1:2:3\n" } ``` @@ -48,15 +48,15 @@ try { ```js try { - throw new SyntaxError('Coucou', 'unFichier.js', 10); + throw new SyntaxError("Coucou", "unFichier.js", 10); } catch (e) { console.log(e instanceof SyntaxError); // true - console.log(e.message); // "Coucou" - console.log(e.name); // "SyntaxError" - console.log(e.fileName); // "unFichier.js" - console.log(e.lineNumber); // 10 - console.log(e.columnNumber); // 0 - console.log(e.stack); // "@Scratchpad/2:11:9\n" + console.log(e.message); // "Coucou" + console.log(e.name); // "SyntaxError" + console.log(e.fileName); // "unFichier.js" + console.log(e.lineNumber); // 10 + console.log(e.columnNumber); // 0 + console.log(e.stack); // "@Scratchpad/2:11:9\n" } ``` diff --git a/files/fr/web/javascript/reference/global_objects/syntaxerror/syntaxerror/index.md b/files/fr/web/javascript/reference/global_objects/syntaxerror/syntaxerror/index.md index 349d34b88426fa..0d172f49ab6f07 100644 --- a/files/fr/web/javascript/reference/global_objects/syntaxerror/syntaxerror/index.md +++ b/files/fr/web/javascript/reference/global_objects/syntaxerror/syntaxerror/index.md @@ -11,10 +11,10 @@ Le constructeur **`SyntaxError()`** permet de créer un objet représentant une ## Syntaxe ```js -new SyntaxError() -new SyntaxError(message) -new SyntaxError(message, nomFichier) -new SyntaxError(message, nomFichier, numeroLigne) +new SyntaxError(); +new SyntaxError(message); +new SyntaxError(message, nomFichier); +new SyntaxError(message, nomFichier, numeroLigne); ``` ### Paramètres @@ -32,7 +32,7 @@ new SyntaxError(message, nomFichier, numeroLigne) ```js try { - eval('coucou truc'); + eval("coucou truc"); } catch (e) { console.error(e instanceof SyntaxError); console.error(e.message); @@ -48,15 +48,15 @@ try { ```js try { - throw new SyntaxError('Coucou', 'unFichier.js', 10); + throw new SyntaxError("Coucou", "unFichier.js", 10); } catch (e) { console.error(e instanceof SyntaxError); // true - console.error(e.message); // Coucou - console.error(e.name); // SyntaxError - console.error(e.fileName); // unFichier.js - console.error(e.lineNumber); // 10 - console.error(e.columnNumber); // 0 - console.error(e.stack); // @debugger eval code:3:9 + console.error(e.message); // Coucou + console.error(e.name); // SyntaxError + console.error(e.fileName); // unFichier.js + console.error(e.lineNumber); // 10 + console.error(e.columnNumber); // 0 + console.error(e.stack); // @debugger eval code:3:9 } ``` diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/@@iterator/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/@@iterator/index.md index d4dc2709a75610..3b7a534869d78d 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/@@iterator/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/@@iterator/index.md @@ -11,7 +11,7 @@ La valeur initiale de la propriété @@iterator est le même objet fonction que ## Syntaxe ```js -typedarray[Symbol.iterator]() +typedarray[Symbol.iterator](); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/@@species/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/@@species/index.md index b0f77650088106..c058e6eb4465aa 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/@@species/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/@@species/index.md @@ -11,7 +11,7 @@ La propriété d'accesseur **`TypedArray[@@species]`** renvoie le constructeur [ ## Syntaxe ```js -TypedArray[Symbol.species] +TypedArray[Symbol.species]; ``` où TypedArray vaut : @@ -35,8 +35,8 @@ L'accesseur `species` renvoie le constructeur par défaut pour les tableaux typ La propriété `species` renvoie le constructeur par défaut qui est l'un des constructeurs de tableau typé (selon le type [de tableau typé](/fr/docs/Web/JavaScript/Reference/Objets_globaux/TypedArray#Les_objets_TypedArray) de l'objet) : ```js -Int8Array[Symbol.species]; // function Int8Array() -Uint8Array[Symbol.species]; // function Uint8Array() +Int8Array[Symbol.species]; // function Int8Array() +Uint8Array[Symbol.species]; // function Uint8Array() Float32Array[Symbol.species]; // function Float32Array() ``` @@ -46,7 +46,9 @@ Pour un objet construit sur mesure (par exemple une tableau `MonTableauTypé`), class MonTableauTypé extends Uint8Array { // On surcharge species pour MonTableauTypé // pour récupérer le constructeur Uint8Array - static get [Symbol.species]() { return Uint8Array; } + static get [Symbol.species]() { + return Uint8Array; + } } ``` diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/at/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/at/index.md index ed92a1d9a6fc44..37cd46bad49791 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/at/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/at/index.md @@ -15,7 +15,7 @@ L'accès aux éléments d'un tableau typé en utilisant les crochets ne permet q ## Syntaxe ```js -at(indice) +at(indice); ``` ### Paramètres @@ -54,7 +54,7 @@ On compare ici différentes façons d'accéder à l'avant-dernier élément d'un const uint8 = new Uint8Array([1, 2, 4, 7, 11, 18]); // En utilisant la propriété length -const avecLength = uint8[uint8.length-2]; +const avecLength = uint8[uint8.length - 2]; console.log(avecLength); // Affiche 11 dans la console // En utilisant la méthode slice() diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/buffer/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/buffer/index.md index db68605d85e4c8..3ab4d3d12efc76 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/buffer/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/buffer/index.md @@ -13,7 +13,7 @@ La propriété **`buffer`** est un accesseur représentant l'{{jsxref("ArrayBuff ## Syntaxe ```js -typedArray.buffer +typedArray.buffer; ``` ## Description diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/bytelength/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/bytelength/index.md index fb28812f5ae5d7..f2b5118bc1359b 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/bytelength/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/bytelength/index.md @@ -13,7 +13,7 @@ La propriété **`byteLength`** est un accesseur qui représente la longueur, ex ## Syntaxe ```js -typedarray.byteLength +typedarray.byteLength; ``` ## Description diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/byteoffset/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/byteoffset/index.md index 550e69e0af2349..925ad14306f16d 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/byteoffset/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/byteoffset/index.md @@ -11,7 +11,7 @@ La propriété **`byteOffset`** est un accesseur qui représente le décalage, e ## Syntaxe ```js -typedarray.byteOffset +typedarray.byteOffset; ``` ## Description diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/bytes_per_element/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/bytes_per_element/index.md index 1e2d7cf27b2903..439bbacfb02eee 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/bytes_per_element/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/bytes_per_element/index.md @@ -23,15 +23,15 @@ La taille des éléments d'un tableau typé varie en fonction du type de `TypedA ## Exemples ```js -Int8Array.BYTES_PER_ELEMENT; // 1 -Uint8Array.BYTES_PER_ELEMENT; // 1 +Int8Array.BYTES_PER_ELEMENT; // 1 +Uint8Array.BYTES_PER_ELEMENT; // 1 Uint8ClampedArray.BYTES_PER_ELEMENT; // 1 -Int16Array.BYTES_PER_ELEMENT; // 2 -Uint16Array.BYTES_PER_ELEMENT; // 2 -Int32Array.BYTES_PER_ELEMENT; // 4 -Uint32Array.BYTES_PER_ELEMENT; // 4 -Float32Array.BYTES_PER_ELEMENT; // 4 -Float64Array.BYTES_PER_ELEMENT; // 8 +Int16Array.BYTES_PER_ELEMENT; // 2 +Uint16Array.BYTES_PER_ELEMENT; // 2 +Int32Array.BYTES_PER_ELEMENT; // 4 +Uint32Array.BYTES_PER_ELEMENT; // 4 +Float32Array.BYTES_PER_ELEMENT; // 4 +Float64Array.BYTES_PER_ELEMENT; // 8 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/copywithin/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/copywithin/index.md index 0189eead32d620..6362afb71ca0f2 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/copywithin/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/copywithin/index.md @@ -40,9 +40,9 @@ Cette méthode remplace la méthode expérimentale {{jsxref("TypedArray.prototyp ```js var buffer = new ArrayBuffer(8); var uint8 = new Uint8Array(buffer); -uint8.set([1,2,3]); +uint8.set([1, 2, 3]); console.log(uint8); // Uint8Array [ 1, 2, 3, 0, 0, 0, 0, 0 ] -uint8.copyWithin(3,0,3); +uint8.copyWithin(3, 0, 3); console.log(uint8); // Uint8Array [ 1, 2, 3, 1, 2, 3, 0, 0 ] ``` diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/entries/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/entries/index.md index d77671fee65aac..70caa1940304a5 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/entries/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/entries/index.md @@ -13,7 +13,7 @@ La méthode **`entries()`** renvoie un nouvel objet `Array Iterator` qui contien ## Syntaxe ```js -arr.entries() +arr.entries(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/every/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/every/index.md index 56b45c050a2695..49499efd2235bc 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/every/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/every/index.md @@ -56,7 +56,7 @@ Dans l'exemple suivant, on teste si tous les éléments du tableau typé sont su function estGrand(element, index, array) { return element >= 10; } -new Uint8Array([12, 5, 8, 130, 44]).every(estGrand); // false +new Uint8Array([12, 5, 8, 130, 44]).every(estGrand); // false new Uint8Array([12, 54, 18, 130, 44]).every(estGrand); // true ``` @@ -65,8 +65,8 @@ new Uint8Array([12, 54, 18, 130, 44]).every(estGrand); // true [Les fonctions fléchées](/fr/docs/Web/JavaScript/Reference/Fonctions/Fonctions_fléchées) permettent d'utiliser une syntaxe plus concise pour parvenir au même résultat : ```js -new Uint8Array([12, 5, 8, 130, 44]).every(elem => elem >= 10); // false -new Uint8Array([12, 54, 18, 130, 44]).every(elem => elem >= 10); // true +new Uint8Array([12, 5, 8, 130, 44]).every((elem) => elem >= 10); // false +new Uint8Array([12, 54, 18, 130, 44]).every((elem) => elem >= 10); // true ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/fill/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/fill/index.md index 0c5d22e1a63274..8bd9c437c5a193 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/fill/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/fill/index.md @@ -40,10 +40,10 @@ Si `début` est négatif, on le traite comme `length+début` où `length` repré ## Exemples ```js -new Uint8Array([1, 2, 3]).fill(4); // Uint8Array [4, 4, 4] -new Uint8Array([1, 2, 3]).fill(4, 1); // Uint8Array [1, 4, 4] -new Uint8Array([1, 2, 3]).fill(4, 1, 2); // Uint8Array [1, 4, 3] -new Uint8Array([1, 2, 3]).fill(4, 1, 1); // Uint8Array [1, 2, 3] +new Uint8Array([1, 2, 3]).fill(4); // Uint8Array [4, 4, 4] +new Uint8Array([1, 2, 3]).fill(4, 1); // Uint8Array [1, 4, 4] +new Uint8Array([1, 2, 3]).fill(4, 1, 2); // Uint8Array [1, 4, 3] +new Uint8Array([1, 2, 3]).fill(4, 1, 1); // Uint8Array [1, 2, 3] new Uint8Array([1, 2, 3]).fill(4, -3, -2); // Uint8Array [4, 2, 3] ``` diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/filter/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/filter/index.md index 08ad3f205f53f5..b21f3bdd174034 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/filter/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/filter/index.md @@ -62,7 +62,7 @@ new Uint8Array([12, 5, 8, 130, 44]).filter(supSeuil); [Les fonctions fléchées](/fr/docs/Web/JavaScript/Reference/Fonctions/Fonctions_fléchées) permettent d'utiliser une syntaxe plus concise pour réaliser le même test que montré précédemment : ```js -new Uint8Array([12, 5, 8, 130, 44]).filter(élém => élém >= 10); +new Uint8Array([12, 5, 8, 130, 44]).filter((élém) => élém >= 10); // Uint8Array [ 12, 130, 44 ] ``` diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/foreach/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/foreach/index.md index f7b65ea9a4608b..9317821c2a1ce9 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/foreach/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/foreach/index.md @@ -58,7 +58,7 @@ Le code ci-dessous affiche une ligne pour chaque élément du tableau typé : ```js function affichageContenuTableau(élément, index, tableau) { - console.log('a[' + index + '] = ' + élément); + console.log("a[" + index + "] = " + élément); } new Uint8Array([0, 1, 2, 3]).forEach(affichageContenuTableau); diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/from/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/from/index.md index 4837102e9a465e..7f71965443c515 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/from/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/from/index.md @@ -65,20 +65,17 @@ var s = new Set([1, 2, 3]); Uint8Array.from(s); // Uint8Array [ 1, 2, 3 ] - // String Int16Array.from("123"); // Int16Array [ 1, 2, 3 ] - // En utilisant un fonction fléchée en tant que // fonctionMap pour manipuler les éléments -Float32Array.from([1, 2, 3], x => x + x); +Float32Array.from([1, 2, 3], (x) => x + x); // Float32Array [ 2, 4, 6 ] - // Pour construire une séquence de nombres -Uint8Array.from({length: 5}, (v, k) => k); +Uint8Array.from({ length: 5 }, (v, k) => k); // Uint8Array [ 0, 1, 2, 3, 4 ] ``` diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/includes/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/includes/index.md index f9461dc4389b41..dc8556c2078ea2 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/includes/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/includes/index.md @@ -30,10 +30,10 @@ Un booléen indiquant la présence de l'élément (`true` s'il y est, `false` si ## Exemples ```js -var uint8 = new Uint8Array([1,2,3]); -uint8.includes(2); // true -uint8.includes(4); // false -uint8.includes(3, 3); // false +var uint8 = new Uint8Array([1, 2, 3]); +uint8.includes(2); // true +uint8.includes(4); // false +uint8.includes(3, 3); // false // Gestion de NaN (vrai uniquement pour Float32 et Float64) new Uint8Array([NaN]).includes(NaN); // false car NaN est converti en 0 par le constructeur diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/index.md index 9e00545ba0fc89..39aa282ce012ed 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/index.md @@ -18,19 +18,19 @@ Lorsqu'on crée une instance de _TypedArray_ (par exemple, une instance de `Int8 ### Objets _TypedArray_ -| Type | Intervalle de valeurs | Taille en octets | Description | Type Web IDL | Type C équivalent | -| ---------------------------------------- | --------------------------------------------------------------- | ------------- | ---------------------------------------------------------------------------------- | --------------------- | ------------------------------- | -| [`Int8Array`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Int8Array) | `-128` à `127` | 1 | Entier sur 8 bits signé en complément à deux | `byte` | `int8_t` | -| [`Uint8Array`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) | `0` à `255` | 1 | Entier non-signé sur 8 bits | `octet` | `uint8_t` | -| [`Uint8ClampedArray`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray) | `0` à `255` | 1 | Entier non-signé sur 8 bits (écrété) | `octet` | `uint8_t` | -| [`Int16Array`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Int16Array) | `-32768` à `32767` | 2 | Entier sur 16 bits, signé en complément à deux | `short` | `int16_t` | -| [`Uint16Array`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array) | `0` à `65535` | 2 | Entier non-signé sur 16 bits | `unsigned short` | `uint16_t` | -| [`Int32Array`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Int32Array) | `-2147483648` à `2147483647` | 4 | Entier sur 32 bits, signé en complément à deux | `long` | `int32_t` | -| [`Uint32Array`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array) | `0` à `4294967295` | 4 | Entier sur 32 bits non-signé | `unsigned long` | `uint32_t` | -| [`Float32Array`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Float32Array) | `-3.4E38` à `3.4E38` avec `1.2E-38` le plus petit nombre positif | 4 | Nombre flottant sur 32 bits au format IEEE avec 7 chiffres significatifs (par exemple `1.234567`) | `unrestricted float` | `float` | -| [`Float64Array`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Float64Array) | `-1.8E308` à `1.8E308` avec `5E-324` le plus petit nombre positif | 8 | Nombre flottant sur 64 bits au format IEEE avec 16 chiffres significatifs (par exemple `1.23456789012345`) | `unrestricted double` | `double` | -| [`BigInt64Array`](/fr/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array) | `-2^63` à `2^63 - 1` | 8 | Entier sur 64 bits, signé en complément à deux integer | `bigint` | `int64_t (signed long long)` | -| [`BigUint64Array`](/fr/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array) | `0` à `2^64 - 1` | 8 | Entier sur 64 bits non-signé | `bigint` | `uint64_t (unsigned long long)` | +| Type | Intervalle de valeurs | Taille en octets | Description | Type Web IDL | Type C équivalent | +| ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------- | --------------------- | ------------------------------- | +| [`Int8Array`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Int8Array) | `-128` à `127` | 1 | Entier sur 8 bits signé en complément à deux | `byte` | `int8_t` | +| [`Uint8Array`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) | `0` à `255` | 1 | Entier non-signé sur 8 bits | `octet` | `uint8_t` | +| [`Uint8ClampedArray`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray) | `0` à `255` | 1 | Entier non-signé sur 8 bits (écrété) | `octet` | `uint8_t` | +| [`Int16Array`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Int16Array) | `-32768` à `32767` | 2 | Entier sur 16 bits, signé en complément à deux | `short` | `int16_t` | +| [`Uint16Array`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array) | `0` à `65535` | 2 | Entier non-signé sur 16 bits | `unsigned short` | `uint16_t` | +| [`Int32Array`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Int32Array) | `-2147483648` à `2147483647` | 4 | Entier sur 32 bits, signé en complément à deux | `long` | `int32_t` | +| [`Uint32Array`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array) | `0` à `4294967295` | 4 | Entier sur 32 bits non-signé | `unsigned long` | `uint32_t` | +| [`Float32Array`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Float32Array) | `-3.4E38` à `3.4E38` avec `1.2E-38` le plus petit nombre positif | 4 | Nombre flottant sur 32 bits au format IEEE avec 7 chiffres significatifs (par exemple `1.234567`) | `unrestricted float` | `float` | +| [`Float64Array`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Float64Array) | `-1.8E308` à `1.8E308` avec `5E-324` le plus petit nombre positif | 8 | Nombre flottant sur 64 bits au format IEEE avec 16 chiffres significatifs (par exemple `1.23456789012345`) | `unrestricted double` | `double` | +| [`BigInt64Array`](/fr/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array) | `-2^63` à `2^63 - 1` | 8 | Entier sur 64 bits, signé en complément à deux integer | `bigint` | `int64_t (signed long long)` | +| [`BigUint64Array`](/fr/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array) | `0` à `2^64 - 1` | 8 | Entier sur 64 bits non-signé | `bigint` | `uint64_t (unsigned long long)` | ## Constructeur @@ -56,7 +56,7 @@ Où _TypedArray_ est un constructeur donné pour un type de tableau typé exista - : Lorsque le constructeur est appelé avec un argument `longueur`, un tampon de mémoire interne sous forme de tableau est créé et dont la taille est `longueur` multipliée par `BYTES_PER_ELEMENT` octets. Chaque élément du tableau contient des zéros. - `tableauType` - : Lorsque le constructeur est appelé avec un argument `tableauType`, `tableauType` est copié dans un nouveau tableau typé. Pour un tableay typé **dont le type n'est pas [`BigInt64Array`](/fr/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array)**, le paramètre peut être un objet de n'importe quel type de tableau typé en dehors de `BigInt64Array` (par exemple [`Int32Array`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Int32Array)). L'inverse est aussi valable, pour obtenir un tableau typé `BigInt64Array`, le paramètre devra nécessairement être de type `BigInt64Array`. - Chaque valeur contenue dans `tableauType` est convertie dans le type correspondant au constructeur avant d'être copiée dans le nouveau tableau. La longueur du nouveau tableau typé sera la même que celle de l'argument `tableauType`. + Chaque valeur contenue dans `tableauType` est convertie dans le type correspondant au constructeur avant d'être copiée dans le nouveau tableau. La longueur du nouveau tableau typé sera la même que celle de l'argument `tableauType`. - `objet` - : Lorsque le constructeur est appelé avec un objet comme argument, un nouveau tableau typé est créé à la façon de la méthode `TypedArray.from()`. - `buffer`, `decalageOctet`, `longueur` @@ -177,17 +177,17 @@ console.log(int16[0]); // 42 // Les propriétés indexées sur les prototypes ne sont pas consultées Int8Array.prototype[20] = "toto"; -(new Int8Array(32))[20]; // 0 +new Int8Array(32)[20]; // 0 // y compris en dehors des limites Int8Array.prototype[20] = "toto"; -(new Int8Array(8))[20]; // undefined +new Int8Array(8)[20]; // undefined // ou avec des index négatifs Int8Array.prototype[-1] = "toto"; -(new Int8Array(8))[-1]; // undefined +new Int8Array(8)[-1]; // undefined // Mais il est possible d'utiliser des propriétés nommées Int8Array.prototype.toto = "truc"; -(new Int8Array(32)).toto; // "truc" +new Int8Array(32).toto; // "truc" ``` ### Impossibles à geler diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/indexof/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/indexof/index.md index 5bdecc1f2bf19a..618fe32be03c3a 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/indexof/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/indexof/index.md @@ -35,9 +35,9 @@ Le premier indice du tableau pour lequel l'élément a été trouvé, `-1` s'il ```js var uint8 = new Uint8Array([2, 5, 9]); -uint8.indexOf(2); // 0 -uint8.indexOf(7); // -1 -uint8.indexOf(9, 2); // 2 +uint8.indexOf(2); // 0 +uint8.indexOf(7); // -1 +uint8.indexOf(9, 2); // 2 uint8.indexOf(2, -1); // -1 uint8.indexOf(2, -3); // 0 ``` diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/join/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/join/index.md index 06c5746476a4df..22df17869c4945 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/join/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/join/index.md @@ -13,7 +13,7 @@ La méthode **`join()`** fusionne l'ensemble des éléments d'un tableau en une ## Syntaxe ```js -typedarray.join([séparateur = ',']); +typedarray.join([(séparateur = ",")]); ``` ### Paramètres @@ -28,10 +28,10 @@ Une chaîne de caractères formée par la concaténation des différents éléme ## Exemples ```js -var uint8 = new Uint8Array([1,2,3]); -uint8.join(); // '1,2,3' -uint8.join(' / '); // '1 / 2 / 3' -uint8.join(''); // '123' +var uint8 = new Uint8Array([1, 2, 3]); +uint8.join(); // '1,2,3' +uint8.join(" / "); // '1 / 2 / 3' +uint8.join(""); // '123' ``` ## Prothèse d'émulation (_polyfill_) @@ -41,8 +41,8 @@ Il n'existe pas d'objet global _TypedArray_, il faut donc ajouter une prothèse ```js // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.join if (!Uint8Array.prototype.join) { - Object.defineProperty(Uint8Array.prototype, 'join', { - value: Array.prototype.join + Object.defineProperty(Uint8Array.prototype, "join", { + value: Array.prototype.join, }); } ``` diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/keys/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/keys/index.md index fe3ce161cacffe..2793cb036ca5e6 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/keys/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/keys/index.md @@ -13,7 +13,7 @@ La méthode **`keys()`** renvoie un nouvel objet `Array Iterator` contenant les ## Syntaxe ```js -arr.keys() +arr.keys(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/lastindexof/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/lastindexof/index.md index 4a5458fe683434..c0b5c5a313396c 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/lastindexof/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/lastindexof/index.md @@ -6,7 +6,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/TypedArray/lastIndexOf {{JSRef}} -La méthode **`lastIndexOf()`** renvoie le dernier indice (le plus grand) pour lequel un élément donné est trouvé. Si l'élément cherché n'est pas trouvé, la valeur de retour sera -1. Le tableau typé est parcouru dans l'ordre des indices décroissants (de la fin vers le début) à partir de `indexDépart`. Cette méthode utilise le même algorithme que {{jsxref("Array.prototype.lastIndexOf()")}}. Dans le reste de l'article, *TypedArray* correspond à l'un des [types de tableaux typés](/fr/docs/Web/JavaScript/Reference/Objets_globaux/TypedArray#Les_objets_TypedArray). +La méthode **`lastIndexOf()`** renvoie le dernier indice (le plus grand) pour lequel un élément donné est trouvé. Si l'élément cherché n'est pas trouvé, la valeur de retour sera -1. Le tableau typé est parcouru dans l'ordre des indices décroissants (de la fin vers le début) à partir de `indexDépart`. Cette méthode utilise le même algorithme que {{jsxref("Array.prototype.lastIndexOf()")}}. Dans le reste de l'article, _TypedArray_ correspond à l'un des [types de tableaux typés](/fr/docs/Web/JavaScript/Reference/Objets_globaux/TypedArray#Les_objets_TypedArray). {{EmbedInteractiveExample("pages/js/typedarray-lastindexof.html")}} @@ -35,10 +35,10 @@ Le dernier indice du tableau typé pour lequel l'élément a été trouvé ou `- ```js var uint8 = new Uint8Array([2, 5, 9, 2]); -uint8.lastIndexOf(2); // 3 -uint8.lastIndexOf(7); // -1 -uint8.lastIndexOf(2, 3); // 3 -uint8.lastIndexOf(2, 2); // 0 +uint8.lastIndexOf(2); // 3 +uint8.lastIndexOf(7); // -1 +uint8.lastIndexOf(2, 3); // 3 +uint8.lastIndexOf(2, 2); // 0 uint8.lastIndexOf(2, -2); // 0 uint8.lastIndexOf(2, -1); // 3 ``` diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/length/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/length/index.md index 096c1a92a97c27..5af9320aea5436 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/length/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/length/index.md @@ -13,7 +13,7 @@ La propriété **`length`** est un accesseur qui permet de représenter la longu ## Syntaxe ```js -typedarray.length +typedarray.length; ``` ## Description diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/map/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/map/index.md index a3cf4cc354c50f..d5d09a61bf5bca 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/map/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/map/index.md @@ -67,7 +67,7 @@ Ici, on illustre comment une fonction utilisant un argument peut être utilisée ```js var nombres = new Uint8Array([1, 4, 9]); -var doubles = nombres.map(function(num) { +var doubles = nombres.map(function (num) { return num * 2; }); // doubles vaut désormais Uint8Array [2, 8, 18] diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/of/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/of/index.md index 35387bf3cd7e0d..3c9b914b7efcf4 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/of/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/of/index.md @@ -47,10 +47,10 @@ Il existe de légères différences entre {{jsxref("Array.of()")}} et `TypedArra ## Exemples ```js -Uint8Array.of(1); // Uint8Array [ 1 ] +Uint8Array.of(1); // Uint8Array [ 1 ] Int8Array.of("1", "2", "3"); // Int8Array [ 1, 2, 3 ] -Float32Array.of(1, 2, 3); // Float32Array [ 1, 2, 3 ] -Int16Array.of(undefined); // Int16Array [ 0 ] +Float32Array.of(1, 2, 3); // Float32Array [ 1, 2, 3 ] +Int16Array.of(undefined); // Int16Array [ 0 ] ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/reduce/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/reduce/index.md index 5409d9c53275cb..e8011592320d75 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/reduce/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/reduce/index.md @@ -49,7 +49,7 @@ Si le tableau typé est vide et que le paramètre `valeurInitiale` n'a pas été ## Exemples ```js -var total = new Uint8Array([0, 1, 2, 3]).reduce(function(a, b) { +var total = new Uint8Array([0, 1, 2, 3]).reduce(function (a, b) { return a + b; }); // total == 6 diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/reduceright/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/reduceright/index.md index b9580f53208a73..804f8290ada019 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/reduceright/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/reduceright/index.md @@ -43,9 +43,11 @@ La méthode `reduceRight` exécute la fonction `callback` une fois pour chaque L'appel à `reduceRight` utilisant la fonction `callback` ressemble à : ```js -typedarray.reduceRight(function(valeurPrécédente, valeurCourante, index, typedarray) { - // ... -}); +typedarray.reduceRight( + function (valeurPrécédente, valeurCourante, index, typedarray) { + // ... + }, +); ``` Lors du premier appel à la fonction callback, `valeurPrécédente` et `valeurCourante` peuvent être un ou deux valeurs différentes. Si `valeurInitiale` est fournie, `valeurPrécédente` sera alors égale à `valeurInitiale` et `valeurCourante` sera égale à la première valeur du tableau. Si le paramètre `valeurInitiale` n'est pas utilisé, `valeurPrécédente` sera égale au premier élément du tableau typé et `valeurCourante` sera égale au second élément. @@ -55,7 +57,7 @@ Si le tableau typé est vide et que le paramètre `valeurInitiale` n'a pas été ## Exemples ```js -var total = new Uint8Array([0, 1, 2, 3]).reduceRight(function(a, b) { +var total = new Uint8Array([0, 1, 2, 3]).reduceRight(function (a, b) { return a + b; }); // total == 6 diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/slice/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/slice/index.md index bede5dde9b4df1..6ed52c8fb7ac31 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/slice/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/slice/index.md @@ -36,11 +36,11 @@ Si un nouvel élément est ajouté à l'un des deux tableaux typés, l'autre ne ## Exemples ```js -var uint8 = new Uint8Array([1,2,3]); -uint8.slice(1); // Uint8Array [ 2, 3 ] -uint8.slice(2); // Uint8Array [ 3 ] -uint8.slice(-2); // Uint8Array [ 2, 3 ] -uint8.slice(0,1); // Uint8Array [ 1 ] +var uint8 = new Uint8Array([1, 2, 3]); +uint8.slice(1); // Uint8Array [ 2, 3 ] +uint8.slice(2); // Uint8Array [ 3 ] +uint8.slice(-2); // Uint8Array [ 2, 3 ] +uint8.slice(0, 1); // Uint8Array [ 1 ] ``` ## Prothèse d'émulation (_polyfill_) @@ -50,10 +50,10 @@ Il n'existe pas d'objet global intitulé _TypedArray_, la prothèse doit donc un ```js // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.slice if (!Uint8Array.prototype.slice) { - Object.defineProperty(Uint8Array.prototype, 'slice', { - value: function (begin, end){ + Object.defineProperty(Uint8Array.prototype, "slice", { + value: function (begin, end) { return new Uint8Array(Array.prototype.slice.call(this, begin, end)); - } + }, }); } ``` diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/some/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/some/index.md index b7a4a1d057cf4a..edf66ab8b06056 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/some/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/some/index.md @@ -56,7 +56,7 @@ Dans l'exemple qui suit, on teste s'il existe au moins un élément du tableau t function supérieurÀ10(élément, index, array) { return élément > 10; } -new Uint8Array([2, 5, 8, 1, 4]).some(supérieurÀ10); // false +new Uint8Array([2, 5, 8, 1, 4]).some(supérieurÀ10); // false new Uint8Array([12, 5, 8, 1, 4]).some(supérieurÀ10); // true ``` @@ -65,8 +65,8 @@ new Uint8Array([12, 5, 8, 1, 4]).some(supérieurÀ10); // true [Les fonctions fléchées](/fr/docs/Web/JavaScript/Reference/Functions/Arrow_functions) permettent d'utiliser une syntaxe plus concise pour arriver au même résultat : ```js -new Uint8Array([2, 5, 8, 1, 4]).some(elem => elem > 10); // false -new Uint8Array([12, 5, 8, 1, 4]).some(elem => elem > 10); // true +new Uint8Array([2, 5, 8, 1, 4]).some((elem) => elem > 10); // false +new Uint8Array([12, 5, 8, 1, 4]).some((elem) => elem > 10); // true ``` ## Prothèse d'émulation (_polyfill_) @@ -76,8 +76,8 @@ Il n'existe pas d'objet global intitulé _TypedArray_, la prothèse doit donc un ```js // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.slice if (!Uint8Array.prototype.some) { - Object.defineProperty(Uint8Array.prototype, 'some', { - value: Array.prototype.some + Object.defineProperty(Uint8Array.prototype, "some", { + value: Array.prototype.some, }); } ``` diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/sort/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/sort/index.md index 8abfa929b091ab..3062f9fbad36d0 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/sort/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/sort/index.md @@ -13,7 +13,7 @@ La méthode **`sort()`** permet de trier numériquement les éléments d'un tabl ## Syntaxe ```js -typedarray.sort([fonctionComparaison]) +typedarray.sort([fonctionComparaison]); ``` ### Paramètres diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/subarray/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/subarray/index.md index b7dd621f846810..c4e7276d8bbb69 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/subarray/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/subarray/index.md @@ -38,13 +38,13 @@ On notera que cette méthode permet de créer un nouvelle vue sur le tampon (_bu ```js var buffer = new ArrayBuffer(8); var uint8 = new Uint8Array(buffer); -uint8.set([1,2,3]); +uint8.set([1, 2, 3]); console.log(uint8); // Uint8Array [ 1, 2, 3, 0, 0, 0, 0, 0 ] -var sub = uint8.subarray(0,4); +var sub = uint8.subarray(0, 4); -console.log(sub); // Uint8Array [ 1, 2, 3, 0 ] +console.log(sub); // Uint8Array [ 1, 2, 3, 0 ] ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/tolocalestring/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/tolocalestring/index.md index efa1f25b292126..8c2bb6d7f805a9 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/tolocalestring/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/tolocalestring/index.md @@ -11,9 +11,9 @@ La méthode **`toLocaleString()`** renvoie une chaîne de caractères qui repré ## Syntaxe ```js -toLocaleString() -toLocaleString(locales) -toLocaleString(locales, options) +toLocaleString(); +toLocaleString(locales); +toLocaleString(locales, options); ``` ### Paramètres @@ -37,10 +37,10 @@ uint.toLocaleString(); // si on exécute sur un environnement utilisant la locale de-DE // "2.000,500,8.123,12,4.212" -uint.toLocaleString('en-US'); +uint.toLocaleString("en-US"); // "2,000,500,8,123,12,4,212" -uint.toLocaleString('ja-JP', { style: 'currency', currency: 'JPY' }); +uint.toLocaleString("ja-JP", { style: "currency", currency: "JPY" }); // "¥2,000,¥500,¥8,123,¥12,¥4,212" ``` diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/tostring/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/tostring/index.md index 00fe10b90b1d87..65327a0caa72dd 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/tostring/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/tostring/index.md @@ -13,7 +13,7 @@ La méthode **`toString()`** renvoie une chaîne de caractères qui représente ## Syntaxe ```js -typedarray.toString() +typedarray.toString(); ``` ### Valeur de retour @@ -25,7 +25,7 @@ Une chaîne de caractères qui représente les éléments du tableau typé. Les objets {{jsxref("TypedArray")}} surchargent la méthode `toString` de {{jsxref("Object")}}. Pour les objets `TypedArray`, la méthode `toString` fusionne le tableau et renovoie une chaîne de caractères contenant les éléments du tableau, chacun séparés par une virgule. Par exemple : ```js -var numbers = new Uint8Array([2, 5, 8, 1, 4]) +var numbers = new Uint8Array([2, 5, 8, 1, 4]); numbers.toString(); // "2,5,8,1,4" ``` @@ -36,7 +36,7 @@ JavaScript appelle automatiquement la méthode `toString()` lorsqu'un tableau ty Si un navigateur ne prend pas encore en charge la méthode `TypedArray.prototype.toString()`, le moteur JavaScript utilisera la méthode `toString` rattachée à {{jsxref("Object")}} : ```js -var numbers = new Uint8Array([2, 5, 8, 1, 4]) +var numbers = new Uint8Array([2, 5, 8, 1, 4]); numbers.toString(); // "[object Uint8Array]" ``` diff --git a/files/fr/web/javascript/reference/global_objects/typedarray/values/index.md b/files/fr/web/javascript/reference/global_objects/typedarray/values/index.md index afb5a3d9767c41..681f466cc5cf1f 100644 --- a/files/fr/web/javascript/reference/global_objects/typedarray/values/index.md +++ b/files/fr/web/javascript/reference/global_objects/typedarray/values/index.md @@ -13,7 +13,7 @@ La méthode **`values()`** renvoie un nouvel objet `Array Iterator` qui contient ## Syntaxe ```js -typedArr.values() +typedArr.values(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/typeerror/index.md b/files/fr/web/javascript/reference/global_objects/typeerror/index.md index c73b60791e8cea..f8477721806df0 100644 --- a/files/fr/web/javascript/reference/global_objects/typeerror/index.md +++ b/files/fr/web/javascript/reference/global_objects/typeerror/index.md @@ -42,13 +42,13 @@ Une exception `TypeError` peut être levée lorsque : try { null.f(); } catch (e) { - console.log(e instanceof TypeError); // true - console.log(e.message); // "null has no properties" - console.log(e.name); // "TypeError" - console.log(e.fileName); // "Scratchpad/1" - console.log(e.lineNumber); // 2 - console.log(e.columnNumber); // 2 - console.log(e.stack); // "@Scratchpad/2:2:3\n" + console.log(e instanceof TypeError); // true + console.log(e.message); // "null has no properties" + console.log(e.name); // "TypeError" + console.log(e.fileName); // "Scratchpad/1" + console.log(e.lineNumber); // 2 + console.log(e.columnNumber); // 2 + console.log(e.stack); // "@Scratchpad/2:2:3\n" } ``` @@ -56,15 +56,15 @@ try { ```js try { - throw new TypeError('Coucou', 'unFichier.js', 10); + throw new TypeError("Coucou", "unFichier.js", 10); } catch (e) { - console.log(e instanceof TypeError); // true - console.log(e.message); // "Coucou" - console.log(e.name); // "TypeError" - console.log(e.fileName); // "unFichier.js" - console.log(e.lineNumber); // 10 - console.log(e.columnNumber); // 0 - console.log(e.stack); // "@Scratchpad/2:2:9\n" + console.log(e instanceof TypeError); // true + console.log(e.message); // "Coucou" + console.log(e.name); // "TypeError" + console.log(e.fileName); // "unFichier.js" + console.log(e.lineNumber); // 10 + console.log(e.columnNumber); // 0 + console.log(e.stack); // "@Scratchpad/2:2:9\n" } ``` diff --git a/files/fr/web/javascript/reference/global_objects/typeerror/typeerror/index.md b/files/fr/web/javascript/reference/global_objects/typeerror/typeerror/index.md index 7fe44d70786d76..480a72315ecd87 100644 --- a/files/fr/web/javascript/reference/global_objects/typeerror/typeerror/index.md +++ b/files/fr/web/javascript/reference/global_objects/typeerror/typeerror/index.md @@ -11,10 +11,10 @@ Le constructeur **`TypeError()`** permet de créer un objet représentant une er ## Syntaxe ```js -new TypeError() -new TypeError(message) -new TypeError(message, nomFichier) -new TypeError(message, nomFichier, numeroLigne) +new TypeError(); +new TypeError(message); +new TypeError(message, nomFichier); +new TypeError(message, nomFichier, numeroLigne); ``` ### Paramètres @@ -34,13 +34,13 @@ new TypeError(message, nomFichier, numeroLigne) try { null.f(); } catch (e) { - console.log(e instanceof TypeError); // true - console.log(e.message); // "null has no properties" - console.log(e.name); // "TypeError" - console.log(e.fileName); // "Scratchpad/1" - console.log(e.lineNumber); // 2 - console.log(e.columnNumber); // 2 - console.log(e.stack); // "@Scratchpad/2:2:3\n" + console.log(e instanceof TypeError); // true + console.log(e.message); // "null has no properties" + console.log(e.name); // "TypeError" + console.log(e.fileName); // "Scratchpad/1" + console.log(e.lineNumber); // 2 + console.log(e.columnNumber); // 2 + console.log(e.stack); // "@Scratchpad/2:2:3\n" } ``` @@ -48,15 +48,15 @@ try { ```js try { - throw new TypeError('Coucou', 'unFichier.js', 10); + throw new TypeError("Coucou", "unFichier.js", 10); } catch (e) { - console.log(e instanceof TypeError); // true - console.log(e.message); // "Coucou" - console.log(e.name); // "TypeError" - console.log(e.fileName); // "unFichier.js" - console.log(e.lineNumber); // 10 - console.log(e.columnNumber); // 0 - console.log(e.stack); // "@Scratchpad/2:2:9\n" + console.log(e instanceof TypeError); // true + console.log(e.message); // "Coucou" + console.log(e.name); // "TypeError" + console.log(e.fileName); // "unFichier.js" + console.log(e.lineNumber); // 10 + console.log(e.columnNumber); // 0 + console.log(e.stack); // "@Scratchpad/2:2:9\n" } ``` diff --git a/files/fr/web/javascript/reference/global_objects/uint16array/index.md b/files/fr/web/javascript/reference/global_objects/uint16array/index.md index c416de72726e4c..c9ae409149b07b 100644 --- a/files/fr/web/javascript/reference/global_objects/uint16array/index.md +++ b/files/fr/web/javascript/reference/global_objects/uint16array/index.md @@ -125,7 +125,7 @@ console.log(uint16.length); // 2 console.log(uint16.BYTES_PER_ELEMENT); // 2 // Construction à partir d'un tableau -var arr = new Uint16Array([21,31]); +var arr = new Uint16Array([21, 31]); console.log(arr[1]); // 31 // Construction à partir d'un tableau typé @@ -138,7 +138,9 @@ var buffer = new ArrayBuffer(8); var z = new Uint16Array(buffer, 0, 4); // Construction à partir d'un itérable -var iterable = function*(){ yield* [1,2,3]; }(); +var iterable = (function* () { + yield* [1, 2, 3]; +})(); var uint16 = new Uint16Array(iterable); // Uint16Array[1, 2, 3] ``` diff --git a/files/fr/web/javascript/reference/global_objects/uint16array/uint16array/index.md b/files/fr/web/javascript/reference/global_objects/uint16array/uint16array/index.md index 4b01d1f7d28e4c..ac999a7fdbf6d6 100644 --- a/files/fr/web/javascript/reference/global_objects/uint16array/uint16array/index.md +++ b/files/fr/web/javascript/reference/global_objects/uint16array/uint16array/index.md @@ -61,7 +61,7 @@ console.log(uint16.length); // 2 console.log(uint16.BYTES_PER_ELEMENT); // 2 // À partir d'un tableau -const arr = new Uint16Array([21,31]); +const arr = new Uint16Array([21, 31]); console.log(arr[1]); // 31 // À partir d'un autre tableau typé @@ -74,7 +74,9 @@ const buffer = new ArrayBuffer(8); const z = new Uint16Array(buffer, 0, 4); // À partir d'un itérable -const iterable = function*(){ yield* [1,2,3]; }(); +const iterable = (function* () { + yield* [1, 2, 3]; +})(); const uint16_from_iterable = new Uint16Array(iterable); // Uint16Array[1, 2, 3] ``` diff --git a/files/fr/web/javascript/reference/global_objects/uint32array/index.md b/files/fr/web/javascript/reference/global_objects/uint32array/index.md index 58095b6c3580b7..75ea4e65b2bfbb 100644 --- a/files/fr/web/javascript/reference/global_objects/uint32array/index.md +++ b/files/fr/web/javascript/reference/global_objects/uint32array/index.md @@ -125,7 +125,7 @@ console.log(uint32.length); // 2 console.log(uint32.BYTES_PER_ELEMENT); // 4 // Construction à partir d'un tableau -var arr = new Uint32Array([21,31]); +var arr = new Uint32Array([21, 31]); console.log(arr[1]); // 31 // Construction à partir d'un tableau typé @@ -138,7 +138,9 @@ var buffer = new ArrayBuffer(16); var z = new Uint32Array(buffer, 0, 4); // Construction à partir d'un itérable -var iterable = function*(){ yield* [1,2,3]; }(); +var iterable = (function* () { + yield* [1, 2, 3]; +})(); var uint32 = new Uint32Array(iterable); // Uint32Array[1, 2, 3] ``` diff --git a/files/fr/web/javascript/reference/global_objects/uint32array/uint32array/index.md b/files/fr/web/javascript/reference/global_objects/uint32array/uint32array/index.md index 7aededd9305c0e..aee214de1ed6e2 100644 --- a/files/fr/web/javascript/reference/global_objects/uint32array/uint32array/index.md +++ b/files/fr/web/javascript/reference/global_objects/uint32array/uint32array/index.md @@ -45,7 +45,7 @@ console.log(uint32.length); // 2 console.log(uint32.BYTES_PER_ELEMENT); // 4 // À partir d'un tableau -let arr = new Uint32Array([21,31]); +let arr = new Uint32Array([21, 31]); console.log(arr[1]); // 31 // À partir d'un autre tableau typé @@ -58,7 +58,9 @@ let buffer = new ArrayBuffer(16); let z = new Uint32Array(buffer, 0, 4); // À partir d'un itérable -let iterable = function*(){ yield* [1,2,3]; }(); +let iterable = (function* () { + yield* [1, 2, 3]; +})(); let uint32 = new Uint32Array(iterable); // Uint32Array[1, 2, 3] ``` diff --git a/files/fr/web/javascript/reference/global_objects/uint8array/index.md b/files/fr/web/javascript/reference/global_objects/uint8array/index.md index 746670d7e9742a..7121e1770c9a19 100644 --- a/files/fr/web/javascript/reference/global_objects/uint8array/index.md +++ b/files/fr/web/javascript/reference/global_objects/uint8array/index.md @@ -43,7 +43,7 @@ Le tableau typé **`Uint8Array`** représente un tableau d'entiers non signés, - [`Uint8Array.prototype.copyWithin()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/copyWithin) - : Copie une suite d'éléments d'un tableau dans le tableau. Voir également [`Array.prototype.copyWithin()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin). - [`Uint8Array.prototype.entries()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/entries) - - : Renvoie un nouvel *itérateur de tableau* qui contient les paires clé/valeur pour chaque indice du tableau. Voir également [`Array.prototype.entries()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/entries). + - : Renvoie un nouvel _itérateur de tableau_ qui contient les paires clé/valeur pour chaque indice du tableau. Voir également [`Array.prototype.entries()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/entries). - [`Uint8Array.prototype.every()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/every) - : Teste si l'ensemble des éléments du tableau remplissent une certaine condition donnée par une fonction de test. Voir également [`Array.prototype.every()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/every). - [`Uint8Array.prototype.fill()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill) @@ -63,7 +63,7 @@ Le tableau typé **`Uint8Array`** représente un tableau d'entiers non signés, - [`Uint8Array.prototype.join()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/join) - : Fusionne l'ensemble des éléments du tableau en une chaîne de caractères. Voir également [`Array.prototype.join()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/join). - [`Uint8Array.prototype.keys()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/keys) - - : Renvoie un nouvel *itérateur de tableau* qui contient les clés de chaque indice du tableau. Voir également [`Array.prototype.keys()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/keys). + - : Renvoie un nouvel _itérateur de tableau_ qui contient les clés de chaque indice du tableau. Voir également [`Array.prototype.keys()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/keys). - [`Uint8Array.prototype.lastIndexOf()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/lastIndexOf) - : Renvoie le dernier indice (le plus élevé) d'un élément du tableau qui est égal à la valeur fournie. Si aucun élément ne correspond, la valeur `-1` sera renvoyée. Voir également [`Array.prototype.lastIndexOf()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf). - [`Uint8Array.prototype.map()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/map) @@ -85,13 +85,13 @@ Le tableau typé **`Uint8Array`** représente un tableau d'entiers non signés, - [`Uint8Array.prototype.subarray()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray) - : Renvoie un nouvel objet `Uint8Array` qui est le fragment du tableau courant, entre les indices de début et de fin donnés. - [`Uint8Array.prototype.values()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/values) - - : Renvoie un nouvel *itérateur de tableau* qui contient les valeurs correspondantes à chaque indice du tableau. Voir également [`Array.prototype.values()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/values). + - : Renvoie un nouvel _itérateur de tableau_ qui contient les valeurs correspondantes à chaque indice du tableau. Voir également [`Array.prototype.values()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/values). - [`Uint8Array.prototype.toLocaleString()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/toLocaleString) - : Renvoie une chaîne de caractères localisée qui représente le tableau et ses éléments. Voir également [`Array.prototype.toLocaleString()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString). - [`Uint8Array.prototype.toString()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/toString) - : Renvoie une chaîne de caractères qui représente le tableau et ses éléments. Voir également [`Array.prototype.toString()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/toString). - [`Uint8Array.prototype[@@iterator]()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/@@iterator) - - : Renvoie un nouvel *itérateur de tableau* qui contient les valeurs correspondantes à chaque indice du tableau. + - : Renvoie un nouvel _itérateur de tableau_ qui contient les valeurs correspondantes à chaque indice du tableau. ## Exemples @@ -106,7 +106,7 @@ console.log(uint8.length); // 2 console.log(uint8.BYTES_PER_ELEMENT); // 1 // Construction à partir d'un tableau -let arr = new Uint8Array([21,31]); +let arr = new Uint8Array([21, 31]); console.log(arr[1]); // 31 // Construction à partir d'un tableau typé @@ -119,7 +119,9 @@ let buffer = new ArrayBuffer(8); let z = new Uint8Array(buffer, 1, 4); // Construction à partir d'un itérable -let iterable = function*(){ yield* [1,2,3]; }(); +let iterable = (function* () { + yield* [1, 2, 3]; +})(); let uint8 = new Uint8Array(iterable); // Uint8Array[1, 2, 3] ``` diff --git a/files/fr/web/javascript/reference/global_objects/uint8array/uint8array/index.md b/files/fr/web/javascript/reference/global_objects/uint8array/uint8array/index.md index b851d65961a798..df9941fa145b4e 100644 --- a/files/fr/web/javascript/reference/global_objects/uint8array/uint8array/index.md +++ b/files/fr/web/javascript/reference/global_objects/uint8array/uint8array/index.md @@ -45,7 +45,7 @@ console.log(uint8.length); // 2 console.log(uint8.BYTES_PER_ELEMENT); // 1 // Construction à partir d'un tableau -let arr = new Uint8Array([21,31]); +let arr = new Uint8Array([21, 31]); console.log(arr[1]); // 31 // Construction à partir d'un tableau typé @@ -58,7 +58,9 @@ let buffer = new ArrayBuffer(8); let z = new Uint8Array(buffer, 1, 4); // Construction à partir d'un itérable -let iterable = function*(){ yield* [1,2,3]; }(); +let iterable = (function* () { + yield* [1, 2, 3]; +})(); let uint8 = new Uint8Array(iterable); // Uint8Array[1, 2, 3] ``` diff --git a/files/fr/web/javascript/reference/global_objects/uint8clampedarray/index.md b/files/fr/web/javascript/reference/global_objects/uint8clampedarray/index.md index 652d71a356cf59..2074c0aa897382 100644 --- a/files/fr/web/javascript/reference/global_objects/uint8clampedarray/index.md +++ b/files/fr/web/javascript/reference/global_objects/uint8clampedarray/index.md @@ -43,7 +43,7 @@ Le tableau typé **`Uint8ClampedArray`** permet de représenter un tableau d'ent - [`Uint8ClampedArray.prototype.copyWithin()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/copyWithin) - : Copie une suite d'éléments d'un tableau dans le tableau. Voir également [`Array.prototype.copyWithin()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin). - [`Uint8ClampedArray.prototype.entries()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/entries) - - : Renvoie un nouvel *itérateur de tableau* qui contient les paires clé/valeur pour chaque indice du tableau. Voir également [`Array.prototype.entries()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/entries). + - : Renvoie un nouvel _itérateur de tableau_ qui contient les paires clé/valeur pour chaque indice du tableau. Voir également [`Array.prototype.entries()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/entries). - [`Uint8ClampedArray.prototype.every()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/every) - : Teste si l'ensemble des éléments du tableau remplissent une certaine condition donnée par une fonction de test. Voir également [`Array.prototype.every()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/every). - [`Uint8ClampedArray.prototype.fill()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill) @@ -63,7 +63,7 @@ Le tableau typé **`Uint8ClampedArray`** permet de représenter un tableau d'ent - [`Uint8ClampedArray.prototype.join()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/join) - : Fusionne l'ensemble des éléments du tableau en une chaîne de caractères. Voir également [`Array.prototype.join()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/join). - [`Uint8ClampedArray.prototype.keys()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/keys) - - : Renvoie un nouvel *itérateur de tableau* qui contient les clés de chaque indice du tableau. Voir également [`Array.prototype.keys()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/keys). + - : Renvoie un nouvel _itérateur de tableau_ qui contient les clés de chaque indice du tableau. Voir également [`Array.prototype.keys()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/keys). - [`Uint8ClampedArray.prototype.lastIndexOf()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/lastIndexOf) - : Renvoie le dernier indice (le plus élevé) d'un élément du tableau qui est égal à la valeur fournie. Si aucun élément ne correspond, la valeur `-1` sera renvoyée. Voir également [`Array.prototype.lastIndexOf()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf). - [`Uint8ClampedArray.prototype.map()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/map) @@ -85,13 +85,13 @@ Le tableau typé **`Uint8ClampedArray`** permet de représenter un tableau d'ent - [`Uint8ClampedArray.prototype.subarray()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray) - : Renvoie un nouvel objet `Uint8ClampedArray` qui est le fragment du tableau courant, entre les indices de début et de fin donnés. - [`Uint8ClampedArray.prototype.values()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/values) - - : Renvoie un nouvel *itérateur de tableau* qui contient les valeurs correspondantes à chaque indice du tableau. Voir également [`Array.prototype.values()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/values). + - : Renvoie un nouvel _itérateur de tableau_ qui contient les valeurs correspondantes à chaque indice du tableau. Voir également [`Array.prototype.values()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/values). - [`Uint8ClampedArray.prototype.toLocaleString()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/toLocaleString) - : Renvoie une chaîne de caractères localisée qui représente le tableau et ses éléments. Voir également [`Array.prototype.toLocaleString()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString). - [`Uint8ClampedArray.prototype.toString()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/toString) - : Renvoie une chaîne de caractères qui représente le tableau et ses éléments. Voir également [`Array.prototype.toString()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/toString). - [`Uint8ClampedArray.prototype[@@iterator]()`](/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/@@iterator) - - : Renvoie un nouvel *itérateur de tableau* qui contient les valeurs correspondantes à chaque indice du tableau. + - : Renvoie un nouvel _itérateur de tableau_ qui contient les valeurs correspondantes à chaque indice du tableau. ## Exemples @@ -108,7 +108,7 @@ console.log(uintc8.length); // 2 console.log(uintc8.BYTES_PER_ELEMENT); // 1 // Construction à partir d'un tableau -let arr = new Uint8ClampedArray([21,31]); +let arr = new Uint8ClampedArray([21, 31]); console.log(arr[1]); // 31 // Construction à partir d'un autre TypedArray @@ -121,7 +121,9 @@ let buffer = new ArrayBuffer(8); let z = new Uint8ClampedArray(buffer, 1, 4); // Construction à partir d'un itérable -let iterable = function*(){ yield* [1,2,3]; }(); +let iterable = (function* () { + yield* [1, 2, 3]; +})(); let uintc8 = new Uint8ClampedArray(iterable); // Uint8ClampedArray[1, 2, 3] ``` diff --git a/files/fr/web/javascript/reference/global_objects/uint8clampedarray/uint8clampedarray/index.md b/files/fr/web/javascript/reference/global_objects/uint8clampedarray/uint8clampedarray/index.md index f76aacd728bc46..20b90f7085504f 100644 --- a/files/fr/web/javascript/reference/global_objects/uint8clampedarray/uint8clampedarray/index.md +++ b/files/fr/web/javascript/reference/global_objects/uint8clampedarray/uint8clampedarray/index.md @@ -47,7 +47,7 @@ console.log(uintc8.length); // 2 console.log(uintc8.BYTES_PER_ELEMENT); // 1 // À partir d'un tableau -let arr = new Uint8ClampedArray([21,31]); +let arr = new Uint8ClampedArray([21, 31]); console.log(arr[1]); // 31 // À partir d'un autre tableau typé @@ -60,7 +60,9 @@ let buffer = new ArrayBuffer(8); let z = new Uint8ClampedArray(buffer, 1, 4); // À partir d'un itérable -let iterable = function*(){ yield* [1,2,3]; }(); +let iterable = (function* () { + yield* [1, 2, 3]; +})(); let uintc8 = new Uint8ClampedArray(iterable); // Uint8ClampedArray[1, 2, 3] ``` diff --git a/files/fr/web/javascript/reference/global_objects/undefined/index.md b/files/fr/web/javascript/reference/global_objects/undefined/index.md index 34c0c20e3bea0c..7f6f9fb4509c2a 100644 --- a/files/fr/web/javascript/reference/global_objects/undefined/index.md +++ b/files/fr/web/javascript/reference/global_objects/undefined/index.md @@ -15,12 +15,12 @@ La propriété globale **`undefined`** représente la valeur primitive [`undefin ## Syntaxe ```js -undefined +undefined; ``` ## Description -`undefined` est une propriété de *l'objet global*, c'est-à-dire qu'elle est accessible globalement. La valeur initiale d'`undefined` est la valeur primitive [`undefined`](/fr/docs/Glossary/undefined). +`undefined` est une propriété de _l'objet global_, c'est-à-dire qu'elle est accessible globalement. La valeur initiale d'`undefined` est la valeur primitive [`undefined`](/fr/docs/Glossary/undefined). Dans les navigateurs modernes (JavaScript 1.8.5 / Firefox 4+), d'après la spécification ECMAScript 5, `undefined` est une propriété non-configurable et non accessible en écriture. Si, toutefois, elle peut être modifiée dans l'environnement utilisé, il faut éviter de l'écraser. @@ -32,15 +32,15 @@ Une variable pour laquelle aucune valeur n'a été assignée sera de type `undef > // À NE PAS FAIRE > > // affiche "toto string" dans la console -> (function() { -> const undefined = 'toto'; -> console.log(undefined, typeof undefined); +> (function () { +> const undefined = "toto"; +> console.log(undefined, typeof undefined); > })(); > > // affiche "toto string" dans la console -> (function(undefined) { +> (function (undefined) { > console.log(undefined, typeof undefined); -> })('toto'); +> })("toto"); > ``` ## Exemples @@ -52,14 +52,13 @@ Il est possible d'utiliser `undefined` et les opérateurs stricts pour l'égalit ```js let x; if (x === undefined) { - // ces instructions seront exécutées -} -else { - // ces instructions ne seront pas exécutées + // ces instructions seront exécutées +} else { + // ces instructions ne seront pas exécutées } ``` -> **Note :** L'opérateur d'égalité stricte doit être utilisé ici plutôt que l'opérateur *d'égalité simple*. En effet, `x == undefined` vérifie également si `x` vaut `null`, tandis que l'égalité stricte ne le fait pas. `null` n'est pas équivalent à `undefined`. +> **Note :** L'opérateur d'égalité stricte doit être utilisé ici plutôt que l'opérateur _d'égalité simple_. En effet, `x == undefined` vérifie également si `x` vaut `null`, tandis que l'égalité stricte ne le fait pas. `null` n'est pas équivalent à `undefined`. > > Voir la page sur les [opérateurs de comparaison](/fr/docs/Web/JavaScript/Reference/Operators) pour plus de détails. @@ -69,8 +68,8 @@ L'opérateur [`typeof`](/fr/docs/Web/JavaScript/Reference/Operators/typeof) peut ```js let x; -if (typeof x === 'undefined') { - // ces instructions seront exécutées +if (typeof x === "undefined") { + // ces instructions seront exécutées } ``` @@ -78,21 +77,22 @@ Une des raisons pour utiliser l'opérateur [`typeof`](/fr/docs/Web/JavaScript/Re ```js // x n'a pas encore été défini -if (typeof x === 'undefined') { // donnera true sans erreur - // ces instructions seront exécutées +if (typeof x === "undefined") { + // donnera true sans erreur + // ces instructions seront exécutées } -if (x === undefined) { // déclenche une ReferenceError - +if (x === undefined) { + // déclenche une ReferenceError } ``` Il existe toutefois une autre alternative. Puisque JavaScript utilise la portée statique, on saura qu'une variable a été déclarée si elle est définie dans un contexte englobant. -La portée globale est rattachée à [l'objet global](/fr/docs/Web/JavaScript/Reference/Global_Objects/globalThis), alors on peut vérifier l'existence d'une variable dans le contexte global en examinant la présence d'une propriété sur *l'objet global* via l'opérateur [`in`](/fr/docs/Web/JavaScript/Reference/Operators/in). Par exemple : +La portée globale est rattachée à [l'objet global](/fr/docs/Web/JavaScript/Reference/Global_Objects/globalThis), alors on peut vérifier l'existence d'une variable dans le contexte global en examinant la présence d'une propriété sur _l'objet global_ via l'opérateur [`in`](/fr/docs/Web/JavaScript/Reference/Operators/in). Par exemple : ```js -if ('x' in window) { +if ("x" in window) { // ces instructions seront exécutées uniquement // si x est défini dans la portée globale } diff --git a/files/fr/web/javascript/reference/global_objects/unescape/index.md b/files/fr/web/javascript/reference/global_objects/unescape/index.md index 0c03368cedfe7c..3f80ca72f44425 100644 --- a/files/fr/web/javascript/reference/global_objects/unescape/index.md +++ b/files/fr/web/javascript/reference/global_objects/unescape/index.md @@ -18,7 +18,7 @@ La fonction dépréciée **`unescape()`** calcule une nouvelle chaîne de caract ## Syntaxe ```js -unescape(str) +unescape(str); ``` ### Paramètres @@ -37,9 +37,9 @@ La fonction `unescape` est une propriété de l'_objet global_. ## Exemples ```js -unescape("abc123"); // "abc123" -unescape("%E4%F6%FC"); // "äöü" -unescape("%u0107"); // "ć" +unescape("abc123"); // "abc123" +unescape("%E4%F6%FC"); // "äöü" +unescape("%u0107"); // "ć" ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/urierror/index.md b/files/fr/web/javascript/reference/global_objects/urierror/index.md index 3fc5a8c4d7b454..1e634a39d67344 100644 --- a/files/fr/web/javascript/reference/global_objects/urierror/index.md +++ b/files/fr/web/javascript/reference/global_objects/urierror/index.md @@ -34,15 +34,15 @@ L'objet **`URIError`** représente une erreur renvoyée lorsqu'une fonction de m ```js try { - decodeURIComponent('%') + decodeURIComponent("%"); } catch (e) { - console.log(e instanceof URIError) // true - console.log(e.message) // "malformed URI sequence" - console.log(e.name) // "URIError" - console.log(e.fileName) // "Scratchpad/1" - console.log(e.lineNumber) // 2 - console.log(e.columnNumber) // 2 - console.log(e.stack) // "@Scratchpad/2:2:3\n" + console.log(e instanceof URIError); // true + console.log(e.message); // "malformed URI sequence" + console.log(e.name); // "URIError" + console.log(e.fileName); // "Scratchpad/1" + console.log(e.lineNumber); // 2 + console.log(e.columnNumber); // 2 + console.log(e.stack); // "@Scratchpad/2:2:3\n" } ``` @@ -50,15 +50,15 @@ try { ```js try { - throw new URIError('Coucou', 'unFichier.js', 10) + throw new URIError("Coucou", "unFichier.js", 10); } catch (e) { - console.log(e instanceof URIError) // true - console.log(e.message) // "Coucou" - console.log(e.name) // "URIError" - console.log(e.fileName) // "unFichier.js" - console.log(e.lineNumber) // 10 - console.log(e.columnNumber) // 0 - console.log(e.stack) // "@Scratchpad/2:2:9\n" + console.log(e instanceof URIError); // true + console.log(e.message); // "Coucou" + console.log(e.name); // "URIError" + console.log(e.fileName); // "unFichier.js" + console.log(e.lineNumber); // 10 + console.log(e.columnNumber); // 0 + console.log(e.stack); // "@Scratchpad/2:2:9\n" } ``` diff --git a/files/fr/web/javascript/reference/global_objects/urierror/urierror/index.md b/files/fr/web/javascript/reference/global_objects/urierror/urierror/index.md index 90a6ec2afcdaa3..ba655578570074 100644 --- a/files/fr/web/javascript/reference/global_objects/urierror/urierror/index.md +++ b/files/fr/web/javascript/reference/global_objects/urierror/urierror/index.md @@ -11,10 +11,10 @@ Le constructeur **`URIError()`** permet de créer une erreur lorsqu'une fonction ## Syntaxe ```js -new URIError() -new URIError(message) -new URIError(message, fileName) -new URIError(message, fileName, lineNumber) +new URIError(); +new URIError(message); +new URIError(message, fileName); +new URIError(message, fileName, lineNumber); ``` ### Paramètres @@ -32,15 +32,15 @@ new URIError(message, fileName, lineNumber) ```js try { - decodeURIComponent('%') + decodeURIComponent("%"); } catch (e) { - console.log(e instanceof URIError) // true - console.log(e.message) // "malformed URI sequence" - console.log(e.name) // "URIError" - console.log(e.fileName) // "Scratchpad/1" - console.log(e.lineNumber) // 2 - console.log(e.columnNumber) // 2 - console.log(e.stack) // "@Scratchpad/2:2:3\n" + console.log(e instanceof URIError); // true + console.log(e.message); // "malformed URI sequence" + console.log(e.name); // "URIError" + console.log(e.fileName); // "Scratchpad/1" + console.log(e.lineNumber); // 2 + console.log(e.columnNumber); // 2 + console.log(e.stack); // "@Scratchpad/2:2:3\n" } ``` @@ -48,15 +48,15 @@ try { ```js try { - throw new URIError('Coucou', 'unFichier.js', 10) + throw new URIError("Coucou", "unFichier.js", 10); } catch (e) { - console.log(e instanceof URIError) // true - console.log(e.message) // "Coucou" - console.log(e.name) // "URIError" - console.log(e.fileName) // "unFichier.js" - console.log(e.lineNumber) // 10 - console.log(e.columnNumber) // 0 - console.log(e.stack) // "@Scratchpad/2:2:9\n" + console.log(e instanceof URIError); // true + console.log(e.message); // "Coucou" + console.log(e.name); // "URIError" + console.log(e.fileName); // "unFichier.js" + console.log(e.lineNumber); // 10 + console.log(e.columnNumber); // 0 + console.log(e.stack); // "@Scratchpad/2:2:9\n" } ``` diff --git a/files/fr/web/javascript/reference/global_objects/weakmap/delete/index.md b/files/fr/web/javascript/reference/global_objects/weakmap/delete/index.md index 20f322f4c5cd72..666d1550081ede 100644 --- a/files/fr/web/javascript/reference/global_objects/weakmap/delete/index.md +++ b/files/fr/web/javascript/reference/global_objects/weakmap/delete/index.md @@ -33,7 +33,7 @@ wm.set(window, "toto"); wm.delete(window); // Renvoie true. La suppression a bien eu lieu. -wm.has(window); // Renvoie false. L'objet window n'est plus dans la WeakMap. +wm.has(window); // Renvoie false. L'objet window n'est plus dans la WeakMap. ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/weakmap/get/index.md b/files/fr/web/javascript/reference/global_objects/weakmap/get/index.md index 87147b8d670c70..7c366e386a82fa 100644 --- a/files/fr/web/javascript/reference/global_objects/weakmap/get/index.md +++ b/files/fr/web/javascript/reference/global_objects/weakmap/get/index.md @@ -32,7 +32,7 @@ var wm = new WeakMap(); wm.set(window, "toto"); wm.get(window); // Renvoie "toto" -wm.get("machin"); // Renvoie undefined. +wm.get("machin"); // Renvoie undefined. ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/weakmap/has/index.md b/files/fr/web/javascript/reference/global_objects/weakmap/has/index.md index 04ddf2068e5b7f..e0cb11aa3841c7 100644 --- a/files/fr/web/javascript/reference/global_objects/weakmap/has/index.md +++ b/files/fr/web/javascript/reference/global_objects/weakmap/has/index.md @@ -32,7 +32,7 @@ var wm = new WeakMap(); wm.set(window, "toto"); wm.has(window); // renvoie true -wm.has("machin"); // renvoie false +wm.has("machin"); // renvoie false ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/weakmap/index.md b/files/fr/web/javascript/reference/global_objects/weakmap/index.md index 6d7141490925c6..813af9d3f8242f 100644 --- a/files/fr/web/javascript/reference/global_objects/weakmap/index.md +++ b/files/fr/web/javascript/reference/global_objects/weakmap/index.md @@ -52,11 +52,11 @@ Grâce aux objets natifs `WeakMap`, les références vers les clés sont faibles ```js var wm1 = new WeakMap(), - wm2 = new WeakMap(), - wm3 = new WeakMap(); + wm2 = new WeakMap(), + wm3 = new WeakMap(); var o1 = {}, - o2 = function(){}, - o3 = window; + o2 = function () {}, + o3 = window; wm1.set(o1, 37); wm1.set(o2, "azerty"); @@ -75,9 +75,9 @@ wm2.has(o3); // true (même si la valeur est 'undefined') wm3.set(o1, 37); wm3.get(o1); // 37 -wm1.has(o1); // true +wm1.has(o1); // true wm1.delete(o1); -wm1.has(o1); // false +wm1.has(o1); // false ``` ### Implémenter une classe semblable à `WeakMap` avec une méthode .clear() @@ -85,23 +85,23 @@ wm1.has(o1); // false ```js class ClearableWeakMap { constructor(init) { - this._wm = new WeakMap(init) + this._wm = new WeakMap(init); } clear() { - this._wm = new WeakMap() + this._wm = new WeakMap(); } delete(k) { - return this._wm.delete(k) + return this._wm.delete(k); } get(k) { - return this._wm.get(k) + return this._wm.get(k); } has(k) { - return this._wm.has(k) + return this._wm.has(k); } set(k, v) { - this._wm.set(k, v) - return this + this._wm.set(k, v); + return this; } } ``` @@ -116,7 +116,7 @@ class ClearableWeakMap { ## Voir aussi -- Une prothèse (*polyfill*) de `WeakMap` est disponible dans [`core-js`](https://github.com/zloirock/core-js#weakmap) +- Une prothèse (_polyfill_) de `WeakMap` est disponible dans [`core-js`](https://github.com/zloirock/core-js#weakmap) - [Le guide sur les collections à clé JavaScript](/fr/docs/Web/JavaScript/Guide/Keyed_collections) - [Masquer des détails d'implémentation avec les WeakMaps ECMAScript 2015](https://fitzgeraldnick.com/weblog/53/) (en anglais) - [`Map`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Map) diff --git a/files/fr/web/javascript/reference/global_objects/weakmap/weakmap/index.md b/files/fr/web/javascript/reference/global_objects/weakmap/weakmap/index.md index 2dc681e5f1bb9c..15bd28079dae83 100644 --- a/files/fr/web/javascript/reference/global_objects/weakmap/weakmap/index.md +++ b/files/fr/web/javascript/reference/global_objects/weakmap/weakmap/index.md @@ -11,8 +11,8 @@ Le **constructeur `WeakMap()`** permet de créer un nouvel objet [`WeakMap`](/fr ## Syntaxe ```js -new WeakMap() -new WeakMap(iterable) +new WeakMap(); +new WeakMap(iterable); ``` ### Paramètres @@ -30,11 +30,11 @@ const wm2 = new WeakMap(); const wm3 = new WeakMap(); const o1 = {}; -const o2 = function() {}; +const o2 = function () {}; const o3 = window; wm1.set(o1, 37); -wm1.set(o2, 'azerty'); +wm1.set(o2, "azerty"); wm2.set(o1, o2); // une valeur peut être de n'importe quel type (objet ou fonction) wm2.set(o3, undefined); wm2.set(wm1, wm2); // les clés et les valeurs peuvent être des objets, même des WeakMaps diff --git a/files/fr/web/javascript/reference/global_objects/weakref/deref/index.md b/files/fr/web/javascript/reference/global_objects/weakref/deref/index.md index ecead3b6224140..ec691d61ff9cbb 100644 --- a/files/fr/web/javascript/reference/global_objects/weakref/deref/index.md +++ b/files/fr/web/javascript/reference/global_objects/weakref/deref/index.md @@ -11,7 +11,7 @@ La méthode `deref` renvoie l'objet cible associé à l'objet [`WeakRef`](/fr/do ## Syntaxe ```js -deref() +deref(); ``` ### Valeur de retour diff --git a/files/fr/web/javascript/reference/global_objects/weakref/index.md b/files/fr/web/javascript/reference/global_objects/weakref/index.md index aadacb20fa33f6..60040dbf550b1a 100644 --- a/files/fr/web/javascript/reference/global_objects/weakref/index.md +++ b/files/fr/web/javascript/reference/global_objects/weakref/index.md @@ -30,7 +30,7 @@ Une utilisation correcte de `WeakRef` nécessite une réflexion suffisante et il Voici quelques sujets spécifiques inclus dans [le document explicatif de la proposition correspondante](https://github.com/tc39/proposal-weakrefs/blob/master/reference.md) : -> [Les ramasses-miettes](https://fr.wikipedia.org/wiki/Ramasse-miettes_(informatique)) sont compliqués. Si une application ou une bibliothèque dépend d'un ramasse-miettes nettoyant un registre FinalizationRegistry ou appelant un finaliseur de façon précise et prédictible, qu'elle se prépare à être déçue : le nettoyage pourra avoir lieu bien plus tard que prévu voire pas du tout. Ce comportement grandement variable est dû : +> [Les ramasses-miettes]() sont compliqués. Si une application ou une bibliothèque dépend d'un ramasse-miettes nettoyant un registre FinalizationRegistry ou appelant un finaliseur de façon précise et prédictible, qu'elle se prépare à être déçue : le nettoyage pourra avoir lieu bien plus tard que prévu voire pas du tout. Ce comportement grandement variable est dû : > > - Au fait qu'un objet peut être récupéré par le ramasse-miettes bien plus tôt qu'un autre, même s'il devient inaccessible au même temps, par exemple en raison du ramassage générationnel. > - À l'action du ramasse-miettes qui peut être divisée dans le temps en utilisant des techniques incrémentales et concurrentes. diff --git a/files/fr/web/javascript/reference/global_objects/weakset/delete/index.md b/files/fr/web/javascript/reference/global_objects/weakset/delete/index.md index 31307010fad0d9..bd8edf18f34e5c 100644 --- a/files/fr/web/javascript/reference/global_objects/weakset/delete/index.md +++ b/files/fr/web/javascript/reference/global_objects/weakset/delete/index.md @@ -33,10 +33,10 @@ var obj = {}; ws.add(window); -ws.delete(obj); // Renvoie false. Aucun objet obj n'a été trouvé ni retiré. +ws.delete(obj); // Renvoie false. Aucun objet obj n'a été trouvé ni retiré. ws.delete(window); // Renvoie true, l'objet window a pu être retiré. -ws.has(window); // Renvoie false, window n'appartient plus au WeakSet. +ws.has(window); // Renvoie false, window n'appartient plus au WeakSet. ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/weakset/has/index.md b/files/fr/web/javascript/reference/global_objects/weakset/has/index.md index 072c5015cf7b52..97ce9e59e5c655 100644 --- a/files/fr/web/javascript/reference/global_objects/weakset/has/index.md +++ b/files/fr/web/javascript/reference/global_objects/weakset/has/index.md @@ -33,8 +33,8 @@ var ws = new WeakSet(); var obj = {}; ws.add(window); -mySet.has(window); // renvoie true -mySet.has(obj); // renvoie false +mySet.has(window); // renvoie true +mySet.has(obj); // renvoie false ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/global_objects/weakset/index.md b/files/fr/web/javascript/reference/global_objects/weakset/index.md index 507661fbfd6413..48c7a34795bbe6 100644 --- a/files/fr/web/javascript/reference/global_objects/weakset/index.md +++ b/files/fr/web/javascript/reference/global_objects/weakset/index.md @@ -25,31 +25,28 @@ Les fonctions récursives doivent faire attention aux structures de données cir ```js // Appeler un callback sur ce qui est stocké dans un objet -function execRecursively(fn, subject, _refs = null){ - if(!_refs) - _refs = new WeakSet(); +function execRecursively(fn, subject, _refs = null) { + if (!_refs) _refs = new WeakSet(); // On évite une récursion infinie - if(_refs.has(subject)) - return; + if (_refs.has(subject)) return; fn(subject); - if("object" === typeof subject){ + if ("object" === typeof subject) { _refs.add(subject); - for(let key in subject) - execRecursively(fn, subject[key], _refs); + for (let key in subject) execRecursively(fn, subject[key], _refs); } } const toto = { toto: "Toto", truc: { - truc: "Truc" - } + truc: "Truc", + }, }; toto.truc.machin = toto; // Référence circulaire ! -execRecursively(obj => console.log(obj), toto); +execRecursively((obj) => console.log(obj), toto); ``` Ici, on a un objet `WeakSet` qui est créé lors de la première exécution et qui est passé ensuite à chaque appel qui suit (via l'argument interne `_refs`). @@ -82,12 +79,12 @@ const truc = {}; ws.add(toto); ws.add(truc); -ws.has(toto); // true -ws.has(truc); // true +ws.has(toto); // true +ws.has(truc); // true ws.delete(toto); // retire toto de l'ensemble -ws.has(toto); // false, toto a été enlevé -ws.has(truc); // toujours true +ws.has(toto); // false, toto a été enlevé +ws.has(truc); // toujours true ``` On notera que `toto !== truc`. Bien que ce soient des objets similaires, ce ne sont pas _**les mêmes objets**_. Aussi, les deux sont ajoutés à l'ensemble. diff --git a/files/fr/web/javascript/reference/global_objects/weakset/weakset/index.md b/files/fr/web/javascript/reference/global_objects/weakset/weakset/index.md index 6f76a8ccd0c0f4..7fe3754d57a543 100644 --- a/files/fr/web/javascript/reference/global_objects/weakset/weakset/index.md +++ b/files/fr/web/javascript/reference/global_objects/weakset/weakset/index.md @@ -11,8 +11,8 @@ Le **constructeur `WeakSet()`** permet de créer des objets `WeakSet` qui stocke ## Syntaxe ```js -new WeakSet() -new WeakSet(iterable) +new WeakSet(); +new WeakSet(iterable); ``` ### Paramètres @@ -32,12 +32,12 @@ const truc = {}; ws.add(toto); ws.add(truc); -ws.has(toto); // true -ws.has(truc); // true +ws.has(toto); // true +ws.has(truc); // true ws.delete(toto); // retire toto de l'ensemble -ws.has(toto); // false, toto a été retiré -ws.has(truc); // true, truc est retenu +ws.has(toto); // false, toto a été retiré +ws.has(truc); // true, truc est retenu ``` On notera que `toto !== truc`. Même si ces objets se ressemblent, _ce ne sont pas **les mêmes objets**_. Aussi, ils sont tous les deux ajoutés à l'ensemble. diff --git a/files/fr/web/javascript/reference/iteration_protocols/index.md b/files/fr/web/javascript/reference/iteration_protocols/index.md index 69c9eadddf1856..9365305a104863 100644 --- a/files/fr/web/javascript/reference/iteration_protocols/index.md +++ b/files/fr/web/javascript/reference/iteration_protocols/index.md @@ -87,8 +87,8 @@ Certains itérateurs sont des itérables : var unTableau = [1, 5, 7]; var élémentsDuTableau = unTableau.entries(); -élémentsDuTableau.toString(); // "[object Array Iterator]" -élémentsDuTableau === élémentsDuTableau[Symbol.iterator](); // true +élémentsDuTableau.toString(); // "[object Array Iterator]" +élémentsDuTableau === élémentsDuTableau[Symbol.iterator](); // true ``` ## Exemples d'utilisation des protocoles d'itération @@ -97,38 +97,39 @@ Une {{jsxref("String")}} est un exemple d'objet natif itérable : ```js var uneChaîne = "coucou"; -typeof uneChaîne[Symbol.iterator]; // "function" +typeof uneChaîne[Symbol.iterator]; // "function" ``` [L'itérateur par défaut d'un objet `String`](/fr/docs/Web/JavaScript/Reference/Objets_globaux/String/@@iterator) renverra les caractères de la chaîne les uns à la suite des autres : ```js var itérateur = uneChaîne[Symbol.iterator](); -itérateur + ""; // "[object String Iterator]" - -itérateur.next(); // { value: "c", done: false } -itérateur.next(); // { value: "o", done: false } -itérateur.next(); // { value: "u", done: false } -itérateur.next(); // { value: "c", done: false } -itérateur.next(); // { value: "o", done: false } -itérateur.next(); // { value: "u", done: false } -itérateur.next(); // { value: undefined, done: true } +itérateur + ""; // "[object String Iterator]" + +itérateur.next(); // { value: "c", done: false } +itérateur.next(); // { value: "o", done: false } +itérateur.next(); // { value: "u", done: false } +itérateur.next(); // { value: "c", done: false } +itérateur.next(); // { value: "o", done: false } +itérateur.next(); // { value: "u", done: false } +itérateur.next(); // { value: undefined, done: true } ``` Certains éléments natifs du langage, tels que [la syntaxe de décomposition](/fr/docs/Web/JavaScript/Reference/Opérateurs/Opérateur_de_décomposition), utilisent ce même protocole : ```js -[...uneChaîne]; // ["c", "o", "u", "c", "o", "u"] +[...uneChaîne]; // ["c", "o", "u", "c", "o", "u"] ``` Il est possible de redéfinir le comportement par défaut en définissant soi-même le symbole `@@iterator` : ```js -var uneChaîne = new String("yo"); // on construit un objet String explicitement afin d'éviter la conversion automatique +var uneChaîne = new String("yo"); // on construit un objet String explicitement afin d'éviter la conversion automatique -uneChaîne[Symbol.iterator] = function() { - return { // l'objet itérateur qui renvoie un seul élément, la chaîne "bop" - next: function() { +uneChaîne[Symbol.iterator] = function () { + return { + // l'objet itérateur qui renvoie un seul élément, la chaîne "bop" + next: function () { if (this._first) { this._first = false; return { value: "bop", done: false }; @@ -136,7 +137,7 @@ uneChaîne[Symbol.iterator] = function() { return { done: true }; } }, - _first: true + _first: true, }; }; ``` @@ -144,8 +145,8 @@ uneChaîne[Symbol.iterator] = function() { On notera que redéfinir le symbole `@@iterator` affecte également le comportement des éléments du langage qui utilisent le protocole : ```js -[...uneChaîne]; // ["bop"] -uneChaîne + ""; // "yo" +[...uneChaîne]; // ["bop"] +uneChaîne + ""; // "yo" ``` ## Exemples d'itérables @@ -161,9 +162,9 @@ Il est possible de construire un itérable dans un script de la façon suivante ```js var monItérable = {}; monItérable[Symbol.iterator] = function* () { - yield 1; - yield 2; - yield 3; + yield 1; + yield 2; + yield 3; }; [...monItérable]; // [1, 2, 3] ``` @@ -174,15 +175,25 @@ Plusieurs API utilisent les itérables, par exemple : {{jsxref("Map", "Map([ité ```js var monObjet = {}; -new Map([[1,"a"],[2,"b"],[3,"c"]]).get(2); // "b" -new WeakMap([[{},"a"],[monObjet,"b"],[{},"c"]]).get(monObjet); // "b" -new Set([1, 2, 3]).has(3); // true -new Set("123").has("2"); // true -new WeakSet(function*() { +new Map([ + [1, "a"], + [2, "b"], + [3, "c"], +]).get(2); // "b" +new WeakMap([ + [{}, "a"], + [monObjet, "b"], + [{}, "c"], +]).get(monObjet); // "b" +new Set([1, 2, 3]).has(3); // true +new Set("123").has("2"); // true +new WeakSet( + (function* () { yield {}; yield monObjet; yield {}; -}()).has(monObjet); // true + })(), +).has(monObjet); // true ``` ainsi que {{jsxref("Promise.all", "Promise.all(itérable)")}}, {{jsxref("Promise.race", "Promise.race(itérable)")}}, {{jsxref("Array.from", "Array.from()")}} @@ -192,8 +203,8 @@ ainsi que {{jsxref("Promise.all", "Promise.all(itérable)")}}, {{jsxref("Promise Certains éléments du langage utilisent des itérables, par exemple : [`for..of`](/fr/docs/Web/JavaScript/Reference/Instructions/for...of), [la syntaxe de décomposition](/fr/docs/Web/JavaScript/Reference/Opérateurs/Opérateur_de_décomposition), [yield\*](/fr/docs/Web/JavaScript/Reference/Opérateurs/yield*), [l'affectation par décomposition](/fr/docs/Web/JavaScript/Reference/Opérateurs/Affecter_par_décomposition) : ```js -for(let value of ["a", "b", "c"]){ - console.log(value); +for (let value of ["a", "b", "c"]) { + console.log(value); } // "a" // "b" @@ -201,7 +212,7 @@ for(let value of ["a", "b", "c"]){ [..."abc"]; // ["a", "b", "c"] -function* gen(){ +function* gen() { yield* ["a", "b", "c"]; } @@ -226,36 +237,36 @@ itérableMalFormé[Symbol.iterator] = () => 1 ### Un itérateur simple ```js -function créerItérateur(tableau){ - var nextIndex = 0; - - return { - next: function(){ - return nextIndex < tableau.length ? - {value: tableau[nextIndex++], done: false} : - {done: true}; - } - } +function créerItérateur(tableau) { + var nextIndex = 0; + + return { + next: function () { + return nextIndex < tableau.length + ? { value: tableau[nextIndex++], done: false } + : { done: true }; + }, + }; } -var it = créerItérateur(['yo', 'ya']); +var it = créerItérateur(["yo", "ya"]); console.log(it.next().value); // 'yo' console.log(it.next().value); // 'ya' -console.log(it.next().done); // true +console.log(it.next().done); // true ``` ### Un itérateur infini ```js -function créateurID(){ - var index = 0; +function créateurID() { + var index = 0; - return { - next: function(){ - return {value: index++, done: false}; - } - }; + return { + next: function () { + return { value: index++, done: false }; + }, + }; } var it = créateurID(); @@ -269,24 +280,23 @@ console.log(it.next().value); // '2' ### Avec un générateur ```js -function* créerUnGénérateurSimple(tableau){ - var nextIndex = 0; +function* créerUnGénérateurSimple(tableau) { + var nextIndex = 0; - while(nextIndex < tableau.length){ - yield tableau[nextIndex++]; - } + while (nextIndex < tableau.length) { + yield tableau[nextIndex++]; + } } -var gen = créerUnGénérateurSimple(['yo', 'ya']); +var gen = créerUnGénérateurSimple(["yo", "ya"]); console.log(gen.next().value); // 'yo' console.log(gen.next().value); // 'ya' -console.log(gen.next().done); // true +console.log(gen.next().done); // true -function* créateurID(){ - var index = 0; - while(true) - yield index++; +function* créateurID() { + var index = 0; + while (true) yield index++; } var gen = créateurID(); @@ -309,23 +319,23 @@ class ClasseSimple { return { next: () => { if (this.index < this.data.length) { - return {value: this.data[this.index++], done: false}; + return { value: this.data[this.index++], done: false }; } else { this.index = 0; // En réinitialisant l'index, on peut // "reprendre" l'itérateure sans avoir // à gérer de mise à jour manuelle - return {done: true}; + return { done: true }; } - } + }, }; } } -const simple = new ClasseSimple([1,2,3,4,5]); +const simple = new ClasseSimple([1, 2, 3, 4, 5]); for (const val of simple) { - console.log(val); // '1' '2' '3' '4' '5' + console.log(val); // '1' '2' '3' '4' '5' } ``` diff --git a/files/fr/web/javascript/reference/lexical_grammar/index.md b/files/fr/web/javascript/reference/lexical_grammar/index.md index 3964141f48ded8..4ec4839e28ade8 100644 --- a/files/fr/web/javascript/reference/lexical_grammar/index.md +++ b/files/fr/web/javascript/reference/lexical_grammar/index.md @@ -14,9 +14,9 @@ Les caractères de contrôle n'ont aucune représentation visuelle mais sont uti | Point de code | Nom | Abréviation | Description | | ------------- | ------------------------------------------------------------ | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `U+200C` | Antiliant sans chasse (_zero width non-joiner_ en anglais) | \ | Placé entre des caractères pour empêcher qu'ils soient connectés par une ligature dans certaines langues ([Wikipédia](https://fr.wikipedia.org/wiki/Antiliant_sans_chasse)). | -| `U+200D` | Liant sans chasse (_zero width joiner_ en anglais) | \ | Placé entre des caractères qui ne seraient normalement pas connectés pour les afficher comme connectés dans certaines langues ([Wikipédia](https://fr.wikipedia.org/wiki/Liant_sans_chasse)). | -| `U+FEFF` | Indicateur d'ordre des octets (_byte order mark_ en anglais) | \ | Utilisé au début d'un script pour indiquer qu'il est en Unicode et quel est l'ordre des octets ([Wikipedia](https://fr.wikipedia.org/wiki/Indicateur_d%27ordre_des_octets)). | +| `U+200C` | Antiliant sans chasse (_zero width non-joiner_ en anglais) | \ | Placé entre des caractères pour empêcher qu'ils soient connectés par une ligature dans certaines langues ([Wikipédia](https://fr.wikipedia.org/wiki/Antiliant_sans_chasse)). | +| `U+200D` | Liant sans chasse (_zero width joiner_ en anglais) | \ | Placé entre des caractères qui ne seraient normalement pas connectés pour les afficher comme connectés dans certaines langues ([Wikipédia](https://fr.wikipedia.org/wiki/Liant_sans_chasse)). | +| `U+FEFF` | Indicateur d'ordre des octets (_byte order mark_ en anglais) | \ | Utilisé au début d'un script pour indiquer qu'il est en Unicode et quel est l'ordre des octets ([Wikipedia](https://fr.wikipedia.org/wiki/Indicateur_d%27ordre_des_octets)). | ## Blancs @@ -24,12 +24,12 @@ Les caractères d'espacement (blancs) sont utilisés pour des raisons de lisibil | Point de code | Nom | Abréviation | Description | Séquence d'échappement | | ------------- | -------------------------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------ | ---------------------- | -| U+0009 | Tabulation (horizontale) | \ | Tabulation horizontale | \t | -| U+000B | Tabulation verticale | \ | Tabulation verticale | \v | -| U+000C | Caractère de saut de page (_form feed_ en anglais) | \ | Caractère de contrôle pour le saut de page ([Wikipédia](http://en.wikipedia.org/wiki/Page_break#Form_feed)). | \f | -| U+0020 | Espace sécable (_space_ en anglais) | \ | Espace sécable | | -| U+00A0 | Espace insécable (_no-break space_ en anglais) | \ | Espace insécable | | -| Autres | Autres caractères d'espaces Unicode | \ | [Espaces Unicode sur Wikipédia](http://en.wikipedia.org/wiki/Space_%28punctuation%29#Spaces_in_Unicode) | | +| U+0009 | Tabulation (horizontale) | \ | Tabulation horizontale | \t | +| U+000B | Tabulation verticale | \ | Tabulation verticale | \v | +| U+000C | Caractère de saut de page (_form feed_ en anglais) | \ | Caractère de contrôle pour le saut de page ([Wikipédia](http://en.wikipedia.org/wiki/Page_break#Form_feed)). | \f | +| U+0020 | Espace sécable (_space_ en anglais) | \ | Espace sécable | | +| U+00A0 | Espace insécable (_no-break space_ en anglais) | \ | Espace insécable | | +| Autres | Autres caractères d'espaces Unicode | \ | [Espaces Unicode sur Wikipédia](http://en.wikipedia.org/wiki/Space_%28punctuation%29#Spaces_in_Unicode) | | ## Terminateurs de lignes @@ -39,10 +39,10 @@ Seuls les points de code Unicode qui suivent sont traités comme des fins de lig | Point de code | Nom | Abréviation | Description | Séquence d'échappement | | ------------- | ------------------------ | ----------- | ---------------------------------------------------------------------------- | ---------------------- | -| U+000A | Nouvelle ligne | \ | Caractère de nouvelle ligne pour les systèmes UNIX. | \n | -| U+000D | Retour chariot | \ | Caractère de nouvelle ligne pour les systèmes Commodore et les premiers Mac. | \r | -| U+2028 | Séparateur de ligne | \ | [Wikipédia](https://fr.wikipedia.org/wiki/Fin_de_ligne) | | -| U+2029 | Séparateur de paragraphe | \ | [Wikipédia](https://fr.wikipedia.org/wiki/Fin_de_ligne) | | +| U+000A | Nouvelle ligne | \ | Caractère de nouvelle ligne pour les systèmes UNIX. | \n | +| U+000D | Retour chariot | \ | Caractère de nouvelle ligne pour les systèmes Commodore et les premiers Mac. | \r | +| U+2028 | Séparateur de ligne | \ | [Wikipédia](https://fr.wikipedia.org/wiki/Fin_de_ligne) | | +| U+2029 | Séparateur de paragraphe | \ | [Wikipédia](https://fr.wikipedia.org/wiki/Fin_de_ligne) | | ## Commentaires @@ -80,7 +80,7 @@ Mais également sur plusieurs lignes, comme ceci : ```js function comment() { - /* Ce commentaire s'étend sur plusieurs lignes. Il n'y a + /* Ce commentaire s'étend sur plusieurs lignes. Il n'y a pas besoin de clore le commentaire avant d'avoir fini. */ console.log("Hello world !"); @@ -226,7 +226,7 @@ function import() {} // Illégal. Voir aussi la page {{jsxref("null")}} pour plus d'informations. ```js -null +null; ``` ### Littéraux booléens @@ -234,8 +234,8 @@ null Voir aussi la page {{jsxref("Boolean")}} pour plus d'informations. ```js -true -false +true; +false; ``` ### Littéraux numériques @@ -243,13 +243,13 @@ false #### Décimaux ```js -1234567890 -42 +1234567890; +42; // Attention à l'utilisation de zéros en début : -0888 // 888 est compris comme décimal -0777 // est compris comme octal et égale 511 en décimal +0888; // 888 est compris comme décimal +0777; // est compris comme octal et égale 511 en décimal ``` Les littéraux décimaux peuvent commencer par un zéro (`0`) suivi d'un autre chiffre. Mais si tous les chiffres après le 0 sont (strictement) inférieurs à 8, le nombre sera analysé comme un nombre octal. Cela n'entraînera pas d'erreur JavaScript, voir [bug Firefox 957513](https://bugzil.la/957513). Voir aussi la page sur {{jsxref("parseInt", "parseInt()")}}. @@ -259,9 +259,9 @@ Les littéraux décimaux peuvent commencer par un zéro (`0`) suivi d'un autre c La représentation binaire des nombres peut être utilisée avec une syntaxe qui comporte un zéro (0) suivi par le caractère latin "B" (minuscule ou majuscule) (`0b` ou `0B`). Cette syntaxe est apparue avec ECMAScript 2015 et il faut donc faire attention au tableau de compatibilité pour cette fonctionnalité. Si les chiffres qui composent le nombre ne sont pas 0 ou 1, cela entraînera une erreur {{jsxref("SyntaxError")}} : "Missing binary digits after 0b". ```js -var FLT_SIGNBIT = 0b10000000000000000000000000000000; // 2147483648 +var FLT_SIGNBIT = 0b10000000000000000000000000000000; // 2147483648 var FLT_EXPONENT = 0b01111111100000000000000000000000; // 2139095040 -var FLT_MANTISSA = 0B00000000011111111111111111111111; // 8388607 +var FLT_MANTISSA = 0b00000000011111111111111111111111; // 8388607 ``` #### Octaux @@ -269,12 +269,12 @@ var FLT_MANTISSA = 0B00000000011111111111111111111111; // 8388607 La syntaxe pour représenter des nombres sous forme octale est : un zéro (0), suivi par la lettre latine "O" (minuscule ou majuscule) (ce qui donne `0o` ou `0O)`. Cette syntaxe est apparue avec ECMAScript 2015 et il faut donc faire attention au tableau de compatibilité pour cette fonctionnalité. Si les chiffres qui composent le nombre ne sont pas compris entre 0 et 7, cela entraînera une erreur {{jsxref("SyntaxError")}} : "Missing octal digits after 0o". ```js -var n = 0O755; // 493 +var n = 0o755; // 493 var m = 0o644; // 420 // Aussi possible en utilisant des zéros en début du nombre (voir la note ci-avant) -0755 -0644 +0755; +0644; ``` #### Hexadécimaux @@ -282,9 +282,9 @@ var m = 0o644; // 420 Les littéraux hexadécimaux ont pour syntaxe : un zéro (0), suivi par la lettre latine "X" (minuscule ou majuscule) (ce qui donne `0x` ou `0X)`. Si les chiffres qui composent le nombre sont en dehors des unités hexadécimales (0123456789ABCDEF), cela entraînera une erreur {{jsxref("SyntaxError")}} : "Identifier starts immediately after numeric literal". ```js -0xFFFFFFFFFFFFFFFFF // 295147905179352830000 -0x123456789ABCDEF // 81985529216486900 -0XA // 10 +0xfffffffffffffffff; // 295147905179352830000 +0x123456789abcdef; // 81985529216486900 +0xa; // 10 ``` #### Littéraux `BigInt` @@ -308,8 +308,10 @@ Voir aussi les pages {{jsxref("Object")}} et {{jsxref("Opérateurs/Initialisateu var o = { a: "toto", b: "truc", c: 42 }; // notation raccourcie depuis ES6 -var a = "toto", b = "truc", c = 42; -var o = {a, b, c}; +var a = "toto", + b = "truc", + c = 42; +var o = { a, b, c }; // plutôt que var o = { a: a, b: b, c: c }; ``` @@ -319,7 +321,7 @@ var o = { a: a, b: b, c: c }; Voir aussi la page {{jsxref("Array")}} pour plus d'informations. ```js -[1954, 1974, 1990, 2014] +[1954, 1974, 1990, 2014]; ``` ### Littéraux de chaînes de caractères @@ -334,9 +336,9 @@ Avant la proposition consistant à rendre les chaînes JSON valides selon ECMA-2 Tous les codets peuvent être écrits sous la forme d'une séquence d'échappement. Les littéraux de chaînes de caractères sont évalués comme des valeurs `String` ECMAScript. Lorsque ces valeurs `String` sont générées, les codets Unicode sont encodés en UTF-16. -```js -'toto' -"truc" +```js-nolint +'toto'; +"truc"; ``` #### Séquence d'échappement hexadécimale @@ -344,7 +346,7 @@ Tous les codets peuvent être écrits sous la forme d'une séquence d'échappeme Une séquence d'échappement hexadécimale consiste en la succession de `\x` et de deux chiffres hexadécimaux représentant un codet sur l'intervalle 0x0000 à 0x00FF. ```js -'\xA9' // "©" +"\xA9"; // "©" ``` #### Séquence d'échappement Unicode @@ -354,7 +356,7 @@ La séquence d'échappement Unicode est composée de `\u` suivi de quatre chiffr Voir aussi {{jsxref("String.fromCharCode()")}} et {{jsxref("String.prototype.charCodeAt()")}}. ```js -'\u00A9' // "©" (U+A9) +"\u00A9"; // "©" (U+A9) ``` #### Échappement de points de code Unicode @@ -364,11 +366,11 @@ Apparu avec ECMAScript 2015, l'échappement de points de code Unicode permet d' Voir également {{jsxref("String.fromCodePoint()")}} et {{jsxref("String.prototype.codePointAt()")}}. ```js -'\u{2F804}' // CJK COMPATIBILITY IDEOGRAPH-2F804 (U+2F804) +"\u{2F804}"; // CJK COMPATIBILITY IDEOGRAPH-2F804 (U+2F804) // avec l'ancienne méthode d'échappement, cela aurait été écrit // avec une paire de surrogates -'\uD87E\uDC04' +"\uD87E\uDC04"; ``` ### Littéraux d'expressions rationnelles @@ -389,14 +391,14 @@ Voir la page [`RegExp`](/fr/docs/Web/JavaScript/Reference/Objets_globaux/RegExp) Voir également la page sur [les gabarits de chaînes de caractères](/fr/docs/Web/JavaScript/Reference/Gabarit_chaînes_caractères) pour plus d'informations. ```js -`chaîne de caractères` +`chaîne de caractères`; `chaîne de caractères ligne 1 - chaîne de caractères ligne 2` + chaîne de caractères ligne 2`; -`chaîne1 ${expression} chaîne2` +`chaîne1 ${expression} chaîne2`; -tag `chaîne1 ${expression} chaîne2` +tag`chaîne1 ${expression} chaîne2`; ``` ## Insertion automatique de points-virgules @@ -426,8 +428,8 @@ La spécification ECMAScript mentionne [trois règles quant à l'insertion de po Ici `++` n'est pas traité comme [opérateur postfixe](/fr/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Increment) s'appliquant à la variable `b` car il y a un terminateur de ligne entre `b` et `++`. ```js -a = b -++c +a = b; +++c; // devient, après ASI : @@ -444,7 +446,7 @@ a = b; - `yield`, `yield*` - `module` -```js +```js-nolint return a + b diff --git a/files/fr/web/javascript/reference/operators/addition/index.md b/files/fr/web/javascript/reference/operators/addition/index.md index 3fc88aff27e184..d9214a9a7327bc 100644 --- a/files/fr/web/javascript/reference/operators/addition/index.md +++ b/files/fr/web/javascript/reference/operators/addition/index.md @@ -13,7 +13,7 @@ L'opérateur d'addition (`+`) produit la somme de deux opérandes numériques ou ## Syntaxe ```js -Opérateur : x + y +Opérateur: x + y; ``` ## Exemples @@ -22,26 +22,26 @@ Opérateur : x + y ```js // Number + Number -> addition -1 + 2 // 3 +1 + 2; // 3 // Boolean + Number -> addition -true + 1 // 2 +true + 1; // 2 // Boolean + Boolean -> addition -false + false // 0 +false + false; // 0 ``` ### Concaténation de chaînes de caractères ```js // String + String -> concatenation -'toto' + 'truc' // "tototruc" +"toto" + "truc"; // "tototruc" // Number + String -> concatenation -5 + 'toto' // "5toto" +5 + "toto"; // "5toto" // String + Boolean -> concatenation -'toto' + false // "totofalse" +"toto" + false; // "totofalse" ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/addition_assignment/index.md b/files/fr/web/javascript/reference/operators/addition_assignment/index.md index 352706970b91a1..aaa5870ba0cb82 100644 --- a/files/fr/web/javascript/reference/operators/addition_assignment/index.md +++ b/files/fr/web/javascript/reference/operators/addition_assignment/index.md @@ -12,8 +12,8 @@ L'opérateur d'addition et d'affectation (`+=`) calcule la somme ou la concatén ## Syntaxe ```js -Opérateur : x += y -Signification : x = x + y +Opérateur: x += y; +Signification: x = x + y; ``` ## Exemples @@ -35,13 +35,13 @@ machin += 1; // 2 machin += false; // 1 // nombre + chaîne de caractères -> concaténation -truc += 'toto'; // "5toto" +truc += "toto"; // "5toto" // chaîne de caractères + booléen -> concaténation -toto += false // "totofalse" +toto += false; // "totofalse" // chaîne de caractères + chaîne de caractères -> concaténation -toto += 'truc' // "tototruc" +toto += "truc"; // "tototruc" ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/assignment/index.md b/files/fr/web/javascript/reference/operators/assignment/index.md index 792951305b37e9..70da94145621dd 100644 --- a/files/fr/web/javascript/reference/operators/assignment/index.md +++ b/files/fr/web/javascript/reference/operators/assignment/index.md @@ -13,7 +13,7 @@ L'opérateur d'assignement simple (`=`) est utilisé pour définir la valeur d'u ## Syntaxe ```js -x = y +x = y; ``` ## Exemples diff --git a/files/fr/web/javascript/reference/operators/async_function/index.md b/files/fr/web/javascript/reference/operators/async_function/index.md index cc1f124e1777ec..40486457d94529 100644 --- a/files/fr/web/javascript/reference/operators/async_function/index.md +++ b/files/fr/web/javascript/reference/operators/async_function/index.md @@ -39,29 +39,30 @@ Une expression `async function` est très proche, et partage quasiment la même ```js function resolveAfter2Seconds(x) { - return new Promise(resolve => { + return new Promise((resolve) => { setTimeout(() => { resolve(x); }, 2000); }); -}; +} -(async function(x) { // fonction asynchrone immédiatement appelée +(async function (x) { + // fonction asynchrone immédiatement appelée var a = resolveAfter2Seconds(20); var b = resolveAfter2Seconds(30); - return x + await a + await b; -})(10).then(v => { - console.log(v); // affiche 60 après 2 secondes. + return x + (await a) + (await b); +})(10).then((v) => { + console.log(v); // affiche 60 après 2 secondes. }); -var add = async function(x) { +var add = async function (x) { var a = await resolveAfter2Seconds(20); var b = await resolveAfter2Seconds(30); return x + a + b; }; -add(10).then(v => { - console.log(v); // affiche 60 après 4 secondes. +add(10).then((v) => { + console.log(v); // affiche 60 après 4 secondes. }); ``` diff --git a/files/fr/web/javascript/reference/operators/async_function_star_/index.md b/files/fr/web/javascript/reference/operators/async_function_star_/index.md index ad120173ba3fd4..929fcbd87153d1 100644 --- a/files/fr/web/javascript/reference/operators/async_function_star_/index.md +++ b/files/fr/web/javascript/reference/operators/async_function_star_/index.md @@ -58,7 +58,9 @@ L'exemple qui suit définit une fonction génératrice asynchrone anonyme et l'a const x = async function* (y) { yield Promise.resolve(y * y); }; -x(6).next().then((res) => console.log(res.value)); // affiche 36 +x(6) + .next() + .then((res) => console.log(res.value)); // affiche 36 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/await/index.md b/files/fr/web/javascript/reference/operators/await/index.md index 91581d330891a9..53f65908885309 100644 --- a/files/fr/web/javascript/reference/operators/await/index.md +++ b/files/fr/web/javascript/reference/operators/await/index.md @@ -31,7 +31,7 @@ Si on passe une promesse à une expression `await`, celle-ci attendra jusqu'à l ```js function resolveAfter2Seconds(x) { - return new Promise(resolve => { + return new Promise((resolve) => { setTimeout(() => { resolve(x); }, 2000); @@ -50,9 +50,9 @@ Les objets dotés d'une méthode `then()` (_thenable_ en anglais) seront égalem ```js async function f0() { const thenable = { - then: function(resolve, _reject) { + then: function (resolve, _reject) { resolve("résolu :)"); - } + }, }; console.log(await thenable); // résolu :) } @@ -85,11 +85,9 @@ f3(); On peut également gérer le cas où la promesse est rejetée grâce à {{jsxref("Promise.prototype.catch()")}} : ```js -var response = await maFonctionPromesse().catch( - (err) => { - console.log(err); - } -); +var response = await maFonctionPromesse().catch((err) => { + console.log(err); +}); ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/bitwise_and/index.md b/files/fr/web/javascript/reference/operators/bitwise_and/index.md index 041b93797b38fd..e252aa9501fea5 100644 --- a/files/fr/web/javascript/reference/operators/bitwise_and/index.md +++ b/files/fr/web/javascript/reference/operators/bitwise_and/index.md @@ -12,14 +12,14 @@ L'opérateur ET binaire (`&`) renvoie un nombre dont la représentation binaire ## Syntaxe ```js -a & b +a & b; ``` ## Description Les opérandes sont convertis en entiers sur 32 bits et exprimés comme une séquence de bits. Les nombres sur plus de 32 bits ont leurs bits en excès écartés. Par exemple, l'entier suivant nécessite plus de 32 bits pour être représenté et il sera converti en un entier sur 32 bits : -```js +```plain Avant: 11100110111110100000000000000110000000000001 Après: 10100000000000000110000000000001 ``` diff --git a/files/fr/web/javascript/reference/operators/bitwise_and_assignment/index.md b/files/fr/web/javascript/reference/operators/bitwise_and_assignment/index.md index 1b2543dd26769e..3754dc382d0410 100644 --- a/files/fr/web/javascript/reference/operators/bitwise_and_assignment/index.md +++ b/files/fr/web/javascript/reference/operators/bitwise_and_assignment/index.md @@ -12,8 +12,8 @@ L'opérateur d'affectation après ET binaire (`&=`) utilise la représentation b ## Syntaxe ```js -Opérateur : x &= y -Signification : x = x & y +Opérateur: x &= y; +Signification: x = x & y; ``` ## Exemples diff --git a/files/fr/web/javascript/reference/operators/bitwise_not/index.md b/files/fr/web/javascript/reference/operators/bitwise_not/index.md index 3e13a1ce66f9a9..332a993170800c 100644 --- a/files/fr/web/javascript/reference/operators/bitwise_not/index.md +++ b/files/fr/web/javascript/reference/operators/bitwise_not/index.md @@ -13,14 +13,14 @@ L'opérateur binaire NON (`~`) prend l'opposé de chaque bit de son opérande et ## Syntaxe ```js -~a +~a; ``` ## Description L'opérande est converti en un entier signé sur 32 bits. Les nombres avec plus de 32 bits voient leurs bits les plus significatifs être tronqués. Voici un exemple où l'entier qui suit est supérieur à une valeur pouvant être exprimée sur 32 bits : la conversion écrête la valeur pour obtenir un entier signé sur 32 bits : -```js +```plain Avant : 11100110111110100000000000000110000000000001 Après : 10100000000000000110000000000001 ``` @@ -52,9 +52,9 @@ Appliquer un NON binaire sur n'importe quel nombre `x` fournira la valeur `-(x + ### Utiliser le NON binaire ```js -~0; // -1 +~0; // -1 ~-1; // 0 -~1; // -2 +~1; // -2 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/bitwise_or/index.md b/files/fr/web/javascript/reference/operators/bitwise_or/index.md index 91917f8f454cc4..4df872f29a4eb4 100644 --- a/files/fr/web/javascript/reference/operators/bitwise_or/index.md +++ b/files/fr/web/javascript/reference/operators/bitwise_or/index.md @@ -12,14 +12,14 @@ L'opérateur OU binaire (`|`) renvoie un nombre dont la représentation binaire ## Syntaxe ```js -a | b +a | b; ``` ## Description Les opérandes sont convertis en entiers sur 32 bits et exprimés comme une séquence de bits. Les nombres sur plus de 32 bits ont leurs bits en excès écartés. Par exemple, l'entier suivant nécessite plus de 32 bits pour être représenté et il sera converti en un entier sur 32 bits : -```js +```plain Avant: 11100110111110100000000000000110000000000001 Après: 10100000000000000110000000000001 ``` @@ -35,7 +35,7 @@ La table de vérité pour l'opérateur OU est : | 1 | 0 | 1 | | 1 | 1 | 1 | -```js +```plain 9 (base 10) = 00000000000000000000000000001001 (base 2) 14 (base 10) = 00000000000000000000000000001110 (base 2) -------------------------------- diff --git a/files/fr/web/javascript/reference/operators/bitwise_or_assignment/index.md b/files/fr/web/javascript/reference/operators/bitwise_or_assignment/index.md index 54fcd267625a61..ebea8770fc8bac 100644 --- a/files/fr/web/javascript/reference/operators/bitwise_or_assignment/index.md +++ b/files/fr/web/javascript/reference/operators/bitwise_or_assignment/index.md @@ -12,8 +12,8 @@ L'opérateur d'affectation après OU binaire (`|=`) utilise la représentation b ## Syntaxe ```js -Opérateur : x |= y -Signification : x = x | y +Opérateur: x |= y; +Signification: x = x | y; ``` ## Exemples diff --git a/files/fr/web/javascript/reference/operators/bitwise_xor/index.md b/files/fr/web/javascript/reference/operators/bitwise_xor/index.md index d750e5d3158411..1bc6c481c104a1 100644 --- a/files/fr/web/javascript/reference/operators/bitwise_xor/index.md +++ b/files/fr/web/javascript/reference/operators/bitwise_xor/index.md @@ -12,14 +12,14 @@ L'opérateur binaire OU exclusif (XOR) (`^`) renvoie un nombre dont la représen ## Syntaxe ```js -a ^ b +a ^ b; ``` ## Description Les opérandes sont convertis en entiers sur 32 bits et exprimés comme une séquence de bits. Les nombres sur plus de 32 bits ont leurs bits en excès écartés. Par exemple, l'entier suivant nécessite plus de 32 bits pour être représenté et il sera converti en un entier sur 32 bits : -```js +```plain Avant: 11100110111110100000000000000110000000000001 Après: 10100000000000000110000000000001 ``` @@ -35,7 +35,7 @@ La table de vérité pour l'opérateur OU exclusif (XOR) est : | 1 | 0 | 1 | | 1 | 1 | 0 | -```js +```plain . 9 (base 10) = 00000000000000000000000000001001 (base 2) 14 (base 10) = 00000000000000000000000000001110 (base 2) -------------------------------- diff --git a/files/fr/web/javascript/reference/operators/bitwise_xor_assignment/index.md b/files/fr/web/javascript/reference/operators/bitwise_xor_assignment/index.md index ad9b41fc72b065..1d2d05e27fb62a 100644 --- a/files/fr/web/javascript/reference/operators/bitwise_xor_assignment/index.md +++ b/files/fr/web/javascript/reference/operators/bitwise_xor_assignment/index.md @@ -12,8 +12,8 @@ L'opérateur d'affectation après OU exclusif (XOR) binaire (`^=`) utilise la re ## Syntaxe ```js -Opérateur : x ^= y -Signification : x = x ^ y +Opérateur: x ^= y; +Signification: x = x ^ y; ``` ## Exemples @@ -21,14 +21,14 @@ Signification : x = x ^ y ### Utiliser l'affectation après OU exclusif binaire ```js -let a = 5; // 00000000000000000000000000000101 -a ^= 3; // 00000000000000000000000000000011 +let a = 5; // 00000000000000000000000000000101 +a ^= 3; // 00000000000000000000000000000011 console.log(a); // 00000000000000000000000000000110 // 6 -let b = 5; // 00000000000000000000000000000101 -b ^= 0; // 00000000000000000000000000000000 +let b = 5; // 00000000000000000000000000000101 +b ^= 0; // 00000000000000000000000000000000 console.log(b); // 00000000000000000000000000000101 // 5 diff --git a/files/fr/web/javascript/reference/operators/class/index.md b/files/fr/web/javascript/reference/operators/class/index.md index 427e4824832a69..fd36e9fe92e53f 100644 --- a/files/fr/web/javascript/reference/operators/class/index.md +++ b/files/fr/web/javascript/reference/operators/class/index.md @@ -54,12 +54,12 @@ var Toto = class TotoNommé { quiEstLa() { return TotoNommé.name; } -} +}; -var truc = new Toto; +var truc = new Toto(); truc.quiEstLa(); // "TotoNommmé" -TotoNommé.name; // ReferenceError -Toto.name; // "TotoNommé" +TotoNommé.name; // ReferenceError +Toto.name; // "TotoNommé" ``` ## Spécifications From 1a4be8c32441258acc4a8f3cc052b2f58c2ebc68 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 01:49:33 -0700 Subject: [PATCH 14/30] fr: Format /web/javascript using Prettier (part 10) (#14649) --- .../operators/comma_operator/index.md | 14 +- .../operators/conditional_operator/index.md | 51 +++---- .../reference/operators/delete/index.md | 56 +++---- .../destructuring_assignment/index.md | 122 ++++++++------- .../reference/operators/division/index.md | 14 +- .../operators/division_assignment/index.md | 12 +- .../reference/operators/equality/index.md | 38 ++--- .../operators/exponentiation/index.md | 22 +-- .../exponentiation_assignment/index.md | 8 +- .../reference/operators/function/index.md | 18 +-- .../operators/function_star_/index.md | 4 +- .../reference/operators/greater_than/index.md | 52 +++---- .../operators/greater_than_or_equal/index.md | 48 +++--- .../reference/operators/grouping/index.md | 8 +- .../reference/operators/import.meta/index.md | 2 +- .../reference/operators/import/index.md | 6 +- .../reference/operators/in/index.md | 44 +++--- .../reference/operators/inequality/index.md | 42 +++--- .../reference/operators/instanceof/index.md | 10 +- .../reference/operators/left_shift/index.md | 2 +- .../operators/left_shift_assignment/index.md | 4 +- .../reference/operators/less_than/index.md | 52 +++---- .../operators/less_than_or_equal/index.md | 48 +++--- .../reference/operators/logical_and/index.md | 47 +++--- .../operators/logical_and_assignment/index.md | 2 +- .../reference/operators/logical_not/index.md | 26 ++-- .../reference/operators/logical_or/index.md | 49 +++--- .../operators/logical_or_assignment/index.md | 4 +- .../operators/multiplication/index.md | 12 +- .../multiplication_assignment/index.md | 8 +- .../reference/operators/new.target/index.md | 12 +- .../reference/operators/new/index.md | 40 ++--- .../reference/operators/null/index.md | 24 +-- .../operators/nullish_coalescing/index.md | 35 +++-- .../nullish_coalescing_assignment/index.md | 2 +- .../operators/object_initializer/index.md | 80 +++++----- .../operators/operator_precedence/index.md | 4 +- .../operators/optional_chaining/index.md | 31 ++-- .../operators/property_accessors/index.md | 19 ++- .../reference/operators/remainder/index.md | 26 ++-- .../operators/remainder_assignment/index.md | 10 +- .../reference/operators/right_shift/index.md | 4 +- .../operators/right_shift_assignment/index.md | 8 +- .../operators/spread_syntax/index.md | 53 ++++--- .../operators/strict_equality/index.md | 34 ++--- .../operators/strict_inequality/index.md | 38 ++--- .../reference/operators/subtraction/index.md | 8 +- .../operators/subtraction_assignment/index.md | 8 +- .../reference/operators/super/index.md | 25 ++-- .../reference/operators/this/index.md | 87 ++++++----- .../reference/operators/typeof/index.md | 96 ++++++------ .../operators/unary_negation/index.md | 2 +- .../reference/operators/unary_plus/index.md | 12 +- .../operators/unsigned_right_shift/index.md | 4 +- .../unsigned_right_shift_assignment/index.md | 8 +- .../reference/operators/void/index.md | 34 ++--- .../reference/operators/yield/index.md | 4 +- .../reference/operators/yield_star_/index.md | 7 +- .../unicode_character_class_escape/index.md | 76 +++++----- .../statements/async_function/index.md | 84 ++++++----- .../statements/async_function_star_/index.md | 17 ++- .../reference/statements/break/index.md | 27 ++-- .../reference/statements/class/index.md | 12 +- .../reference/statements/continue/index.md | 46 +++--- .../reference/statements/debugger/index.md | 6 +- .../reference/statements/do...while/index.md | 7 +- .../reference/statements/empty/index.md | 23 ++- .../reference/statements/export/index.md | 36 ++--- .../statements/for-await...of/index.md | 16 +- .../reference/statements/for...in/index.md | 8 +- .../reference/statements/for...of/index.md | 43 +++--- .../reference/statements/for/index.md | 46 ++++-- .../reference/statements/function/index.md | 26 +++- .../statements/function_star_/index.md | 30 ++-- .../reference/statements/if...else/index.md | 12 +- .../reference/statements/import/index.md | 53 ++++--- .../reference/statements/label/index.md | 45 +++--- .../reference/statements/let/index.md | 67 +++++---- .../reference/statements/return/index.md | 21 +-- .../reference/statements/switch/index.md | 141 +++++++++--------- .../reference/statements/throw/index.md | 134 +++++++++-------- .../reference/statements/try...catch/index.md | 79 ++++------ .../reference/statements/var/index.md | 103 ++++++------- .../reference/statements/while/index.md | 6 +- .../reference/statements/with/index.md | 21 ++- .../javascript/reference/strict_mode/index.md | 98 ++++++------ .../reference/template_literals/index.md | 61 ++++---- .../reference/trailing_commas/index.md | 26 ++-- 88 files changed, 1491 insertions(+), 1419 deletions(-) diff --git a/files/fr/web/javascript/reference/operators/comma_operator/index.md b/files/fr/web/javascript/reference/operators/comma_operator/index.md index 67beeef75b2426..d636899af1b9e0 100644 --- a/files/fr/web/javascript/reference/operators/comma_operator/index.md +++ b/files/fr/web/javascript/reference/operators/comma_operator/index.md @@ -32,7 +32,7 @@ L'opérateur virgule est à différencier de la virgule utilisée pour séparer SI on a un tableau à 2 dimensions appelé `monTableau`, qui possède 10 éléments ayant chacun 10 éléments, on peut utiliser le code suivant avec l'opérateur virgule afin d'incrémenter deux variables (`i` et `j`) à la fois. Attention, la virgule utilisée au sein de l'instruction `var` **n'est pas** l'opérateur virgule (car il ne peut exister au sein d'une expression) ; ici c'est un caractère spécial de l'instruction {{jsxref("Instructions/var","var")}}. Le code qui suit affiche les éléments présents sur la diagonale de cette matrice : ```js -for (var i = 0, j = 9; i <= 9; i++, j--){ +for (var i = 0, j = 9; i <= 9; i++, j--) { console.log("monTableau[" + i + "][" + j + "] = " + monTableau[i][j]); } ``` @@ -41,16 +41,16 @@ Dans le code suivant, `a` est défini avec la valeur de `b = 3` (qui est 3) et l ```js var a, b, c; -a = b = 3, c = 4; // Renvoie 4 dans la console -console.log(a); // 3 +(a = b = 3), (c = 4); // Renvoie 4 dans la console +console.log(a); // 3 ``` Pour isoler la précédence de l'opérateur, on peut utiliser des parenthèses : ```js var x, y, z; -x = (y = 5, z = 6); // Renvoie 6 dans la console -console.log(x); // 6 +x = ((y = 5), (z = 6)); // Renvoie 6 dans la console +console.log(x); // 6 ``` ### Effectuer un traitement puis renvoyer une valeur @@ -58,10 +58,10 @@ console.log(x); // 6 Un autre exemple consiste à effectuer un certain traitement sur la variable puis à renvoyer le résultat. Par définition, seul le dernier élément sera renvoyé mais les instructions précédentes seront bien exécutées. AInsi, on pourrait avoir : ```js -function maFonction () { +function maFonction() { var x = 0; - return (x += 1, x); // ce qui revient à renvoyer ++x + return (x += 1), x; // ce qui revient à renvoyer ++x } ``` diff --git a/files/fr/web/javascript/reference/operators/conditional_operator/index.md b/files/fr/web/javascript/reference/operators/conditional_operator/index.md index 06a20919b9b73f..688d285401caa3 100644 --- a/files/fr/web/javascript/reference/operators/conditional_operator/index.md +++ b/files/fr/web/javascript/reference/operators/conditional_operator/index.md @@ -13,7 +13,7 @@ L'**opérateur (ternaire) conditionnel** est le seul opérateur JavaScript qui c ## Syntaxe ```js -condition ? exprSiVrai : exprSiFaux +condition ? exprSiVrai : exprSiFaux; ``` ### Paramètres @@ -30,7 +30,7 @@ condition ? exprSiVrai : exprSiFaux SI `condition` vaut `true`, l'opérateur renverra la valeur d'`exprSiVrai;` dans le cas contraire, il renverra la valeur de `exprSiFaux`. Par exemple, on peut afficher un message différent en fonction d'une variable `estMembre` avec cette déclaration : ```js -"Le prix est : " + (estMembre ? "15 €" : "30 €") +"Le prix est : " + (estMembre ? "15 €" : "30 €"); ``` On peut également affecter des variables dont la valeur dépendra du test : @@ -43,8 +43,12 @@ On peut enchaîner plusieurs évaluations ternaires l'une à la suite de l'autre ```js var premierControle = false, - secondControle = false, - acces = premierControle ? "Accès refusé" : secondControle ? "Accès refusé" : "Accès autorisé"; + secondControle = false, + acces = premierControle + ? "Accès refusé" + : secondControle + ? "Accès refusé" + : "Accès autorisé"; console.log(acces); // "Accès autorisé" ``` @@ -52,23 +56,21 @@ console.log(acces); // "Accès autorisé" Il est également possible d'utiliser cet opérateur pour effectuer l'une ou l'autre expression selon le cas de figure qui se présente : ```js -var stop = false, age = 16; +var stop = false, + age = 16; -age > 18 ? location.assign("continue.html") : stop = true; +age > 18 ? location.assign("continue.html") : (stop = true); ``` en utilisant l'{{jsxref("Opérateurs/L_opérateur_virgule","opérateur virgule")}}, on peut même y placer plusieurs instructions (attention toutefois à la lisibilité et à se demander si un {{jsxref("Instructions/if...else","if...else")}} n'est pas plus approprié). ```js -var stop = false, age = 23; - -age > 18 ? ( - console.log("OK, accès autorisé."), - location.assign("continue.html") -) : ( - stop = true, - console.log("Accès refusé !") -); +var stop = false, + age = 23; + +age > 18 + ? (console.log("OK, accès autorisé."), location.assign("continue.html")) + : ((stop = true), console.log("Accès refusé !")); ``` De la même façon, on peut effectuer plusieurs opérations, encadrées par des parenthèses, avant d'affecter le résultat de l'opérateur à une variable. Conformément à l'opérateur virgule, ce sera **_la dernière valeur qui sera affectée_**. Ici aussi, attention à la lisibilité du code relativement à un `if...else`. @@ -76,16 +78,15 @@ De la même façon, on peut effectuer plusieurs opérations, encadrées par des ```js var age = 16; -var url = age > 18 ? ( - console.log("Accès autorisé."), - // console.log renvoie "undefined", mais cela importe peu car - // ce n'est pas le dernier élément de l'expression - "continue.html" // la valeur à affecter si âge > 18 -) : ( - console.log("Accès refusé !"), - // etc. - "stop.html" // la valeur à affecter si âge <= 18 -); +var url = + age > 18 + ? (console.log("Accès autorisé."), + // console.log renvoie "undefined", mais cela importe peu car + // ce n'est pas le dernier élément de l'expression + "continue.html") // la valeur à affecter si âge > 18 + : (console.log("Accès refusé !"), + // etc. + "stop.html"); // la valeur à affecter si âge <= 18 location.assign(url); // "stop.html" ``` diff --git a/files/fr/web/javascript/reference/operators/delete/index.md b/files/fr/web/javascript/reference/operators/delete/index.md index 9f504fe5cb8ccc..864b97e9766486 100644 --- a/files/fr/web/javascript/reference/operators/delete/index.md +++ b/files/fr/web/javascript/reference/operators/delete/index.md @@ -13,14 +13,14 @@ L'opérateur **`delete`** permet de retirer une propriété d'un objet. ## Syntaxe ```js -delete expression +delete expression; ``` où _expression_ est évaluée comme une référence à une propriété : ```js -delete objet.propriete -delete objet['propriete'] +delete objet.propriete; +delete objet["propriete"]; ``` ### Paramètres @@ -59,12 +59,12 @@ Voici un fragment de code qui illustre certains cas : ```js var Employe = { age: 28, - nom: 'abc', - designation: 'developpeur' -} + nom: "abc", + designation: "developpeur", +}; -console.log(delete Employe.nom); // renvoie true -console.log(delete Employe.age); // renvoie true +console.log(delete Employe.nom); // renvoie true +console.log(delete Employe.age); // renvoie true // Lorsqu'on souhaite supprimer une propriété // inexistante, on obtient true @@ -77,19 +77,19 @@ Lorsqu'une propriété est marquée comme non-configurable, `delete` n'aura aucu ```js var Employe = {}; -Object.defineProperty(Employe, 'nom', {configurable: false}); +Object.defineProperty(Employe, "nom", { configurable: false }); -console.log(delete Employe.nom); // renvoie false +console.log(delete Employe.nom); // renvoie false ``` {{jsxref("Instructions/var","var")}} (ou `let` ou `const`) crée des propriétés non-configurables qui ne peuvent pas être supprimées via `delete` : ```js -var autreNom = 'XYZ'; +var autreNom = "XYZ"; // On peut accéder à la description de cette // propriété globale grâce à : -Object.getOwnPropertyDescriptor(window, 'autreNom') +Object.getOwnPropertyDescriptor(window, "autreNom"); /* Object {value: "XYZ", writable: true, @@ -100,7 +100,7 @@ Object.getOwnPropertyDescriptor(window, 'autreNom') // On voit que "autreNom", ajouté avec var // est marquée comme "non-configurable" -delete autreNom; // renvoie false +delete autreNom; // renvoie false ``` En mode strict, cela aurait déclenché une exception. @@ -126,7 +126,7 @@ Voyons comment ce code se comporte en mode strict : au lieu de renvoyer false, l "use strict"; function Employe() { - delete salaire; // SyntaxError + delete salaire; // SyntaxError var salaire; } @@ -144,25 +144,25 @@ delete DemoFunction; // SyntaxError ```js // on crée la propriété adminName sur la portée globale -adminName = 'xyz'; +adminName = "xyz"; // on crée la propriété empCount sur la portée globale // On utilise var, elle est donc non-configurable var empCount = 43; EmployeeDetails = { - name: 'xyz', + name: "xyz", age: 5, - designation: 'Developer' + designation: "Developer", }; // adminName est une propriété de la portée globale // qui peut être supprimée car configurable. -delete adminName; // renvoie true +delete adminName; // renvoie true // En revanche empCount n'est pas configurable // car c'est var qui a été utilisée. -delete empCount; // renvoie false +delete empCount; // renvoie false // delete peut être utilisé pour retirer des propriétés // d'objets @@ -178,14 +178,14 @@ delete Math.PI; // renvoie false // EmployeeDetails est une propriété de la portée globale // définie sans var, elle est donc configurable -delete EmployeeDetails; // renvoie true +delete EmployeeDetails; // renvoie true function f() { var z = 44; // delete n'a pas d'impact sur les noms // des variables locales - delete z; // returns false + delete z; // returns false } ``` @@ -194,7 +194,7 @@ function f() { Dans l'exemple qui suit, on supprime une propriété directement rattachée à un objet (une propriété « propre ») alors qu'une propriété du même nom existe sur la chaîne de prototypes : ```js -function Toto(){ +function Toto() { this.truc = 10; } @@ -228,17 +228,17 @@ Lorsqu'on supprime un élément d'un tableau, la longueur du tableau n'est pas m Lorsqu'on utilise `delete` pour retirer un élément du tableau, cet élément n'est plus dans le tableau. Dans l'exemple suivant, on retire `arbres[3]` grâce à `delete`. ```js -var arbres = ["cèdre","pin","chêne","érable","sapin"]; +var arbres = ["cèdre", "pin", "chêne", "érable", "sapin"]; delete arbres[3]; if (3 in arbres) { - // Le code ici ne sera pas exécuté + // Le code ici ne sera pas exécuté } ``` Si on veut conserver l'existence d'un élément du tableau avec une valeur indéfinie, on pourra affecter la valeur `undefined` à cet élément. Ainsi, contrairement à l'exemple précédent, en utilisant `undefined`, `arbres[3]` continue d'être présent : ```js -var arbres = ["cèdre","pin","chêne","érable","sapin"]; +var arbres = ["cèdre", "pin", "chêne", "érable", "sapin"]; arbres[3] = undefined; if (3 in arbres) { // Le code ici sera bien exécuté @@ -248,14 +248,14 @@ if (3 in arbres) { Si on souhaite plutôt retirer un élément du tableau en changeant le contenu du tableau, on pourra utiliser la méthode {{jsxref("Array.splice()")}}. Dans l'exemple qui suit, la valeur actuelle de `arbres[3]` est retirée du tableau grâce à `splice()` mais l'index suivant se décale et arbres\[4] devient arbres\[3] : ```js -var arbres = ["cèdre","pin","chêne","érable","sapin"]; +var arbres = ["cèdre", "pin", "chêne", "érable", "sapin"]; if (3 in arbres) { - // Le code ici sera exécuté + // Le code ici sera exécuté } arbres.splice(3, 1); console.log(arbres); // ["cèdre","pin","chêne","sapin"]; if (3 in arbres) { - // Le code ici sera également exécuté + // Le code ici sera également exécuté } ``` diff --git a/files/fr/web/javascript/reference/operators/destructuring_assignment/index.md b/files/fr/web/javascript/reference/operators/destructuring_assignment/index.md index ca88ebdd3ea4ca..7b1872b4241501 100644 --- a/files/fr/web/javascript/reference/operators/destructuring_assignment/index.md +++ b/files/fr/web/javascript/reference/operators/destructuring_assignment/index.md @@ -23,12 +23,12 @@ console.log(a); // 10 console.log(b); // 20 console.log(rest); // [30, 40, 50] -({a, b} = {a: 10, b: 20}); +({ a, b } = { a: 10, b: 20 }); console.log(a); // 10 console.log(b); // 20 // Proposition de syntaxe (niveau 4) -({a, b, ...rest} = {a: 10, b: 20, c: 30, d: 40}); +({ a, b, ...rest } = { a: 10, b: 20, c: 30, d: 40 }); console.log(a); // 10 console.log(b); // 20 console.log(rest); // {c: 30, d: 40} @@ -61,8 +61,8 @@ Cette syntaxe est semblable aux fonctionnalités offertes par des langages tels const toto = ["un", "deux", "trois"]; // sans utiliser la décomposition -const un = toto[0]; -const deux = toto[1]; +const un = toto[0]; +const deux = toto[1]; const trois = toto[2]; // en utilisant la décomposition @@ -76,8 +76,8 @@ L'affectation par décomposition peut être effectuée sans qu'il y ait de décl ```js let a, b; [a, b] = [1, 2]; -console.log(a); // 1 -console.log(b); // 2 +console.log(a); // 1 +console.log(b); // 2 ``` ### Valeurs par défaut @@ -150,7 +150,7 @@ console.log("A vaut " + a + " B vaut " + b); Après avoir exécuté ce code, on aura a égal à 1 et b égal à 3. La valeur 2 est ignorée. On peut ignorer n'importe laquelle des valeurs (voire toutes). Par exemple : ```js -[,,] = f(); +[, ,] = f(); ``` ### Exploiter les résultats d'une expression rationnelle @@ -169,7 +169,9 @@ function parseProtocol(url) { return protocol; } -console.log(parseProtocol('https://developer.mozilla.org/en-US/Web/JavaScript')); // "https" +console.log( + parseProtocol("https://developer.mozilla.org/en-US/Web/JavaScript"), +); // "https" ``` ### Affecter le reste d'un tableau à une variable @@ -184,8 +186,8 @@ console.log(b); // [2, 3] Un exception {{jsxref("SyntaxError")}} sera levée si une virgule est laissée à la fin de l'élément du reste du tableau de gauche : -```js example-bad -const [a, ...b,] = [1, 2, 3] +```js-nolint example-bad +const [a, ...b,] = [1, 2, 3]; // SyntaxError : un élément du reste ne peut pas avoir // de virgule à la fin ``` @@ -195,14 +197,14 @@ const [a, ...b,] = [1, 2, 3] ### Exemple simple ```js -const o = {p: 42, q: true}; -const {p, q} = o; +const o = { p: 42, q: true }; +const { p, q } = o; console.log(p); // 42 console.log(q); // true // Assign new variable names -const {p: toto, q: truc} = o; +const { p: toto, q: truc } = o; console.log(toto); // 42 console.log(truc); // true @@ -214,7 +216,7 @@ Il est possible d'effectuer une affectation par décomposition même si aucune d ```js let a, b; -({a, b} = {a:1, b:2}); +({ a, b } = { a: 1, b: 2 }); ``` > **Note :** Les parenthèses `( ... )` utilisées autour de l'instruction sont nécessaires pour que la partie gauche soit bien interprétée comme un objet littéral et non comme un bloc. Il est également nécessaire d'avoir un point-virgule avant les parenthèses de l'instruction car sinon, ces parenthèses peuvent être interprétées comme un appel de fonction. @@ -224,8 +226,8 @@ let a, b; Lorsqu'on décompose un objet, on peut affecter la variable obtenue sur une variable qui possède un autre nom (que celui de la propriété) : ```js -const o = {p: 42, q: true}; -const {p: toto, q: truc} = o; +const o = { p: 42, q: true }; +const { p: toto, q: truc } = o; console.log(toto); // 42 console.log(truc); // true @@ -238,7 +240,7 @@ Ici, par exemple, `const {p: toto} = o` prend la propriété `p` de l'objet `o` Une variable peut recevoir une valeur par défaut lors de la décomposition si la propriété correspondante de l'objet vaut `undefined`. ```js -const {a = 10, b = 5} = {a: 3}; +const { a = 10, b = 5 } = { a: 3 }; console.log(a); // 3 console.log(b); // 5 @@ -249,7 +251,7 @@ console.log(b); // 5 Il est possible d'extraitre une valeur d'un objet pour lui affecter un nouveau nom et lui affecter une valeur par défaut au cas où la valeur extraite vaut `undefined`. ```js -const {a: aa = 10, b: bb = 5} = {a: 3}; +const { a: aa = 10, b: bb = 5 } = { a: 3 }; console.log(aa); // 3 console.log(bb); // 5 @@ -262,7 +264,7 @@ console.log(bb); // 5 ```js function dessinGrapheES5(options) { options = options === undefined ? {} : options; - var size = options.size === undefined ? 'big' : options.size; + var size = options.size === undefined ? "big" : options.size; var coords = options.coords === undefined ? { x: 0, y: 0 } : options.coords; var radius = options.radius === undefined ? 25 : options.radius; console.log(size, coords, radius); @@ -271,22 +273,25 @@ function dessinGrapheES5(options) { dessinGrapheES5({ coords: { x: 18, y: 30 }, - radius: 30 + radius: 30, }); ``` #### Version ES2015 ```js -function dessinGrapheES2015({size = 'big', coords = { x: 0, y: 0 }, radius = 25} = {}) -{ +function dessinGrapheES2015({ + size = "big", + coords = { x: 0, y: 0 }, + radius = 25, +} = {}) { console.log(size, coords, radius); // on dessine le graphe } dessinGrapheES2015({ coords: { x: 18, y: 30 }, - radius: 30 + radius: 30, }); ``` @@ -296,23 +301,26 @@ dessinGrapheES2015({ ```js const metadata = { - title: "Scratchpad", - translations: [ - { - locale: "de", - localization_tags: [ ], - last_edit: "2014-04-14T08:43:37", - url: "/de/docs/Tools/Scratchpad", - title: "JavaScript-Umgebung" - } - ], - url: "/fr/docs/Tools/Scratchpad" + title: "Scratchpad", + translations: [ + { + locale: "de", + localization_tags: [], + last_edit: "2014-04-14T08:43:37", + url: "/de/docs/Tools/Scratchpad", + title: "JavaScript-Umgebung", + }, + ], + url: "/fr/docs/Tools/Scratchpad", }; -let { title: englishTitle, translations: [{ title: localeTitle }] } = metadata; +let { + title: englishTitle, + translations: [{ title: localeTitle }], +} = metadata; console.log(englishTitle); // "Scratchpad" -console.log(localeTitle); // "JavaScript-Umgebung" +console.log(localeTitle); // "JavaScript-Umgebung" ``` ### Décomposition et utilisation de [for of](/fr/docs/JavaScript/Référence_JavaScript/Instructions/for...of) @@ -324,22 +332,25 @@ const personnes = [ famille: { mere: "Isabelle Dupont", pere: "Jean Dupont", - soeur: "Laure Dupont" + soeur: "Laure Dupont", }, - age: 35 + age: 35, }, { nom: "Luc Marchetoile", famille: { mere: "Patricia Marchetoile", pere: "Antonin Marchetoile", - frere: "Yann Marchetoile" + frere: "Yann Marchetoile", }, - age: 25 - } + age: 25, + }, ]; -for (const {nom: n, famille: { pere: f } } of personnes) { +for (const { + nom: n, + famille: { pere: f }, +} of personnes) { console.log("Nom : " + n + ", Père : " + f); } @@ -355,19 +366,20 @@ const user = { displayName: "jbiche", fullName: { firstName: "Jean", - lastName: "Biche" - } + lastName: "Biche", + }, }; -function userId({id}) { +function userId({ id }) { return id; } -function whois({displayName: displayName, fullName: {firstName: name}}){ +function whois({ displayName: displayName, fullName: { firstName: name } }) { console.log(displayName + " est " + name); } -console.log("userId: " + userId(user)); w// "userId: 42" +console.log("userId: " + userId(user)); +w; // "userId: 42" whois(user); // "jbiche est Jean" ``` @@ -389,7 +401,7 @@ console.log(toto); // "truc" [La proposition de décomposition des propriétés et de la syntaxe du reste dans ECMAScript](https://github.com/tc39/proposal-object-rest-spread) ajoute [la syntaxe du reste](/fr/docs/Web/JavaScript/Reference/Fonctions/paramètres_du_reste) pour la décomposition. La propriété du reste permet de collecter les propriétés énumérables restantes qui n'auraient pas été extraites par la décomposition : ```js -let {a, b, ...reste } = {a: 10, b: 20, c: 30, d: 40}; +let { a, b, ...reste } = { a: 10, b: 20, c: 30, d: 40 }; a; // 10 b; // 20 reste; // { c: 30, d: 40 } @@ -400,10 +412,10 @@ reste; // { c: 30, d: 40 } Si besoin, on peut également utiliser la décomposition pour fournir un alias à des noms de propriétés qui ne seraient pas des identifiants valides. Par exemple : ```js -const toto = {'truc-bidule': true} -const {'truc-bidule': trucBidule } = toto; +const toto = { "truc-bidule": true }; +const { "truc-bidule": trucBidule } = toto; -console.log(trucBidule); // "true" +console.log(trucBidule); // "true" ``` ### Combiner la décomposition de tableaux et d'objets @@ -412,12 +424,12 @@ Il est possible de décomposer un tableau et un objet simultanément. Dans l'exe ```js const props = [ - { id: 1, nom: "Toto"}, - { id: 2, nom: "Truc"}, - { id: 3, nom: "Bidule"} + { id: 1, nom: "Toto" }, + { id: 2, nom: "Truc" }, + { id: 3, nom: "Bidule" }, ]; -const [,, {nom}] = props; +const [, , { nom }] = props; console.log(nom); // Bidule ``` diff --git a/files/fr/web/javascript/reference/operators/division/index.md b/files/fr/web/javascript/reference/operators/division/index.md index 8790d4d7484d0b..3e465ac5877709 100644 --- a/files/fr/web/javascript/reference/operators/division/index.md +++ b/files/fr/web/javascript/reference/operators/division/index.md @@ -12,7 +12,7 @@ L'opérateur de division (`/`) fournit le quotient de l'opérande gauche (le num ## Syntaxe ```js -Opérateur : x / y +Opérateur: x / y; ``` ## Exemples @@ -20,17 +20,17 @@ Opérateur : x / y ### Divisions simples ```js -1 / 2 // 0.5 -Math.floor(3 / 2) // 1 -1.0 / 2.0 // 0.5 +1 / 2; // 0.5 +Math.floor(3 / 2); // 1 +1.0 / 2.0; // 0.5 ``` ### Division par zéro ```js -2.0 / 0 // Infinity -2.0 / 0.0 // Infinity, because 0.0 === 0 -2.0 / -0.0 // -Infinity +2.0 / 0; // Infinity +2.0 / 0.0; // Infinity, because 0.0 === 0 +2.0 / -0.0; // -Infinity ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/division_assignment/index.md b/files/fr/web/javascript/reference/operators/division_assignment/index.md index de9d7e4821e068..f093712bc3551e 100644 --- a/files/fr/web/javascript/reference/operators/division_assignment/index.md +++ b/files/fr/web/javascript/reference/operators/division_assignment/index.md @@ -12,8 +12,8 @@ L'opérateur de division et d'affectation (`/=`) divise la variable fournie par ## Syntaxe ```js -Opérateur : x /= y -Signification: x = x / y +Opérateur: x /= y; +Signification: x = x / y; ``` ## Exemples @@ -22,10 +22,10 @@ Signification: x = x / y ```js let truc = 5; -truc /= 2; // 2.5 -truc /= 2; // 1.25 -truc /= 0; // Infinity -truc /= 'toto'; // NaN +truc /= 2; // 2.5 +truc /= 2; // 1.25 +truc /= 0; // Infinity +truc /= "toto"; // NaN ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/equality/index.md b/files/fr/web/javascript/reference/operators/equality/index.md index dc8b236ee53c7f..408e34d0e17b73 100644 --- a/files/fr/web/javascript/reference/operators/equality/index.md +++ b/files/fr/web/javascript/reference/operators/equality/index.md @@ -12,7 +12,7 @@ L'opérateur d'égalité (`==`) vérifie si ses deux opérandes sont égaux et r ## Syntaxe ```js -x == y +x == y; ``` ## Description @@ -40,36 +40,36 @@ La différence fondamentale entre cet opérateur et [l'opérateur d'égalité st ### Comparaison sans conversion de types ```js -1 == 1; // true -"coucou" == "coucou"; // true +1 == 1; // true +"coucou" == "coucou"; // true ``` ### Comparaison avec conversion de types ```js -"1" == 1; // true -1 == "1"; // true -0 == false; // true -0 == null; // false -0 == undefined; // false -0 == !!null; // true, voir la documentation pour !! -0 == !!undefined; // true, voir la documentation pour !! -null == undefined; // true +"1" == 1; // true +1 == "1"; // true +0 == false; // true +0 == null; // false +0 == undefined; // false +0 == !!null; // true, voir la documentation pour !! +0 == !!undefined; // true, voir la documentation pour !! +null == undefined; // true const nombre1 = new Number(3); const nombre2 = new Number(3); -nombre1 == 3; // true -nombre1 == nombre2; // false +nombre1 == 3; // true +nombre1 == nombre2; // false ``` ### Comparaison d'objets ```js -const objet1 = {"clé": "valeur"} -const objet2 = {"clé": "valeur"}; +const objet1 = { clé: "valeur" }; +const objet2 = { clé: "valeur" }; -objet1 == objet2 // false -objet2 == objet2 // true +objet1 == objet2; // false +objet2 == objet2; // true ``` ### Comparaison entre des chaînes de caractères et des objets String @@ -92,9 +92,9 @@ console.log(string4 == string4); // true ### Comparaison entre les dates et les chaînes de caractères ```js -const d = new Date('December 17, 1995 03:24:00'); +const d = new Date("December 17, 1995 03:24:00"); const s = d.toString(); // par exemple : "Sun Dec 17 1995 03:24:00 GMT-0800 (Pacific Standard Time)" -console.log(d == s); //true +console.log(d == s); //true ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/exponentiation/index.md b/files/fr/web/javascript/reference/operators/exponentiation/index.md index 097591322eda2d..1313f3b18f5005 100644 --- a/files/fr/web/javascript/reference/operators/exponentiation/index.md +++ b/files/fr/web/javascript/reference/operators/exponentiation/index.md @@ -12,7 +12,7 @@ L'opérateur d'exponentiation (`**`) fournit le résultat obtenu lorsqu'on élè ## Syntaxe ```js -Opérateur : var1 ** var2 +Opérateur: var1 ** var2; ``` ## Description @@ -39,19 +39,19 @@ Attnetion, certains langages de programmation utilisent l'accent circonflexe `) renvoie `true` si l'opérande gauche est st ## Syntaxe ```js -x > y +x > y; ``` ## Description @@ -24,57 +24,57 @@ Les opérandes sont comparés avec l'algorithme de [comparaison abstraite relati ### Comparaison numérique ```js -console.log(5 > 3); // true -console.log(3 > 3); // false -console.log(3 > 5); // false +console.log(5 > 3); // true +console.log(3 > 3); // false +console.log(3 > 5); // false ``` ### Comparaison entre un nombre et un BigInt ```js -console.log(5n > 3); // true -console.log(3 > 5n); // false +console.log(5n > 3); // true +console.log(3 > 5n); // false ``` ### Comparaison entre chaînes de caractères ```js -console.log("a" > "b"); // false -console.log("a" > "a"); // false -console.log("a" > "3"); // true +console.log("a" > "b"); // false +console.log("a" > "a"); // false +console.log("a" > "3"); // true ``` ### Comparaison entre nombres et chaînes de caractères ```js -console.log("5" > 3); // true -console.log("3" > 3); // false -console.log("3" > 5); // false +console.log("5" > 3); // true +console.log("3" > 3); // false +console.log("3" > 5); // false -console.log("coucou" > 5); // false -console.log(5 > "coucou"); // false +console.log("coucou" > 5); // false +console.log(5 > "coucou"); // false -console.log("5" > 3n); // true -console.log("3" > 5n); // false +console.log("5" > 3n); // true +console.log("3" > 5n); // false ``` ### Comparaison avec des booléens, null, undefined, NaN ```js -console.log(true > false); // true -console.log(false > true); // false +console.log(true > false); // true +console.log(false > true); // false -console.log(true > 0); // true -console.log(true > 1); // false +console.log(true > 0); // true +console.log(true > 1); // false -console.log(null > 0); // false -console.log(1 > null); // true +console.log(null > 0); // false +console.log(1 > null); // true -console.log(undefined > 3); // false -console.log(3 > undefined); // false +console.log(undefined > 3); // false +console.log(3 > undefined); // false -console.log(3 > NaN); // false -console.log(NaN > 3); // false +console.log(3 > NaN); // false +console.log(NaN > 3); // false ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/greater_than_or_equal/index.md b/files/fr/web/javascript/reference/operators/greater_than_or_equal/index.md index 04a93eb956921e..5b3823917d61bf 100644 --- a/files/fr/web/javascript/reference/operators/greater_than_or_equal/index.md +++ b/files/fr/web/javascript/reference/operators/greater_than_or_equal/index.md @@ -12,7 +12,7 @@ L'opérateur supérieur ou égal (`>=`) renvoie `true` si l'opérande gauche est ## Syntaxe ```js -x >= y +x >= y; ``` ## Description @@ -24,56 +24,56 @@ Les opérandes sont comparés avec l'algorithme de [comparaison abstraite relati ### Comparaison numérique ```js -console.log(5 >= 3); // true -console.log(3 >= 3); // true -console.log(3 >= 5); // false +console.log(5 >= 3); // true +console.log(3 >= 3); // true +console.log(3 >= 5); // false ``` ### Comparaison entre un nombre et un BigInt ```js -console.log(5n >= 3); // true -console.log(3 >= 3n); // true -console.log(3 >= 5n); // false +console.log(5n >= 3); // true +console.log(3 >= 3n); // true +console.log(3 >= 5n); // false ``` ### Comparaison entre chaînes de caractères ```js -console.log("a" >= "b"); // false -console.log("a" >= "a"); // true -console.log("a" >= "3"); // true +console.log("a" >= "b"); // false +console.log("a" >= "a"); // true +console.log("a" >= "3"); // true ``` ### Comparaison entre nombres et chaînes de caractères ```js -console.log("5" >= 3); // true -console.log("3" >= 3); // true -console.log("3" >= 5); // false +console.log("5" >= 3); // true +console.log("3" >= 3); // true +console.log("3" >= 5); // false -console.log("coucou" >= 5); // false -console.log(5 >= "coucou"); // false +console.log("coucou" >= 5); // false +console.log(5 >= "coucou"); // false ``` ### Comparaison avec des booléens, null, undefined, NaN ```js -console.log(true >= false); // true -console.log(true >= true); // true -console.log(false >= true); // false +console.log(true >= false); // true +console.log(true >= true); // true +console.log(false >= true); // false -console.log(true >= 0); // true -console.log(true >= 1); // true +console.log(true >= 0); // true +console.log(true >= 1); // true -console.log(null >= 0); // true -console.log(1 >= null); // true +console.log(null >= 0); // true +console.log(1 >= null); // true console.log(undefined >= 3); // false console.log(3 >= undefined); // false -console.log(3 >= NaN); // false -console.log(NaN >= 3); // false +console.log(3 >= NaN); // false +console.log(NaN >= 3); // false ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/grouping/index.md b/files/fr/web/javascript/reference/operators/grouping/index.md index d04665e9fe102d..d7685fc0523658 100644 --- a/files/fr/web/javascript/reference/operators/grouping/index.md +++ b/files/fr/web/javascript/reference/operators/grouping/index.md @@ -30,16 +30,16 @@ var b = 2; var c = 3; // précédence normale -a + b * c // 7 +a + b * c; // 7 // l'évaluation est effectuée de cette façon -a + (b * c) // 7 +a + (b * c); // 7 // précédence surchargée avec le groupement // on additionne avant de multiplier -(a + b) * c // 9 +(a + b) * c; // 9 // mathématiquement, cela est équivalent à -a * c + b * c // 9 +a * c + b * c; // 9 ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/import.meta/index.md b/files/fr/web/javascript/reference/operators/import.meta/index.md index 89e3ace8d35d29..5b9675e4b707d6 100644 --- a/files/fr/web/javascript/reference/operators/import.meta/index.md +++ b/files/fr/web/javascript/reference/operators/import.meta/index.md @@ -11,7 +11,7 @@ L'objet **`import.meta`** est une méta-propriété qui expose des métadonnées ## Syntaxe ```js -import.meta +import.meta; ``` ## Description diff --git a/files/fr/web/javascript/reference/operators/import/index.md b/files/fr/web/javascript/reference/operators/import/index.md index 475d563dede19d..afc7878051fabe 100644 --- a/files/fr/web/javascript/reference/operators/import/index.md +++ b/files/fr/web/javascript/reference/operators/import/index.md @@ -14,7 +14,7 @@ L'appel `import()`, généralement appelé _import dynamique_, est une expressio ## Syntaxe ```js -import(nomModule) +import(nomModule); ``` L'appel `import()` a une syntaxe qui ressemble à celle d'un appel de fonction, mais `import` est bien un mot-clé et pas une fonction. On ne peut pas créer de synonyme comme avec `const monImport = import`, cela déclenchera une exception [`SyntaxError`](/fr/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError). @@ -118,8 +118,8 @@ Ici, on charge 10 modules, `/modules/module-0.js`, `/modules/module-1.js`, etc., ```js Promise.all( Array.from({ length: 10 }).map((_, index) => - import(`/modules/module-${index}.js`) - ) + import(`/modules/module-${index}.js`), + ), ).then((modules) => modules.forEach((module) => module.load())); ``` diff --git a/files/fr/web/javascript/reference/operators/in/index.md b/files/fr/web/javascript/reference/operators/in/index.md index d451be6b695b29..3e3dc9ab76f5ff 100644 --- a/files/fr/web/javascript/reference/operators/in/index.md +++ b/files/fr/web/javascript/reference/operators/in/index.md @@ -13,7 +13,7 @@ L'**opérateur `in`** renvoie `true` si une propriété donnée appartient à l' ## Syntaxe ```js -propriété in nomObjet +propriété in nomObjet; ``` ### Paramètres @@ -30,33 +30,33 @@ Les exemples suivants illustrent certaines utilisation de l'opérateur `in`. ```js // Tableaux var arbres = ["sapin", "hêtre", "cèdre", "chêne", "érable"]; -0 in arbres // renvoie true -3 in arbres // renvoie true -6 in arbres // renvoie false -"hêtre" in arbres // renvoie false (l'indice doit être spécifié, pas la valeur à cet indice) -"length" in arbres // renvoie true (length est une propriété des objets Array) -Symbol.iterator in arbres // renvoie true (les tableaux sont itérables, à partir d'ES6) +0 in arbres; // renvoie true +3 in arbres; // renvoie true +6 in arbres; // renvoie false +"hêtre" in arbres; // renvoie false (l'indice doit être spécifié, pas la valeur à cet indice) +"length" in arbres; // renvoie true (length est une propriété des objets Array) +Symbol.iterator in arbres; // renvoie true (les tableaux sont itérables, à partir d'ES6) // Objets prédéfinis -"PI" in Math // renvoie true +"PI" in Math; // renvoie true var ma_chaine = new String("corail"); -"length" in ma_chaine // renvoie true +"length" in ma_chaine; // renvoie true // Objets personnalisés -var voiture = {marque: "Honda", modèle: "Accord", année: 1998}; -"marque" in voiture // renvoie true -"modèle" in voiture // renvoie true -"marque" in voiture // renvoie true -"Accord" in voiture // renvoie false +var voiture = { marque: "Honda", modèle: "Accord", année: 1998 }; +"marque" in voiture; // renvoie true +"modèle" in voiture; // renvoie true +"marque" in voiture; // renvoie true +"Accord" in voiture; // renvoie false ``` L'opérande droit doit toujours être du type objet (et pas un autre type primitif). Par exemple, on peut utiliser une chaîne créée avec le constructeur `String`, mais pas une chaîne littérale. ```js var couleur1 = new String("vert"); -"length" in couleur1 // renvoie true +"length" in couleur1; // renvoie true var couleur2 = "corail"; -"length" in couleur2 // génère une erreur (couleur n'est pas un objet String) +"length" in couleur2; // génère une erreur (couleur n'est pas un objet String) ``` ### Utilisation de l'opérateur `in` avec des propriétés supprimées ou indéfinies @@ -64,25 +64,25 @@ var couleur2 = "corail"; Si une propriété est supprimée avec l'opérateur [`delete`](/fr/Référence_de_JavaScript_1.5_Core/Opérateurs/Opérateurs_spéciaux/L'opérateur_delete), l'opérateur `in` renvoie `false` pour cette propriété. ```js -var voiture = {marque: "Honda", modèle: "Accord", année: 1998}; +var voiture = { marque: "Honda", modèle: "Accord", année: 1998 }; delete voiture.marque; -"marque" in voiture // renvoie false +"marque" in voiture; // renvoie false var arbres = new Array("sapin", "hêtre", "cèdre", "chêne", "érable"); delete arbres[3]; -3 in arbres // renvoie false +3 in arbres; // renvoie false ``` Si une propriété est définie à {{jsxref("Objets_globaux/undefined", "undefined")}} mais n'est pas supprimée, l'opérateur `in` renverra `true` pour cette propriété. ```js -var voiture = {marque: "Honda", modèle: "Accord", année: 1998}; +var voiture = { marque: "Honda", modèle: "Accord", année: 1998 }; voiture.marque = undefined; -"marque" in voiture // renvoie true +"marque" in voiture; // renvoie true var arbres = new Array("sapin", "hêtre", "cèdre", "chêne", "érable"); arbres[3] = undefined; -3 in arbres // renvoie true +3 in arbres; // renvoie true ``` ### Propriétés héritées diff --git a/files/fr/web/javascript/reference/operators/inequality/index.md b/files/fr/web/javascript/reference/operators/inequality/index.md index 2396cdc42ba5d7..e5cad356d4a226 100644 --- a/files/fr/web/javascript/reference/operators/inequality/index.md +++ b/files/fr/web/javascript/reference/operators/inequality/index.md @@ -12,7 +12,7 @@ L'opérateur d'inégalité (`!=`) vérifie si ses deux opérandes ne sont pas é ## Syntaxe ```js -x != y +x != y; ``` ## Description @@ -20,8 +20,8 @@ x != y L'opérateur d'inégalité vérifie si ses deux opérandes ne sont pas égaux. Il s'agit de la négation de [l'opérateur d'égalité](/fr/docs/Web/JavaScript/Reference/Operators/Equality) et les deux lignes suivantes fourniront donc toujours le même résultat : ```js -x != y -!(x == y) +x != y; +!(x == y); ``` Pour plus de détails sur l'algorithme de comparaison utilisé, voir [la page relative à l'opérateur d'égalité](/fr/docs/Web/JavaScript/Reference/Operators/Equality). @@ -43,39 +43,39 @@ Si cette conversion implicite n'est pas souhaitable et qu'on souhaite considére ### Comparaison sans conversion de types ```js -1 != 2; // true -"hello" != "hola"; // true +1 != 2; // true +"hello" != "hola"; // true -1 != 1; // false -"hello" != "hello"; // false +1 != 1; // false +"hello" != "hello"; // false ``` ### Comparaison avec conversion de types ```js -"1" != 1; // false -1 != "1"; // false -0 != false; // false -0 != null; // true -0 != undefined; // true -0 != !!null; // false, voir la documentation pour !! -0 != !!undefined; // false, voir la documentation pour !! -null != undefined; // false +"1" != 1; // false +1 != "1"; // false +0 != false; // false +0 != null; // true +0 != undefined; // true +0 != !!null; // false, voir la documentation pour !! +0 != !!undefined; // false, voir la documentation pour !! +null != undefined; // false const number1 = new Number(3); const number2 = new Number(3); -number1 != 3; // false -number1 != number2; // true +number1 != 3; // false +number1 != number2; // true ``` ### Comparaison d'objets ```js -const objet1 = {"clé": "valeur"} -const objet2 = {"clé": "valeur"}; +const objet1 = { clé: "valeur" }; +const objet2 = { clé: "valeur" }; -objet1 != objet2 // true -objet2 != objet2 // false +objet1 != objet2; // true +objet2 != objet2; // false ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/instanceof/index.md b/files/fr/web/javascript/reference/operators/instanceof/index.md index f5cfe64f4fd9ce..07ae3bb0c1f49b 100644 --- a/files/fr/web/javascript/reference/operators/instanceof/index.md +++ b/files/fr/web/javascript/reference/operators/instanceof/index.md @@ -13,7 +13,7 @@ L'**opérateur `instanceof`** permet de tester si un objet possède, dans sa cha ## Syntaxe ```js -objet instanceof constructeur +objet instanceof constructeur; ``` ### Paramètres @@ -28,8 +28,8 @@ objet instanceof constructeur L'opérateur `instanceof` teste la présence de `constructeur.prototype` dans la chaîne de prototypes d'`objet`. ```js -function C(){} // Définition du constructeur -function D(){} // Définition d'un autre constructeur +function C() {} // Définition du constructeur +function D() {} // Définition d'un autre constructeur var o = new C(); @@ -40,7 +40,7 @@ o instanceof C; o instanceof D; o instanceof Object; // true, car: -C.prototype instanceof Object // true +C.prototype instanceof Object; // true C.prototype = {}; var o2 = new C(); @@ -110,7 +110,7 @@ function Voiture(fabricant, modele, annee) { } var mavoiture = new Voiture("Citroën", "C3", 2006); var a = mavoiture instanceof Voiture; // retourne true -var b = mavoiture instanceof Object; // retourne true +var b = mavoiture instanceof Object; // retourne true ``` ### Attention à la précédence des opérateurs diff --git a/files/fr/web/javascript/reference/operators/left_shift/index.md b/files/fr/web/javascript/reference/operators/left_shift/index.md index 7e0216f0955e79..dc7530ebee8282 100644 --- a/files/fr/web/javascript/reference/operators/left_shift/index.md +++ b/files/fr/web/javascript/reference/operators/left_shift/index.md @@ -12,7 +12,7 @@ L'opérateur de **décalage binaire à gauche (`<<`)** décale la séquence de b ## Syntaxe ```js -a << b +a << b; ``` ## Description diff --git a/files/fr/web/javascript/reference/operators/left_shift_assignment/index.md b/files/fr/web/javascript/reference/operators/left_shift_assignment/index.md index 25804b8ddf3832..9c6b461a85d9c0 100644 --- a/files/fr/web/javascript/reference/operators/left_shift_assignment/index.md +++ b/files/fr/web/javascript/reference/operators/left_shift_assignment/index.md @@ -12,8 +12,8 @@ L'opérateur de décalage à gauche et d'affectation (`<<=`) décale la séquenc ## Syntaxe ```js -Opérateur : x <<= y -Signification : x = x << y +Opérateur: x <<= y; +Signification: x = x << y; ``` ## Exemples diff --git a/files/fr/web/javascript/reference/operators/less_than/index.md b/files/fr/web/javascript/reference/operators/less_than/index.md index 5d55544a672e95..e3f477a123298a 100644 --- a/files/fr/web/javascript/reference/operators/less_than/index.md +++ b/files/fr/web/javascript/reference/operators/less_than/index.md @@ -12,7 +12,7 @@ L'opérateur inférieur strict (`<`) renvoie `true` si son opérande gauche est ## Syntaxe ```js -x < y +x < y; ``` ## Description @@ -36,57 +36,57 @@ Les opérandes sont comparés avec l'algorithme de [comparaison abstraite relati ### Comparaison numérique ```js -console.log(5 < 3); // false -console.log(3 < 3); // false -console.log(3 < 5); // true +console.log(5 < 3); // false +console.log(3 < 3); // false +console.log(3 < 5); // true ``` ### Comparaison entre un nombre et un BigInt ```js -console.log(5n < 3); // false -console.log(3 < 5n); // true +console.log(5n < 3); // false +console.log(3 < 5n); // true ``` ### Comparaison entre chaînes de caractères ```js -console.log("a" < "b"); // true -console.log("a" < "a"); // false -console.log("a" < "3"); // false +console.log("a" < "b"); // true +console.log("a" < "a"); // false +console.log("a" < "3"); // false ``` ### Comparaison entre nombres et chaînes de caractères ```js -console.log("5" < 3); // false -console.log("3" < 3); // false -console.log("3" < 5); // true +console.log("5" < 3); // false +console.log("3" < 3); // false +console.log("3" < 5); // true -console.log("coucou" < 5); // false -console.log(5 < "coucou"); // false +console.log("coucou" < 5); // false +console.log(5 < "coucou"); // false -console.log("5" < 3n); // false -console.log("3" < 5n); // true +console.log("5" < 3n); // false +console.log("3" < 5n); // true ``` ### Comparaison avec des booléens, null, undefined, NaN ```js -console.log(true < false); // false -console.log(false < true); // true +console.log(true < false); // false +console.log(false < true); // true -console.log(0 < true); // true -console.log(true < 1); // false +console.log(0 < true); // true +console.log(true < 1); // false -console.log(null < 0); // false -console.log(null < 1); // true +console.log(null < 0); // false +console.log(null < 1); // true -console.log(undefined < 3); // false -console.log(3 < undefined); // false +console.log(undefined < 3); // false +console.log(3 < undefined); // false -console.log(3 < NaN); // false -console.log(NaN < 3); // false +console.log(3 < NaN); // false +console.log(NaN < 3); // false ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/less_than_or_equal/index.md b/files/fr/web/javascript/reference/operators/less_than_or_equal/index.md index 84be92ff157ee5..119efad75c52f2 100644 --- a/files/fr/web/javascript/reference/operators/less_than_or_equal/index.md +++ b/files/fr/web/javascript/reference/operators/less_than_or_equal/index.md @@ -12,7 +12,7 @@ L'opérateur inférieur ou égal (`<=`) renvoie `true` si l'opérande gauche est ## Syntaxe ```js -x <= y +x <= y; ``` ## Description @@ -24,56 +24,56 @@ Les opérandes sont comparés avec l'algorithme de [comparaison abstraite relati ### Comparaison numérique ```js -console.log(5 <= 3); // false -console.log(3 <= 3); // true -console.log(3 <= 5); // true +console.log(5 <= 3); // false +console.log(3 <= 3); // true +console.log(3 <= 5); // true ``` ### Comparaison entre un nombre et un BigInt ```js -console.log(5n <= 3); // false -console.log(3 <= 3n); // true -console.log(3 <= 5n); // true +console.log(5n <= 3); // false +console.log(3 <= 3n); // true +console.log(3 <= 5n); // true ``` ### Comparaison entre chaînes de caractères ```js -console.log("a" <= "b"); // true -console.log("a" <= "a"); // true -console.log("a" <= "3"); // false +console.log("a" <= "b"); // true +console.log("a" <= "a"); // true +console.log("a" <= "3"); // false ``` ### Comparaison entre nombres et chaînes de caractères ```js -console.log("5" <= 3); // false -console.log("3" <= 3); // true -console.log("3" <= 5); // true +console.log("5" <= 3); // false +console.log("3" <= 3); // true +console.log("3" <= 5); // true -console.log("coucou" <= 5); // false -console.log(5 <= "coucou"); // false +console.log("coucou" <= 5); // false +console.log(5 <= "coucou"); // false ``` ### Comparaison avec des booléens, null, undefined, NaN ```js -console.log(true <= false); // false -console.log(true <= true); // true -console.log(false <= true); // true +console.log(true <= false); // false +console.log(true <= true); // true +console.log(false <= true); // true -console.log(true <= 0); // false -console.log(true <= 1); // true +console.log(true <= 0); // false +console.log(true <= 1); // true -console.log(null <= 0); // true -console.log(1 <= null); // false +console.log(null <= 0); // true +console.log(1 <= null); // false console.log(undefined <= 3); // false console.log(3 <= undefined); // false -console.log(3 <= NaN); // false -console.log(NaN <= 3); // false +console.log(3 <= NaN); // false +console.log(NaN <= 3); // false ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/logical_and/index.md b/files/fr/web/javascript/reference/operators/logical_and/index.md index 795765efd83083..fbe29329d2d7cf 100644 --- a/files/fr/web/javascript/reference/operators/logical_and/index.md +++ b/files/fr/web/javascript/reference/operators/logical_and/index.md @@ -12,7 +12,7 @@ L'opérateur ET logique (`&&`) (conjonction logique) renvoie vrai si et uniqueme ## Syntaxe ```js -expr1 && expr2 +expr1 && expr2; ``` ## Description @@ -40,17 +40,17 @@ L'expression utilisant un ET logique est évaluée de gauche à droite. Le moteu Cette notion de court-circuit indique que la partie `expr` ci-avant **n'est pas évaluée**, tout effet de bord lié à cette évaluation n'aura pas lieu (par exemple, si `expr` est un appel de fonction, la fonction n'est pas appelée). Ce fonctionnement a lieu, car la valeur du résultat peut d'office être déterminée par l'évaluation du premier opérande. Par exemple : ```js -function A(){ - console.log('A a été appelée'); +function A() { + console.log("A a été appelée"); return false; } -function B(){ - console.log('B a été appelée'); +function B() { + console.log("B a été appelée"); return true; } -console.log( A() && B() ); +console.log(A() && B()); // affichera "A a été appelée" dans la console via l'appel de la fonction // puis affichera false (la valeur du résultat de l'expression avec l'opérateur) // on voit que la fonction B n'est pas du tout appelée @@ -61,9 +61,8 @@ console.log( A() && B() ); Les expressions suivantes peuvent sembler équivalentes mais ne le sont pas. En effet, l'opérateur `&&` est exécuté avant l'opérateur `||` (voir [l'article sur la précédence des opérateurs](/fr/docs/Web/JavaScript/Reference/Operators/Operator_Precedence)). ```js -true || false && false // renvoie true, car && est exécuté en premier -(true || false) && false // renvoie false, car la précédence par défaut ne s'applique pas - // avec les parenthèses +true || false && false; // renvoie true, car && est exécuté en premier +(true || false) && false; // renvoie false, car la précédence par défaut ne s'applique pas avec les parenthèses ``` ## Exemples @@ -73,15 +72,15 @@ true || false && false // renvoie true, car && est exécuté en premier Le code suivant illustre quelques usages de l'opérateur ET logique `&&`. ```js -a1 = true && true // t && t renvoie true -a2 = true && false // t && f renvoie false -a3 = false && true // f && t renvoie false -a4 = false && (3 == 4) // f && f renvoie false -a5 = 'Chat' && 'Chien' // t && t renvoie "Chien" -a6 = false && 'Chat' // f && t renvoie false -a7 = 'Chat' && false // t && f renvoie false -a8 = '' && false // f && f renvoie "" -a9 = false && '' // f && f renvoie false +a1 = true && true; // t && t renvoie true +a2 = true && false; // t && f renvoie false +a3 = false && true; // f && t renvoie false +a4 = false && 3 == 4; // f && f renvoie false +a5 = "Chat" && "Chien"; // t && t renvoie "Chien" +a6 = false && "Chat"; // f && t renvoie false +a7 = "Chat" && false; // t && f renvoie false +a8 = "" && false; // f && f renvoie "" +a9 = false && ""; // f && f renvoie false ``` ### Règles de conversion booléennes @@ -91,13 +90,13 @@ a9 = false && '' // f && f renvoie false L'opération suivante, utilisant des **booléens** : ```js -bCondition1 && bCondition2 +bCondition1 && bCondition2; ``` sera toujours équivalente à : ```js -!(!bCondition1 || !bCondition2) +!(!bCondition1 || !bCondition2); ``` #### Convertir OU en ET @@ -105,13 +104,13 @@ sera toujours équivalente à : L'opération suivante, utilisant des **booléens** : ```js -bCondition1 || bCondition2 +bCondition1 || bCondition2; ``` sera toujours équivalente à : ```js -!(!bCondition1 && !bCondition2) +!(!bCondition1 && !bCondition2); ``` ### Retrait des parenthèses imbriquées @@ -121,13 +120,13 @@ Les expressions logiques sont évaluées de gauche à droite, il est donc possib L'opération composite suivant, qui utilise des **booléens** : ```js -bCondition1 || (bCondition2 && bCondition3) +bCondition1 || (bCondition2 && bCondition3); ``` sera toujours égale à : ```js -bCondition1 || bCondition2 && bCondition3 +bCondition1 || (bCondition2 && bCondition3); ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/logical_and_assignment/index.md b/files/fr/web/javascript/reference/operators/logical_and_assignment/index.md index 5a596af7aeccd8..8168ba5d92e614 100644 --- a/files/fr/web/javascript/reference/operators/logical_and_assignment/index.md +++ b/files/fr/web/javascript/reference/operators/logical_and_assignment/index.md @@ -12,7 +12,7 @@ L'opérateur d'affectation après ET logique (`x &&= y`) n'affecte la valeur de ## Syntaxe ```js -expr1 &&= expr2 +expr1 &&= expr2; ``` ## Description diff --git a/files/fr/web/javascript/reference/operators/logical_not/index.md b/files/fr/web/javascript/reference/operators/logical_not/index.md index 6ab3d8307c3f9f..3ffb3612ef8c4f 100644 --- a/files/fr/web/javascript/reference/operators/logical_not/index.md +++ b/files/fr/web/javascript/reference/operators/logical_not/index.md @@ -12,7 +12,7 @@ L'opérateur logique NON (`!`) prend l'opposé logique de la valeur fournie par ## Syntaxe ```js -!expr +!expr; ``` ## Description @@ -38,10 +38,10 @@ Bien que l'opérateur `!` puisse être utilisé avec des opérandes non booléen Le code suivant illustre l'utilisation de l'opérateur `!` pour le NON logique. ```js -let n1 = !true // !t renvoie false -let n2 = !false // !f renvoie true -let n3 = !'' // !f renvoie true -let n4 = !'Cat' // !t renvoie false +let n1 = !true; // !t renvoie false +let n2 = !false; // !f renvoie true +let n3 = !""; // !f renvoie true +let n4 = !"Cat"; // !t renvoie false ``` ### Double NON (`!!`) @@ -51,12 +51,12 @@ Il est possible d'utiliser deux opérateurs NON à la suite pour convertir n'imp Une conversion équivalente pourra être obtenue avec le constructeur [`Boolean`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Boolean). ```js -let n1 = !!true // !!truthy renvoie true -let n2 = !!{} // !!truthy renvoie true : tout objet est truthy -let n3 = !!(new Boolean(false)) // Attention, un objet Boolean est toujours truthy ! -let n4 = !!false // !!falsy renvoie false -let n5 = !!"" // !!falsy renvoie false -let n6 = !!Boolean(false) // !!falsy renvoie false +let n1 = !!true; // !!truthy renvoie true +let n2 = !!{}; // !!truthy renvoie true : tout objet est truthy +let n3 = !!new Boolean(false); // Attention, un objet Boolean est toujours truthy ! +let n4 = !!false; // !!falsy renvoie false +let n5 = !!""; // !!falsy renvoie false +let n6 = !!Boolean(false); // !!falsy renvoie false ``` ### Équivalence booléenne de la double négation @@ -64,13 +64,13 @@ let n6 = !!Boolean(false) // !!falsy renvoie false L'expression qui suit, utilisée avec des booléens : ```js -!!bCondition +!!bCondition; ``` est toujours égale à : ```js -bCondition +bCondition; ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/logical_or/index.md b/files/fr/web/javascript/reference/operators/logical_or/index.md index a75d4ef6a09467..4c49f840e6b7bf 100644 --- a/files/fr/web/javascript/reference/operators/logical_or/index.md +++ b/files/fr/web/javascript/reference/operators/logical_or/index.md @@ -12,7 +12,7 @@ L'opérateur OU logique (`||`) (disjonction logique) renvoie vrai si et seulemen ## Syntaxe ```js -expr1 || expr2 +expr1 || expr2; ``` ## Description @@ -40,17 +40,17 @@ L'expression utilisant un OU logique est évaluée de gauche à droite. Le moteu Cette notion de court-circuit indique que la partie `expr` ci-avant **n'est pas évaluée**, tout effet de bord lié à cette évaluation n'aura pas lieu (par exemple, si `expr` est un appel de fonction, la fonction n'est pas appelée). Ce fonctionnement a lieu, car la valeur du résultat peut d'office être déterminée par l'évaluation du premier opérande. Par exemple : ```js -function A(){ - console.log('A a été appelée'); +function A() { + console.log("A a été appelée"); return false; } -function B(){ - console.log('B a été appelée'); +function B() { + console.log("B a été appelée"); return true; } -console.log( B() || A() ); +console.log(B() || A()); // affichera "B a été appelée" dans la console via l'appel de la fonction // puis affichera true (la valeur du résultat de l'expression avec l'opérateur) // on voit que la fonction A n'est pas du tout appelée @@ -61,9 +61,8 @@ console.log( B() || A() ); Les expressions suivantes peuvent sembler équivalentes mais ne le sont pas. En effet, l'opérateur `&&` est exécuté avant l'opérateur `||` (voir [l'article sur la précédence des opérateurs](/fr/docs/Web/JavaScript/Reference/Operators/Operator_Precedence)). ```js -true || false && false // renvoie true, car && est exécuté en premier -(true || false) && false // renvoie false, car la précédence par défaut ne s'applique pas - // avec les parenthèses +true || false && false; // renvoie true, car && est exécuté en premier +(true || false) && false; // renvoie false, car la précédence par défaut ne s'applique pas avec les parenthèses ``` ## Exemples @@ -73,16 +72,16 @@ true || false && false // renvoie true, car && est exécuté en premier Le code suivant illustre quelques usages de l'opérateur OU logique `||`. ```js -o1 = true || true // t || t renvoie true -o2 = false || true // f || t renvoie true -o3 = true || false // t || f renvoie true -o4 = false || (3 == 4) // f || f renvoie false -o5 = 'Chat' || 'Chien' // t || t renvoie "Chat" -o6 = false || 'Chat' // f || t renvoie "Chat" -o7 = 'Chat' || false // t || f renvoie "Chat" -o8 = '' || false // f || f renvoie false -o9 = false || '' // f || f renvoie "" -o10 = false || varObject // f || object renvoie varObject +o1 = true || true; // t || t renvoie true +o2 = false || true; // f || t renvoie true +o3 = true || false; // t || f renvoie true +o4 = false || 3 == 4; // f || f renvoie false +o5 = "Chat" || "Chien"; // t || t renvoie "Chat" +o6 = false || "Chat"; // f || t renvoie "Chat" +o7 = "Chat" || false; // t || f renvoie "Chat" +o8 = "" || false; // f || f renvoie false +o9 = false || ""; // f || f renvoie "" +o10 = false || varObject; // f || object renvoie varObject ``` > **Note :** Si vous utilisez cet opérateur afin de fournir une valeur par défaut à une variable. Soyez conscient⋅e qu'une valeur équivalente à `false` ne pourra pas être utilisée ainsi. Si vous souhaitez uniquement écarter [`null`](/fr/docs/Web/JavaScript/Reference/Global_Objects/null) ou [`undefined`](/fr/docs/Web/JavaScript/Reference/Global_Objects/undefined), privilégiez l'utilisation de [l'opérateur de coalescence des nuls](/fr/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator). @@ -94,13 +93,13 @@ o10 = false || varObject // f || object renvoie varObject L'opération suivante, utilisant des **booléens** : ```js -bCondition1 && bCondition2 +bCondition1 && bCondition2; ``` sera toujours équivalente à : ```js -!(!bCondition1 || !bCondition2) +!(!bCondition1 || !bCondition2); ``` #### Convertir OU en ET @@ -108,13 +107,13 @@ sera toujours équivalente à : L'opération suivante, utilisant des **booléens** : ```js -bCondition1 || bCondition2 +bCondition1 || bCondition2; ``` sera toujours équivalente à : ```js -!(!bCondition1 && !bCondition2) +!(!bCondition1 && !bCondition2); ``` ### Retrait des parenthèses imbriquées @@ -124,13 +123,13 @@ Les expressions logiques sont évaluées de gauche à droite, il est donc possib L'opération composite suivante, utilisant des **booléens** : ```js -bCondition1 && (bCondition2 || bCondition3) +bCondition1 && (bCondition2 || bCondition3); ``` sera toujours équivalente à : ```js -!(!bCondition1 || !bCondition2 && !bCondition3) +!(!bCondition1 || (!bCondition2 && !bCondition3)); ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/logical_or_assignment/index.md b/files/fr/web/javascript/reference/operators/logical_or_assignment/index.md index 4eb4eedd204630..a590b4b5e3533a 100644 --- a/files/fr/web/javascript/reference/operators/logical_or_assignment/index.md +++ b/files/fr/web/javascript/reference/operators/logical_or_assignment/index.md @@ -12,7 +12,7 @@ L'opérateur d'affectation après OU logique (`x ||= y`) n'affecte la valeur de ## Syntaxe ```js -expr1 ||= expr2 +expr1 ||= expr2; ``` ## Description @@ -50,7 +50,7 @@ On notera que ce comportement est différent entre les opérateurs binaires et l Dans l'exemple qui suit, si `paroles` est vide, on y place une valeur par défaut : ```js -document.getElementById('paroles').textContent ||= 'Aucune parole.' +document.getElementById("paroles").textContent ||= "Aucune parole."; ``` Ici, la notion de court-circuit est utile, car l'élément ne sera pas mis à jour si ce n'est pas nécessaire. Il n'y aura pas d'effet de bord indésiré comme une autre étape de rendu ou la perte du focus, etc. diff --git a/files/fr/web/javascript/reference/operators/multiplication/index.md b/files/fr/web/javascript/reference/operators/multiplication/index.md index a0b8002ebea96b..99ea8beae383ee 100644 --- a/files/fr/web/javascript/reference/operators/multiplication/index.md +++ b/files/fr/web/javascript/reference/operators/multiplication/index.md @@ -12,7 +12,7 @@ L'opérateur de multiplication (`*`) fournit le produit de la multiplication des ## Syntaxe ```js -Opérateur : x * y +Opérateur: x * y; ``` ## Exemples @@ -20,21 +20,21 @@ Opérateur : x * y ### Avec des nombres ```js - 2 * 2 // 4 --2 * 2 // -4 +2 * 2; // 4 +-2 * 2; // -4 ``` ### Avec l'infini ```js -Infinity * 0 // NaN -Infinity * Infinity // Infinity +Infinity * 0; // NaN +Infinity * Infinity; // Infinity ``` ### Avec des valeurs non-numériques ```js -'foo' * 2 // NaN +"foo" * 2; // NaN ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/multiplication_assignment/index.md b/files/fr/web/javascript/reference/operators/multiplication_assignment/index.md index 5ed8422a4ab6c5..7f168edb745f92 100644 --- a/files/fr/web/javascript/reference/operators/multiplication_assignment/index.md +++ b/files/fr/web/javascript/reference/operators/multiplication_assignment/index.md @@ -12,8 +12,8 @@ L'opérateur de multiplication et d'affectation (`*=`) multiplie une variable fo ## Syntaxe ```js -Opérateur : x *= y -Signification : x = x * y +Opérateur: x *= y; +Signification: x = x * y; ``` ## Exemples @@ -22,8 +22,8 @@ Signification : x = x * y ```js let truc = 5; -truc *= 2; // 10 -truc *= 'toto'; // NaN +truc *= 2; // 10 +truc *= "toto"; // NaN ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/new.target/index.md b/files/fr/web/javascript/reference/operators/new.target/index.md index a7279e9882b7ea..974d41f7293c44 100644 --- a/files/fr/web/javascript/reference/operators/new.target/index.md +++ b/files/fr/web/javascript/reference/operators/new.target/index.md @@ -13,7 +13,7 @@ La syntaxe **`new.target`** est disponible dans toutes les fonctions et permet e ## Syntaxe ```js -new.target +new.target; ``` ## Description @@ -29,8 +29,8 @@ La syntaxe `new.target` se compose du mot-clé `new`, suivi d'un point puis d'un Utilisé dans les appels de fonctions « classiques » (autrement dit pour les fonctions qui ne sont pas des constructeurs), `new.target` vaut {{jsxref("undefined")}}. Cela permet de détecter si une fonction a été appelée comme constructeur avec [`new`](/fr/docs/Web/JavaScript/Reference/Opérateurs/L_opérateur_new) : ```js -function Toto(){ - if (!new.target) throw "Toto() doit être appelé avec new" +function Toto() { + if (!new.target) throw "Toto() doit être appelé avec new"; console.log("Toto instancié avec new"); } @@ -49,7 +49,11 @@ class A { } } -class B extends A { constructor() { super(); } } +class B extends A { + constructor() { + super(); + } +} var a = new A(); // affiche "A" var b = new B(); // affiche "B" diff --git a/files/fr/web/javascript/reference/operators/new/index.md b/files/fr/web/javascript/reference/operators/new/index.md index ab1c9cbe86bad1..3f6adcb519b374 100644 --- a/files/fr/web/javascript/reference/operators/new/index.md +++ b/files/fr/web/javascript/reference/operators/new/index.md @@ -19,8 +19,8 @@ Le mot-clé `new`, utilisé avec une fonction, applique les 4 étapes suivantes ## Syntaxe -```js -new constructeur[([arguments])] +```js-nolint +new constructeur[([arguments])]; ``` ### Paramètres @@ -54,18 +54,18 @@ function Voiture() {} voiture1 = new Voiture(); voiture2 = new Voiture(); -console.log(voiture1.couleur); // undefined +console.log(voiture1.couleur); // undefined Voiture.prototype.couleur = "couleur standard"; -console.log(voiture1.couleur); // couleur standard +console.log(voiture1.couleur); // couleur standard voiture1.couleur = "noir"; -console.log(voiture1.couleur); // noir +console.log(voiture1.couleur); // noir -console.log(voiture1.__proto__.couleur); // couleur standard -console.log(voiture2.__proto__.couleur); // couleur standard -console.log(voiture1.couleur); // noir -console.log(voiture2.couleur); // couleur standard +console.log(voiture1.__proto__.couleur); // couleur standard +console.log(voiture2.__proto__.couleur); // couleur standard +console.log(voiture1.couleur); // noir +console.log(voiture2.couleur); // couleur standard ``` > **Note :** Si on n'écrit pas l'appel du constructeur avec l'opérateur `new`, le constructeur est appelé comme une fonction normale et ne crée pas d'objet. Dans ce cas, la valeur de `this` sera différente. @@ -78,9 +78,9 @@ Supposons que vous vouliez créer un type d'objet pour les voitures. Vous voulez ```js function Voiture(marque, modèle, année) { - this.marque = marque; - this.modèle = modèle; - this.année = année; + this.marque = marque; + this.modèle = modèle; + this.année = année; } ``` @@ -104,9 +104,9 @@ Supposons que vous ayez défini un objet appelé `Personne` de la manière suiva ```js function Personne(nom, age, surnom) { - this.nom = nom; - this.age = age; - this.surnom = surnom; + this.nom = nom; + this.age = age; + this.surnom = surnom; } ``` @@ -121,10 +121,10 @@ Vous pouvez alors réécrire la définition de `Voiture` pour contenir une propr ```js function Voiture(marque, modèle, année, propriétaire) { - this.marque = marque; - this.modèle = modèle; - this.année = année; - this.propriétaire = propriétaire; + this.marque = marque; + this.modèle = modèle; + this.année = année; + this.propriétaire = propriétaire; } ``` @@ -138,7 +138,7 @@ voiture2 = new Voiture("Nissan", "300ZX", 1992, ken); Plutôt que de passer une chaîne littérale ou une valeur entière lors de la création des nouveaux objets, les instructions ci-dessus utilisent les objets `rand` et `ken` comme paramètres pour les propriétaires. Pour connaître le nom du propriétaire de `voiture2`, on peut alors accéder à la propriété suivante : ```js -voiture2.propriétaire.nom +voiture2.propriétaire.nom; ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/null/index.md b/files/fr/web/javascript/reference/operators/null/index.md index 97ab4fc99455b6..4c8610f1b97b36 100644 --- a/files/fr/web/javascript/reference/operators/null/index.md +++ b/files/fr/web/javascript/reference/operators/null/index.md @@ -1,5 +1,5 @@ --- -title: 'null' +title: "null" slug: Web/JavaScript/Reference/Operators/null translation_of: Web/JavaScript/Reference/Global_Objects/null --- @@ -13,7 +13,7 @@ La valeur **`null`** est un littéral JavaScript représentant la nullité au se ## Syntaxe ```js -null +null; ``` ## Description @@ -23,7 +23,7 @@ La valeur `null` est un littéral (et non pas une propriété de l'objet global ```js // toto n'existe pas, n'a pas été défini et n'a jamais été initialisé toto; -"ReferenceError: toto is not defined" +("ReferenceError: toto is not defined"); // toto existe mais n'a ni type ni valeur var toto = null; @@ -33,15 +33,15 @@ console.log(toto); // null ### Différence entre `null` et `undefined` ```js -typeof null; // "object" (pas null pour des raisons historiques) -typeof undefined; // "undefined" -null === undefined; // false -null == undefined; // true -null === null; // true -null == null; // true -!null; // true -isNaN(1 + null); // false -isNaN(1 + undefined); // true +typeof null; // "object" (pas null pour des raisons historiques) +typeof undefined; // "undefined" +null === undefined; // false +null == undefined; // true +null === null; // true +null == null; // true +!null; // true +isNaN(1 + null); // false +isNaN(1 + undefined); // true ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/nullish_coalescing/index.md b/files/fr/web/javascript/reference/operators/nullish_coalescing/index.md index 3abfc30be128f5..3b6ff64e65bf4d 100644 --- a/files/fr/web/javascript/reference/operators/nullish_coalescing/index.md +++ b/files/fr/web/javascript/reference/operators/nullish_coalescing/index.md @@ -15,7 +15,7 @@ Contrairement à [l'opérateur logique OU (`||`)](/fr/docs/Web/JavaScript/Refere ## Syntaxe ```js -leftExpr ?? rightExpr +leftExpr ?? rightExpr; ``` ## Exemples @@ -46,7 +46,7 @@ Auparavant, lorsque l'on voulait attribuer une valeur par défaut à une variabl let toto; // toto ne se voit jamais attribuer de valeur, il vaut donc undefined -let unTexteBateau = toto || 'Coucou !'; +let unTexteBateau = toto || "Coucou !"; ``` Cependant, parce que `||` est un opérateur logique booléen, l'opérande de gauche a été converti en un booléen pour l'évaluation et aucune valeur _falsy_ (`0`, `''`, `NaN`, `null`, `undefined`) n'a été renvoyée. Ce comportement peut entraîner des conséquences inattendues si on souhaite considérer `0`, `''` ou `NaN` comme des valeurs valides. @@ -57,19 +57,19 @@ let texte = ""; let qté = compteur || 42; let message = texte || "Coucou !"; -console.log(qté); // 42 et non 0 +console.log(qté); // 42 et non 0 console.log(message); // "Coucou !" et non "" ``` L'opérateur de coalescence des nuls évite ce risque en ne renvoyant le deuxième opérande que lorsque le premier vaut `null` ou `undefined` (mais pas d'autres valeurs _falsy_) : ```js -let monTexte = ''; // Un chaine vide (qui est donc une valeur falsy) +let monTexte = ""; // Un chaine vide (qui est donc une valeur falsy) -let notFalsyText = monTexte || 'Hello world'; +let notFalsyText = monTexte || "Hello world"; console.log(notFalsyText); // Hello world -let preservingFalsy = monTexte ?? 'Salut le voisin'; +let preservingFalsy = monTexte ?? "Salut le voisin"; console.log(preservingFalsy); // '' (car monTexte n'est ni null ni undefined) ``` @@ -78,15 +78,24 @@ console.log(preservingFalsy); // '' (car monTexte n'est ni null ni undefined) À l'instar des opérateurs logiques OR (`||`) et AND (`&&`), l'expression de droite n'est pas évaluée si celle de gauche ne vaut ni `null` ni `undefined`. ```js -function A() { console.log('A a été appelée'); return undefined; } -function B() { console.log('B a été appelée'); return false; } -function C() { console.log('C a été appelée'); return "toto"; } - -console.log( A() ?? C() ); +function A() { + console.log("A a été appelée"); + return undefined; +} +function B() { + console.log("B a été appelée"); + return false; +} +function C() { + console.log("C a été appelée"); + return "toto"; +} + +console.log(A() ?? C()); // Inscrit "A a été appelée" puis "C a été appelée" et enfin "toto" // puisque : A() retourne undefined, les deux expressions sont donc évaluées -console.log( B() ?? C() ); +console.log(B() ?? C()); // Inscrit "B a été appelée" puis false // puisque : B() retourne false (et non null ou undefined) et // l'opérande de droite n'est pas évaluée @@ -114,7 +123,7 @@ Tout comme l'opérateur de coalescence des nuls, l'[opérateur de chaînage opti ```js let toto = { uneProprieteToto: "coucou" }; -console.log(toto.uneProprieteToto?.toUpperCase()); // "COUCOU" +console.log(toto.uneProprieteToto?.toUpperCase()); // "COUCOU" console.log(toto.uneProprieteTiti?.toUpperCase()); // undefined ``` diff --git a/files/fr/web/javascript/reference/operators/nullish_coalescing_assignment/index.md b/files/fr/web/javascript/reference/operators/nullish_coalescing_assignment/index.md index 1343366318b57f..ed99571aae9fd4 100644 --- a/files/fr/web/javascript/reference/operators/nullish_coalescing_assignment/index.md +++ b/files/fr/web/javascript/reference/operators/nullish_coalescing_assignment/index.md @@ -12,7 +12,7 @@ L'opérateur d'affectation après coalescence des nuls (`x ??= y`) effectue une ## Syntaxe ```js -expr1 ??= expr2 +expr1 ??= expr2; ``` ## Description diff --git a/files/fr/web/javascript/reference/operators/object_initializer/index.md b/files/fr/web/javascript/reference/operators/object_initializer/index.md index 7d2a2c296f628f..bd7919de56579b 100644 --- a/files/fr/web/javascript/reference/operators/object_initializer/index.md +++ b/files/fr/web/javascript/reference/operators/object_initializer/index.md @@ -16,13 +16,15 @@ Il est possible d'initialiser un objet en utilisant les notations [`new Object() var o = {}; var o = { a: "toto", b: 42, c: {} }; -var a = "toto", b = 42, c = {}; +var a = "toto", + b = 42, + c = {}; var o = { a: a, b: b, c: c }; var o = { property: function (paramètres) {}, get property() {}, - set property(valeur) {} + set property(valeur) {}, }; ``` @@ -32,12 +34,14 @@ ECMAScript 2015 (ES6) introduit de nouvelles notations. Pour plus d'informations ```js // Raccourcis pour les noms de propriétés (ES2015) -var a = "toto", b = 42, c = {}; +var a = "toto", + b = 42, + c = {}; var o = { a, b, c }; // Raccourcis pour les noms de méthodes(ES2015) var o = { - property(paramètres) {} + property(paramètres) {}, }; // Noms calculés pour les propriétés (ES2015) @@ -64,10 +68,10 @@ Cependant, en utilisant un littéral ou un initialisateur, on peut créer des ob ```js var object = { - toto: 'truc', + toto: "truc", âge: 42, machin: { maProp: 12 }, -} +}; ``` ### Accéder à des propriétés @@ -76,9 +80,9 @@ Après la création d'un objet, vous pourrez avoir besoin de consulter ou de mod ```js object.toto; // "truc" -object['âge']; // 42 +object["âge"]; // 42 -object.toto = 'machin'; +object.toto = "machin"; ``` ### Définir des propriétés @@ -86,29 +90,29 @@ object.toto = 'machin'; On a déjà vu comment on pouvait utiliser la syntaxe de l'initialisateur pour définir des propriétés. Il arrive souvent de vouloir utiliser des variables comme propriétés d'un objet. C'est pourquoi on peut trouver le code suivant : ```js -var a = 'toto', - b = 42, - c = {}; +var a = "toto", + b = 42, + c = {}; var o = { a: a, b: b, - c: c + c: c, }; ``` Avec ECMAScript 2015 (ES6), on peut utiliser une notation plus courte pour un résultat égal : ```js -var a = 'toto', - b = 42, - c = {}; +var a = "toto", + b = 42, + c = {}; // Raccourcis sur les noms de propriétés (ES2015) var o = { a, b, c }; // Autrement dit -console.log((o.a === { a }.a)); // true +console.log(o.a === { a }.a); // true ``` #### Les duplicatas et les noms de propriétés @@ -116,15 +120,15 @@ console.log((o.a === { a }.a)); // true Si le même nom est utilisé plusieurs fois pour différentes propriétés, ce sera la dernière propriété qui sera prise en compte : ```js -var a = {x: 1, x: 2}; +var a = { x: 1, x: 2 }; console.log(a); // { x: 2} ``` Le mode strict d'ECMAScript 5 renvoyait une exception {{jsxref("SyntaxError")}} lorsque plusieurs propriétés avaient le même nom. ECMAScript 2015 (ES6) permettant de créer des propriétés avec des noms qui sont calculés à l'exécution, cette restriction a été retirée. ```js -function vérifierSémantiqueES2015(){ - 'use strict'; +function vérifierSémantiqueES2015() { + "use strict"; try { ({ prop: 1, prop: 2 }); @@ -145,7 +149,7 @@ Une propriété d'un objet peut être une [function](/fr/docs/Web/JavaScript/Ref var o = { property: function (paramètres) {}, get property() {}, - set property(valeur) {} + set property(valeur) {}, }; ``` @@ -155,7 +159,7 @@ Avec ECMAScript 2015 (ES6), une notation raccourcie permet de ne plus utiliser l // Raccourci pour les noms de méthodes (ES2015) var o = { property(paramètres) {}, - *generator() {} + *generator() {}, }; ``` @@ -175,7 +179,7 @@ _(Il n'y a pas de function génératrice en ECMAScript5, mais l'exemple permet d ```js var o = { - generator: function* (){} + generator: function* () {}, }; ``` @@ -189,19 +193,19 @@ Avec ECMAScript 2015 (ES6), on peut utiliser un initialisateur et avoir des noms // Calcul des noms de propriétés (ES2015) var i = 0; var a = { - ['toto' + ++i]: i, - ['toto' + ++i]: i, - ['toto' + ++i]: i + ["toto" + ++i]: i, + ["toto" + ++i]: i, + ["toto" + ++i]: i, }; console.log(a.toto1); // 1 console.log(a.toto2); // 2 console.log(a.toto3); // 3 -var param = 'taille'; +var param = "taille"; var config = { [param]: 12, - ['mobile' + param.charAt(0).toUpperCase() + param.slice(1)]: 4 + ["mobile" + param.charAt(0).toUpperCase() + param.slice(1)]: 4, }; console.log(config); // { taille: 12, mobileTaille: 4 } @@ -214,8 +218,8 @@ La proposition de la décomposition des propriétés à ECMAScript (au niveau 4, Le clonage superficiel (sans rattacher le prototype) ou la fusion d'objets pourra désormais être écrite de façon plus concise qu'avec {{jsxref("Object.assign()")}}. ```js -var obj1 = { toto: 'truc', x: 42 }; -var obj2 = { toto: 'bidule', y: 13 }; +var obj1 = { toto: "truc", x: 42 }; +var obj2 = { toto: "bidule", y: 13 }; var clone = { ...obj1 }; // Object { toto: 'truc', x: 42 } @@ -238,7 +242,7 @@ var obj2 = { __proto__: null }; assert(Object.getPrototypeOf(obj2) === null); var protoObj = {}; -var obj3 = { '__proto__': protoObj }; +var obj3 = { __proto__: protoObj }; assert(Object.getPrototypeOf(obj3) === protoObj); var obj4 = { __proto__: "not an object or null" }; @@ -251,17 +255,21 @@ On ne peut modifier le prototype qu'une seule fois pour une même notation litt Les définitions de propriétés qui n'utilisent pas les deux points ne permettent pas de modifier le prototype, elles définieront une propriété de façon classique. ```js -var __proto__ = 'variable'; +var __proto__ = "variable"; var obj1 = { __proto__ }; assert(Object.getPrototypeOf(obj1) === Object.prototype); -assert(obj1.hasOwnProperty('__proto__')); -assert(obj1.__proto__ === 'variable'); +assert(obj1.hasOwnProperty("__proto__")); +assert(obj1.__proto__ === "variable"); -var obj2 = { __proto__() { return 'hello'; } }; -assert(obj2.__proto__() === 'hello'); +var obj2 = { + __proto__() { + return "hello"; + }, +}; +assert(obj2.__proto__() === "hello"); -var obj3 = { ['__prot' + 'o__']: 17 }; +var obj3 = { ["__prot" + "o__"]: 17 }; assert(obj3.__proto__ === 17); ``` diff --git a/files/fr/web/javascript/reference/operators/operator_precedence/index.md b/files/fr/web/javascript/reference/operators/operator_precedence/index.md index 50c89479395510..d104264120328b 100644 --- a/files/fr/web/javascript/reference/operators/operator_precedence/index.md +++ b/files/fr/web/javascript/reference/operators/operator_precedence/index.md @@ -31,10 +31,10 @@ avec le résultat attendu que `a` et `b` obtiennent la même valeur de 5. C'est ## Exemples ```js -3 > 2 && 2 > 1 +3 > 2 && 2 > 1; // renvoie true -3 > 2 > 1 +3 > 2 > 1; // renvoie false car 3 > 2 vaut true et que true > 1 vaut false // En ajoutant des parenthèses, on y voit plus clair (3 > 2) > 1 ``` diff --git a/files/fr/web/javascript/reference/operators/optional_chaining/index.md b/files/fr/web/javascript/reference/operators/optional_chaining/index.md index f41e3468ca44ee..073b14d51bbf5b 100644 --- a/files/fr/web/javascript/reference/operators/optional_chaining/index.md +++ b/files/fr/web/javascript/reference/operators/optional_chaining/index.md @@ -17,10 +17,10 @@ Le chainage optionnel ne peut pas être utilisé sur un objet initialement inexi ## Syntaxe ```js -obj?.prop -obj?.[expr] -arr?.[index] -func?.(args) +obj?.prop; +obj?.[expr]; +arr?.[index]; +func?.(args); ``` ## Description @@ -47,7 +47,7 @@ C'est équivalent à : ```js let temp = obj.premier; -let nestedProp = ((temp === null || temp === undefined) ? undefined : temp.second); +let nestedProp = temp === null || temp === undefined ? undefined : temp.second; ``` ### Chaînage optionnel avec des appels de fonctions @@ -71,9 +71,9 @@ Si vous utilisez des fonctions ou des méthodes de recherche depuis un objet ave function doSomething(onContent, onError) { try { // ... faire quelque chose avec les données - } - catch (err) { - if (onError) { // vérifier que onError existe réellement + } catch (err) { + if (onError) { + // vérifier que onError existe réellement onError(err.message); } } @@ -84,9 +84,8 @@ function doSomething(onContent, onError) { // Utiliser le chaînage optionnel avec les appels de fonctions function doSomething(onContent, onError) { try { - // ... faire quelque chose avec les données - } - catch (err) { + // ... faire quelque chose avec les données + } catch (err) { onError?.(err.message); // pas d'exception si onError n'est pas défini } } @@ -97,7 +96,7 @@ function doSomething(onContent, onError) { Vous pouvez aussi utiliser l'opérateur de chaînage optionnel lorsque vous accédez aux propriétés avec une expression en utilisant [la notation avec crochets des accesseurs de propriétés](/fr/docs/Web/JavaScript/Reference/Operators/Property_Accessors#Bracket_notation) : ```js -let nestedProp = obj?.['propName']; +let nestedProp = obj?.["propName"]; ``` ### Chaînage optionnel invalide depuis le côté gauche d'une affectation @@ -121,7 +120,7 @@ Cet exemple cherche la valeur de la propriété `name` dans un objet stocké com ```js let monMap = new Map(); -monMap.set("foo", {name: "baz", desc: "inga"}); +monMap.set("foo", { name: "baz", desc: "inga" }); let nameBar = monMap.get("bar")?.name; ``` @@ -147,9 +146,9 @@ let client = { nom: "Carl", details: { age: 82, - localisation: "Paradise Falls" + localisation: "Paradise Falls", // adresse détaillée inconnue - } + }, }; let villeDuClient = client.details?.adresse?.ville; @@ -164,7 +163,7 @@ L'{{JSxRef("Opérateurs/Nullish_coalescing_operator", "Opérateur de coalescence ```js let client = { nom: "Carl", - details: { age: 82 } + details: { age: 82 }, }; const villeDuClient = client?.ville ?? "Ville Inconnue"; console.log(villeDuClient); // Ville inconnue diff --git a/files/fr/web/javascript/reference/operators/property_accessors/index.md b/files/fr/web/javascript/reference/operators/property_accessors/index.md index a9071dee8b91fd..4c3207518ff7b2 100644 --- a/files/fr/web/javascript/reference/operators/property_accessors/index.md +++ b/files/fr/web/javascript/reference/operators/property_accessors/index.md @@ -13,8 +13,8 @@ Les **accesseurs de propriété** permettent de fournir un accès aux propriét ## Syntaxe ```js -objet.propriété -objet["propriété"] +objet.propriété; +objet["propriété"]; ``` ## Description @@ -33,7 +33,7 @@ objet.propriété = définir; `propriété` doit être un identifiant JavaScript valide, c'est-à-dire une séquence de caractères alphanumériques, soulignés (« `_` ») et signes dollar (« `$` »), qui ne peut commencer par un nombre. Par exemple, `objet.$1` est valide, mais `objet.1` ne l'est pas. ```js -document.createElement('pre'); +document.createElement("pre"); ``` Ici, la méthode `createElement` est obtenue depuis l'objet `document` et est appelée. @@ -41,14 +41,13 @@ Ici, la méthode `createElement` est obtenue depuis l'objet `document` et est ap Si on utilise une méthode pour un littéral numérique et que celui-ci ne possède pas de point décimal ni d'exposant lié à la notation scientifique, il faudra laisser un ou plusieurs blancs afin que l'appel soit bien interprété comme un appel de méthode plutôt que comme un séparateur décimal : ```js -77 .toExponential(); +(77).toExponential(); // ou -77 -.toExponential(); +(77).toExponential(); // ou, mieux pour la lisibilité (77).toExponential(); // ou encore -77.0.toExponential(); +(77.0).toExponential(); // 77. correspond à 77.0 et là il n'y a aucun doute ``` @@ -64,7 +63,7 @@ objet[nom_de_propriété] = définir; #### Exemple ```js -document['createElement']('pre'); +document["createElement"]("pre"); ``` Cette ligne fait exactement la même chose que l'exemple précédent. @@ -77,7 +76,7 @@ Les noms de propriétés doivent être des chaînes de caractères ou des symbol ```js var objet = {}; -objet['1'] = 'valeur'; +objet["1"] = "valeur"; console.log(objet[1]); ``` @@ -102,7 +101,7 @@ Pour plus d'informations, consultez la page sur [l'opérateur `this` et les liai Les nouveaux venus en JavaScript font souvent l'erreur d'utiliser {{jsxref("eval", "eval()")}} alors que la notation avec crochets pourrait être utilisée. Par exemple, la syntaxe suivante est utilisée dans de nombreux scripts. ```js -x = eval('document.formulaire.' + controle + '.value'); +x = eval("document.formulaire." + controle + ".value"); ``` `eval` est lente et insécurisée et devrait être évitée dès que possible. Il est préférable d'utiliser la notation avec crochets : diff --git a/files/fr/web/javascript/reference/operators/remainder/index.md b/files/fr/web/javascript/reference/operators/remainder/index.md index 90ef274ca392f0..a7b208a7047364 100644 --- a/files/fr/web/javascript/reference/operators/remainder/index.md +++ b/files/fr/web/javascript/reference/operators/remainder/index.md @@ -14,7 +14,7 @@ Bien que dans la plupart des langages, `%` est un opérateur de reste, pour d'au ## Syntaxe ```js -Opérateur : var1 % var2 +Opérateur: var1 % var2; ``` ## Exemples @@ -22,33 +22,33 @@ Opérateur : var1 % var2 ### Reste avec numérateur positif ```js -12 % 5 // 2 - 1 % -2 // 1 - 1 % 2 // 1 - 2 % 3 // 2 -5.5 % 2 // 1.5 +12 % 5; // 2 +1 % -2; // 1 +1 % 2; // 1 +2 % 3; // 2 +5.5 % 2; // 1.5 ``` ### Reste avec numérateur négatif ```js --12 % 5 // -2 --1 % 2 // -1 --4 % 2 // -0 +-12 % 5; // -2 +-1 % 2; // -1 +-4 % 2; // -0 ``` ### Reste avec NaN ```js -NaN % 2 // NaN +NaN % 2; // NaN ``` ### Reste avec l'infini ```js -Infinity % 2 // NaN -Infinity % 0 // NaN -Infinity % Infinity // NaN +Infinity % 2; // NaN +Infinity % 0; // NaN +Infinity % Infinity; // NaN ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/remainder_assignment/index.md b/files/fr/web/javascript/reference/operators/remainder_assignment/index.md index dc2331bd3b27df..add170ccf65799 100644 --- a/files/fr/web/javascript/reference/operators/remainder_assignment/index.md +++ b/files/fr/web/javascript/reference/operators/remainder_assignment/index.md @@ -12,8 +12,8 @@ L'opérateur de reste et d'affectation (`%=`) calcule le reste de la division de ## Syntaxe ```js -Opérateur : x %= y -Signification : x = x % y +Opérateur: x %= y; +Signification: x = x % y; ``` ## Exemples @@ -22,9 +22,9 @@ Signification : x = x % y ```js let truc = 5; -truc %= 2; // 1 -truc %= 'toto'; // NaN -truc %= 0; // NaN +truc %= 2; // 1 +truc %= "toto"; // NaN +truc %= 0; // NaN ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/right_shift/index.md b/files/fr/web/javascript/reference/operators/right_shift/index.md index d17d2e3570e106..3061752bc64c00 100644 --- a/files/fr/web/javascript/reference/operators/right_shift/index.md +++ b/files/fr/web/javascript/reference/operators/right_shift/index.md @@ -12,7 +12,7 @@ L'opérateur de **décalage binaire à droite (`>>`)** décale la séquence de b ## Syntaxe ```js -a >> b +a >> b; ``` ## Description @@ -40,7 +40,7 @@ De même, `-9 >> 2` donnera `-3`, car le signe est préservé : ### Utiliser le décalage à droite ```js - 9 >> 2; // 2 +9 >> 2; // 2 -9 >> 2; // -3 ``` diff --git a/files/fr/web/javascript/reference/operators/right_shift_assignment/index.md b/files/fr/web/javascript/reference/operators/right_shift_assignment/index.md index f4ad5f88d5c61e..06917a14ded419 100644 --- a/files/fr/web/javascript/reference/operators/right_shift_assignment/index.md +++ b/files/fr/web/javascript/reference/operators/right_shift_assignment/index.md @@ -12,8 +12,8 @@ L'opérateur de décalage à droite et d'affectation (`>>=`) décale la séquenc ## Syntaxe ```js -Opérateur : x >>= y -Signification : x = x >> y +Opérateur: x >>= y; +Signification: x = x >> y; ``` ## Exemples @@ -22,10 +22,10 @@ Signification : x = x >> y ```js let a = 5; // (00000000000000000000000000000101) -a >>= 2; // 1 (00000000000000000000000000000001) +a >>= 2; // 1 (00000000000000000000000000000001) let b = -5; // (-00000000000000000000000000000101) -b >>= 2; // -2 (-00000000000000000000000000000010) +b >>= 2; // -2 (-00000000000000000000000000000010) ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/spread_syntax/index.md b/files/fr/web/javascript/reference/operators/spread_syntax/index.md index 7cc558a7640a69..ada1518cbdd3ce 100644 --- a/files/fr/web/javascript/reference/operators/spread_syntax/index.md +++ b/files/fr/web/javascript/reference/operators/spread_syntax/index.md @@ -21,7 +21,7 @@ f(...objetIterable); Pour les littéraux de tableaux : ```js -[...objetIterable, 4, 5, 6] +[...objetIterable, 4, 5, 6]; ``` Pour les littéraux objets (nouvelle fonctionnalité pour ECMAScript, actuellement en proposition de niveau 4, finalisée) : @@ -39,7 +39,7 @@ let objClone = { ...obj }; Il arrive souvent qu'on veuille utiliser {{jsxref( "Function.prototype.apply")}} avec un tableau parmi les arguments de la fonction utilisée : ```js -function f(x, y, z) { } +function f(x, y, z) {} var args = [0, 1, 2]; f.apply(null, args); ``` @@ -47,7 +47,7 @@ f.apply(null, args); avec la décomposition, on peut désormais écrire : ```js -function f(x, y, z) { } +function f(x, y, z) {} var args = [0, 1, 2]; f(...args); ``` @@ -55,7 +55,7 @@ f(...args); Tout argument passé à une fonction peut être décomposé grâce à cette syntaxe et cette syntaxe peut être utilisée pour plusieurs arguments. ```js -function f(v, w, x, y, z) { } +function f(v, w, x, y, z) {} var args = [0, 1]; f(-1, ...args, 2, ...[3]); ``` @@ -73,27 +73,26 @@ Afin d'utiliser `new` avec un tableau de paramètres, sans utiliser la décompos ```js function applyAndNew(constructor, args) { - function partial () { - return constructor.apply(this, args); - }; - if (typeof constructor.prototype === "object") { - partial.prototype = Object.create(constructor.prototype); - } - return partial; + function partial() { + return constructor.apply(this, args); + } + if (typeof constructor.prototype === "object") { + partial.prototype = Object.create(constructor.prototype); + } + return partial; } - -function monConstructeur () { - console.log("arguments.length: " + arguments.length); - console.log(arguments); - this.prop1="val1"; - this.prop2="val2"; -}; +function monConstructeur() { + console.log("arguments.length: " + arguments.length); + console.log(arguments); + this.prop1 = "val1"; + this.prop2 = "val2"; +} var mesArguments = ["bi", "bop", "bup", null]; var monConstructeurAvecArguments = applyAndNew(monConstructor, mesArguments); -console.log(new monConstructeurAvecArguments); +console.log(new monConstructeurAvecArguments()); // (log fourni par monConstructeur): arguments.length: 4 // (log fourni par monConstructeur): ["bi", "bop", "bup", null] // (log fourni par "new monConstructeurAvecArguments"): {prop1: "val1", prop2: "val2"} @@ -106,8 +105,8 @@ console.log(new monConstructeurAvecArguments); À l'heure actuelle, sans la décomposition, si on a un tableau et qu'on souhaite créer un nouveau tableau composé du premier, on ne peut pas utiliser un littéral de tableau et il faut utiliser des fonctions comme {{jsxref("Array.prototype.push", "push()")}}, {{jsxref("Array.prototype.splice", "splice()")}}, {{jsxref("Array.prototype.concat", "concat()")}}, etc. Avec la syntaxe de décomposition, cela devient plus succinct : ```js -var articulations = ['épaules', 'genoux']; -var corps = ['têtes', ...articulations, 'bras', 'pieds']; +var articulations = ["épaules", "genoux"]; +var corps = ["têtes", ...articulations, "bras", "pieds"]; // ["têtes", "épaules", "genoux", "bras", "pieds"] ``` @@ -121,7 +120,7 @@ var arr2 = [...arr]; arr2.push(4); console.log(arr2); // [1, 2, 3, 4] -console.log(arr); // [1, 2, 3] (inchangé) +console.log(arr); // [1, 2, 3] (inchangé) ``` > **Note :** Lorsqu'on utilise la décomposition pour copier un tableau, celle-ci ne s'applique qu'au premier niveau de profondeur. Par conséquent, il peut ne pas convenir pour la copie des tableaux multidimensionnels (des tableaux imbriqués dans d'autres tableaux) comme le montre l'exemple suivant (il en va de même avec {{jsxref("Object.assign()")}} et la décomposition). @@ -159,7 +158,7 @@ var arr1 = [0, 1, 2]; var arr2 = [3, 4, 5]; // On ajoute tous les éléments // de arr2 au début de arr1 -Array.prototype.unshift.apply(arr1, arr2) // arr1 vaut [3, 4, 5, 0, 1, 2] +Array.prototype.unshift.apply(arr1, arr2); // arr1 vaut [3, 4, 5, 0, 1, 2] ``` Avec ES2015 et la décomposition, on peut écrire : @@ -180,8 +179,8 @@ arr1 = [...arr2, ...arr1]; Le clonage superficiel (qui ne rattache pas le prototype) ou la fusion d'objets peut donc être obtenue avec une syntaxe plus concise que celle utilisant {{jsxref("Object.assign()")}}. ```js -var profil = { prenom: 'Sarah', profilComplet: false }; -var profilMisAJour = { nom: 'Dupont', profilComplet: true }; +var profil = { prenom: "Sarah", profilComplet: false }; +var profilMisAJour = { nom: "Dupont", profilComplet: true }; var clone = { ...profil }; // Object { prenom: 'Sarah', profilComplet: false } @@ -213,13 +212,13 @@ Dans l'exemple précédent, la syntaxe de décomposition ne fonctionne pas comme Pour rappel : la syntaxe de décomposition ne s'applique qu'[aux objets itérables](/fr/docs/Web/JavaScript/Guide/iterable) : ```js -var obj = {"clé1" : "valeur1"}; +var obj = { clé1: "valeur1" }; function maFonction(x) { console.log(x); // undefined } maFonction(...obj); var args = [...obj]; -console.log(args, args.length) //[] 0 +console.log(args, args.length); //[] 0 ``` ### Utiliser la décomposition avec de nombreuses valeurs diff --git a/files/fr/web/javascript/reference/operators/strict_equality/index.md b/files/fr/web/javascript/reference/operators/strict_equality/index.md index de7437e7471ac0..62ff7554d9991a 100644 --- a/files/fr/web/javascript/reference/operators/strict_equality/index.md +++ b/files/fr/web/javascript/reference/operators/strict_equality/index.md @@ -12,7 +12,7 @@ L'opérateur d'égalité stricte (`===`) vérifie si ses deux opérandes sont é ## Syntaxe ```js -x === y +x === y; ``` ## Description @@ -36,41 +36,41 @@ La différence fondamentale avec [l'opérateur d'égalité](/fr/docs/Web/JavaScr ### Comparaison d'opérandes de même type ```js -console.log("hello" === "hello"); // true -console.log("hello" === "hola"); // false +console.log("hello" === "hello"); // true +console.log("hello" === "hola"); // false -console.log(3 === 3); // true -console.log(3 === 4); // false +console.log(3 === 3); // true +console.log(3 === 4); // false -console.log(true === true); // true -console.log(true === false); // false +console.log(true === true); // true +console.log(true === false); // false -console.log(null === null); // true +console.log(null === null); // true ``` ### Comparaison d'opérandes de types différents ```js -console.log("3" === 3); // false +console.log("3" === 3); // false -console.log(true === 1); // false +console.log(true === 1); // false -console.log(null === undefined); // false +console.log(null === undefined); // false ``` ### Comparaison d'objets ```js const objet1 = { - name: "coucou" -} + name: "coucou", +}; const objet2 = { - name: "coucou" -} + name: "coucou", +}; -console.log(objet1 === objet2); // false -console.log(objet1 === objet1); // true +console.log(objet1 === objet2); // false +console.log(objet1 === objet1); // true ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/strict_inequality/index.md b/files/fr/web/javascript/reference/operators/strict_inequality/index.md index bc959b26ad2820..fd6aee378ec4e1 100644 --- a/files/fr/web/javascript/reference/operators/strict_inequality/index.md +++ b/files/fr/web/javascript/reference/operators/strict_inequality/index.md @@ -12,7 +12,7 @@ L'opérateur d'inégalité stricte (`!==`) vérifie si ses deux opérandes ne so ## Syntaxe ```js -x !== y +x !== y; ``` ## Description @@ -20,8 +20,8 @@ x !== y L'opérateur d'inégalité stricte vérifie que ses deux opérandes ne sont pas égaux. Il s'agit de la négation de [l'opérateur d'égalité stricte](/fr/docs/Web/JavaScript/Reference/Operators/Strict_equality). Les deux expressions suivantes fourniront toujours le même résultat : ```js -x !== y -!(x === y) +x !== y; +!(x === y); ``` Pour plus de détails sur l'algorithme de comparaison utilisé, voir [la page sur l'opérateur d'égalité stricte](/fr/docs/Web/JavaScript/Reference/Operators/Strict_equality). @@ -37,41 +37,41 @@ Pour plus de détails sur l'algorithme de comparaison utilisé, voir [la page su ### Comparaison d'opérandes de même type ```js -console.log("hello" !== "hello"); // false -console.log("hello" !== "hola"); // true +console.log("hello" !== "hello"); // false +console.log("hello" !== "hola"); // true -console.log(3 !== 3); // false -console.log(3 !== 4); // true +console.log(3 !== 3); // false +console.log(3 !== 4); // true -console.log(true !== true); // false -console.log(true !== false); // true +console.log(true !== true); // false +console.log(true !== false); // true -console.log(null !== null); // false +console.log(null !== null); // false ``` ### Comparaison d'opérandes de types différents ```js -console.log("3" !== 3); // true +console.log("3" !== 3); // true -console.log(true !== 1); // true +console.log(true !== 1); // true -console.log(null !== undefined); // true +console.log(null !== undefined); // true ``` ### Comparaison d'objets ```js const objet1 = { - name: "coucou" -} + name: "coucou", +}; const objet2 = { - name: "coucou" -} + name: "coucou", +}; -console.log(objet1 !== objet2); // true -console.log(objet1 !== objet1); // false +console.log(objet1 !== objet2); // true +console.log(objet1 !== objet1); // false ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/subtraction/index.md b/files/fr/web/javascript/reference/operators/subtraction/index.md index aa1b43283a3a0b..deea0bae4b3920 100644 --- a/files/fr/web/javascript/reference/operators/subtraction/index.md +++ b/files/fr/web/javascript/reference/operators/subtraction/index.md @@ -12,7 +12,7 @@ L'opérateur de soustraction (`-`) effectue la soustraction entre les deux opér ## Syntaxe ```js -Opérateur : x - y +Opérateur: x - y; ``` ## Exemples @@ -20,14 +20,14 @@ Opérateur : x - y ### Avec des valeurs numériques ```js -5 - 3 // 2 -3 - 5 // -2 +5 - 3; // 2 +3 - 5; // -2 ``` ### Avec des valeurs non-numériques ```js -'toto' - 3 // NaN +"toto" - 3; // NaN ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/subtraction_assignment/index.md b/files/fr/web/javascript/reference/operators/subtraction_assignment/index.md index cc5e13fc55a167..849ae2fa54a92f 100644 --- a/files/fr/web/javascript/reference/operators/subtraction_assignment/index.md +++ b/files/fr/web/javascript/reference/operators/subtraction_assignment/index.md @@ -12,8 +12,8 @@ L'opérateur d'affectation après soustraction (`-=`) calcule la soustraction de ## Syntaxe ```js -Opérateur : x -= y -Signification : x = x - y +Opérateur: x -= y; +Signification: x = x - y; ``` ## Exemples @@ -22,8 +22,8 @@ Signification : x = x - y ```js let truc = 5; -truc -= 2; // 3 -truc -= 'toto'; // NaN +truc -= 2; // 3 +truc -= "toto"; // NaN ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/super/index.md b/files/fr/web/javascript/reference/operators/super/index.md index b8db27c7eeceb3..43e146917beb62 100644 --- a/files/fr/web/javascript/reference/operators/super/index.md +++ b/files/fr/web/javascript/reference/operators/super/index.md @@ -30,12 +30,12 @@ Ce fragment de code est tiré de [cet exemple](https://github.com/GoogleChrome/s ```js class Rectangle { constructor(hauteur, largeur) { - this.name = 'Rectangle'; + this.name = "Rectangle"; this.hauteur = hauteur; this.largeur = largeur; } - coucou(){ - console.log('Coucou, je suis un ' + this.name + '.'); + coucou() { + console.log("Coucou, je suis un " + this.name + "."); } get aire() { return this.hauteur * this.largeur; @@ -48,7 +48,6 @@ class Rectangle { class Carre extends Rectangle { constructor(longueur) { - // Ici, on appelle le constructeur de Rectangle // qui est l'objet « parent » de Carré super(longueur, longueur); @@ -56,7 +55,7 @@ class Carre extends Rectangle { // Pour les classes dérivées, super() doit être appelé // avant d'utiliser 'this' sinon cela entraînera une // exception ReferenceError. - this.name = 'Carré'; + this.name = "Carré"; } } ``` @@ -74,9 +73,9 @@ class Rectangle { } class Carre extends Rectangle { - constructor(){} + constructor() {} static logDescription() { - return super.logNbCotes() + ' qui sont tous égaux'; + return super.logNbCotes() + " qui sont tous égaux"; } } Carre.logDescription(); // "J'ai 4 côtés qui sont tous égaux" @@ -111,7 +110,7 @@ class X { Object.defineProperty(this, "prop", { configurable: true, writable: false, - value: 1 + value: 1, }); } } @@ -119,7 +118,7 @@ class Y extends X { constructor() { super(); } - toto(){ + toto() { super.prop = 2; // Impossible de surcharger } } @@ -136,14 +135,14 @@ console.log(y.prop); // 1 const obj1 = { methode1() { console.log("méthode 1"); - } -} + }, +}; const obj2 = { methode2() { super.methode1(); - } -} + }, +}; Object.setPrototypeOf(obj2, obj1); obj2.methode2(); // affiche "méthode 1" dans la console diff --git a/files/fr/web/javascript/reference/operators/this/index.md b/files/fr/web/javascript/reference/operators/this/index.md index efe1d8cb86da10..040b9c67ca711e 100644 --- a/files/fr/web/javascript/reference/operators/this/index.md +++ b/files/fr/web/javascript/reference/operators/this/index.md @@ -15,7 +15,7 @@ Dans la plupart des cas, la valeur de `this` sera déterminée à partir de la f ## Syntaxe ```js -this +this; ``` ### Valeur @@ -36,7 +36,7 @@ console.log(window.a); // 37 this.b = "MDN"; console.log(window.b); // "MDN" -console.log(b); // "MDN" +console.log(b); // "MDN" ``` > **Note :** Il est également possible d'accéder au contexte global avec la propriété {{jsxref("globalThis")}} quel que soit le contexte utilisé pour l'exécution. @@ -48,7 +48,7 @@ S'il est utilisé dans une fonction, la valeur de `this` dépendra de la façon ### Avec un appel simple ```js -function f1(){ +function f1() { return this; } @@ -62,7 +62,7 @@ f1() === global; // true Dans cet exemple, la valeur de `this` n'est pas définie lors de l'appel. Le code n'étant pas en mode strict, `this` doit toujours être un objet et ce sera donc l'objet global (soit {{domxref("Window", "window")}} pour un navigateur). ```js -function f2(){ +function f2() { "use strict"; // on utilise le mode strict return this; } @@ -92,19 +92,19 @@ function whatsThis(arg) { return this.a; } -whatsThis(); // 'Global' car celui-ci dans la fonction n'est pas défini, il est donc défini par défaut sur l'objet global window -whatsThis.call(obj); // "Toto" +whatsThis(); // 'Global' car celui-ci dans la fonction n'est pas défini, il est donc défini par défaut sur l'objet global window +whatsThis.call(obj); // "Toto" whatsThis.apply(obj); // "Toto" ``` Lorsque le mot-clé `this` est utilisé dans le corps d'une fonction, il est possible d'utiliser les méthodes {{jsxref("Function.prototype.call()", "call()")}} ou {{jsxref("Function.prototype.apply()", "apply()")}} pour lier `this` à un objet donné. Toutes les fonctions héritent de ces méthodes grâce à {{jsxref("Function.prototype")}}. ```js -function ajout(c, d){ +function ajout(c, d) { return this.a + this.b + c + d; } -var o = {a:1, b:3}; +var o = { a: 1, b: 3 }; // Le premier paramètre correspond à l'objet qu'on souhaite // lier à 'this', les paramètres suivants sont les arguments @@ -124,8 +124,8 @@ function truc() { console.log(Object.prototype.toString.call(this)); } -truc.call(7); // [object Number] -truc.call('foo'); // [object String] +truc.call(7); // [object Number] +truc.call("foo"); // [object String] ``` ### La méthode `bind` @@ -133,17 +133,17 @@ truc.call('foo'); // [object String] Avec ECMAScript 5, une nouvelle fonction fut introduite : {{jsxref("Function.prototype.bind()")}}. Lorsqu'on appelle `f.bind(unObjet)`, on crée une nouvelle fonction qui possède le même corps et la même portée que `f`, mais où `this` sera lié, de façon permanente, au premier argument passé à `bind`, quelle que soit la façon dont la méthode est utilisée. ```js -function f(){ +function f() { return this.a; } -var g = f.bind({a:"azerty"}); +var g = f.bind({ a: "azerty" }); console.log(g()); // azerty -var h = g.bind({a:"coucou"}); // bind ne fonctionne qu'une seule fois +var h = g.bind({ a: "coucou" }); // bind ne fonctionne qu'une seule fois console.log(h()); // azerty -var o = {a:37, f:f, g:g, h:h}; +var o = { a: 37, f: f, g: g, h: h }; console.log(o.a, o.f(), o.g(), o.h()); // 37, 37, azerty, azerty ``` @@ -153,7 +153,7 @@ En utilisant [les fonctions fléchées](/fr/docs/Web/JavaScript/Reference/Foncti ```js var objetGlobal = this; -var toto = (() => this); +var toto = () => this; console.log(toto() === objetGlobal); // true ``` @@ -161,7 +161,7 @@ Peu importe la façon dont `toto` sera appelée, `this` sera toujours l'objet gl ```js // Appelé comme la méthode d'un objet -var obj = {toto: toto}; +var obj = { toto: toto }; console.log(obj.toto() === objetGlobal); // true // Ici on utilise call @@ -181,11 +181,12 @@ Quelle que soit la méthode utilisée le `this` de `toto` sera défini avec la v // la forme d'une fonction fléchée. this est // donc fixé de façon permanente avec la valeur // de this du contexte englobant. -var obj = { truc : function() { - var x = (() => this); - return x; - } - }; +var obj = { + truc: function () { + var x = () => this; + return x; + }, +}; // On appelle truc comme une méthode d'obj, this // vaudra donc obj. On récupère la fonction // renvoyée par truc et on en stocke une référence @@ -217,9 +218,9 @@ Ainsi, dans l'exemple suivant, lorsqu'on appelle `o.f()`, le `this` contenu à l ```js var o = { prop: 37, - f: function() { + f: function () { return this.prop; - } + }, }; console.log(o.f()); // 37 @@ -228,7 +229,7 @@ console.log(o.f()); // 37 On notera que ce comportement n'est pas du tout affecté par la façon ou l'endroit de la définition de la fonction. Dans l'exemple précédent, on aurait très bien pu définir la fonction plus tard et la rattacher à une propriété de `o` plutôt que de la déclarer de cette façon. On aura le même résultat en faisant ainsi : ```js -var o = {prop: 37}; +var o = { prop: 37 }; function indépendante() { return this.prop; @@ -244,7 +245,7 @@ On voit ici que ce qui importe est la façon dont la fonction est appelée et no De la même façon, `this` n'est affecté que par la référence la plus proche. Autrement dit, dans l'exemple suivant quand on appelle la fonction `o.b.g`, on appelle la méthode `g` de l'objet `o.b`. Ainsi, au moment de l'exécution, `this` fera référence à `o.b`. Le fait que cet objet soit une propriété de `o` n'a aucun impact : seule la référence objet la plus proche compte. ```js -o.b = {g: indépendante, prop: 42}; +o.b = { g: indépendante, prop: 42 }; console.log(o.b.g()); // 42 ``` @@ -253,7 +254,11 @@ console.log(o.b.g()); // 42 Ce qui a été vu ci-avant est également applicable pour les méthodes qui sont présentes sur la chaîne de prototypes de l'objet. Si une méthode se situe sur la chaîne de prototype, `this` fera référence à l'objet appelant (de la même façon que si la méthode était une propriété directe de l'objet). ```js -var o = {f:function(){ return this.a + this.b; }}; +var o = { + f: function () { + return this.a + this.b; + }, +}; var p = Object.create(o); p.a = 1; p.b = 4; @@ -268,20 +273,23 @@ Dans cet exemple, l'objet qui est affecté à la variable `p` ne possède pas di Ici aussi, on a le même principe lorsque la fonction est appelée à partir d'un accesseur (_getter_) ou d'un mutateur (_setter_). Une fonction utilisée comme accesseur ou mutateur verra son `this` lié à l'objet à partir duquel on souhaite accéder/changer la propriété. ```js -function moduleRéel(){ +function moduleRéel() { return Math.sqrt(this.re * this.re + this.im * this.im); } var o = { re: 1, im: -1, - get phase(){ + get phase() { return Math.atan2(this.im, this.re); - } + }, }; -Object.defineProperty(o, 'moduleRéel', { - get: moduleRéel, enumerable:true, configurable:true}); +Object.defineProperty(o, "moduleRéel", { + get: moduleRéel, + enumerable: true, + configurable: true, +}); console.log(o.phase, o.moduleRéel); // logs -0.78 1.4142 ``` @@ -314,17 +322,16 @@ Lorsqu'une fonction est utilisée comme constructeur (c'est-à-dire qu'elle est * } */ -function C(){ +function C() { this.a = 37; } var o = new C(); console.log(o.a); // 37 - -function C2(){ +function C2() { this.a = 37; - return {a:38}; + return { a: 38 }; } o = new C2(); @@ -341,7 +348,7 @@ Lorsqu'une fonction est utilisée comme gestionnaire d'événement (_event handl // Lorsque cette fonction est appelée // comme listener, l'élément associé // sera coloré en bleu -function bluify(e){ +function bluify(e) { // Cette proposition est toujours vraie console.log(this === e.currentTarget); @@ -349,17 +356,17 @@ function bluify(e){ // au même objet console.log(this === e.target); - this.style.backgroundColor = '#A5D9F3'; + this.style.backgroundColor = "#A5D9F3"; } // On obtient une liste de tous les éléments // contenus dans le document -var elements = document.getElementsByTagName('*'); +var elements = document.getElementsByTagName("*"); // On ajout le listener bluify pour réagier au clic // Quand on clique sur un élément, il deviendra bleu -for(var i=0 ; i>>`)** décale la s ## Syntaxe ```js -a >>> b +a >>> b; ``` ## Description @@ -40,7 +40,7 @@ Toutefois, ce n'est pas le cas pour les nombres négatifs : `-9 >>> 2` renverra ### Utiliser le décalage à droite non-signé ```js - 9 >>> 2; // 2 +9 >>> 2; // 2 -9 >>> 2; // 1073741821 ``` diff --git a/files/fr/web/javascript/reference/operators/unsigned_right_shift_assignment/index.md b/files/fr/web/javascript/reference/operators/unsigned_right_shift_assignment/index.md index b1b76072d301ca..9b8a04ad14e3f7 100644 --- a/files/fr/web/javascript/reference/operators/unsigned_right_shift_assignment/index.md +++ b/files/fr/web/javascript/reference/operators/unsigned_right_shift_assignment/index.md @@ -12,8 +12,8 @@ L'**opérateur de décalage à droite non signé et d'affectation** (`>>>=`) dé ## Syntaxe ```js -Opérateur : x >>>= y -Signification : x = x >>> y +Opérateur: x >>>= y; +Signification: x = x >>> y; ``` ## Exemples @@ -22,10 +22,10 @@ Signification : x = x >>> y ```js let a = 5; // (00000000000000000000000000000101) -a >>>= 2; // 1 (00000000000000000000000000000001) +a >>>= 2; // 1 (00000000000000000000000000000001) let b = -5; // (-00000000000000000000000000000101) -b >>>= 2; // 1073741822 (00111111111111111111111111111110) +b >>>= 2; // 1073741822 (00111111111111111111111111111110) ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/operators/void/index.md b/files/fr/web/javascript/reference/operators/void/index.md index 31a450a6ed45ca..b77c9d74e49513 100644 --- a/files/fr/web/javascript/reference/operators/void/index.md +++ b/files/fr/web/javascript/reference/operators/void/index.md @@ -13,7 +13,7 @@ L'**opérateur `void`** permet d'évaluer une _expression_ donnée et de renvoye ## Syntaxe ```js -void expression +void expression; ``` ## Description @@ -25,8 +25,8 @@ L'opérateur `void` est souvent utilisé pour obtenir la valeur `undefined`, gé Attention à [la précédence des opérateurs](/fr/docs/Web/JavaScript/Reference/Opérateurs/Précédence_des_opérateurs) et notamment de celle de `void`, si besoin, on pourra utiliser des parenthèses pour clarifier la résolution de l'expression : ```js -void 2 == '2'; // renvoie false -void (2 === '2'); // renvoie undefined +void 2 == "2"; // renvoie false +void (2 === "2"); // renvoie undefined ``` ## Expressions de fonction appelées immédiatement @@ -34,18 +34,18 @@ void (2 === '2'); // renvoie undefined Lorsqu'on utilise tout un script dans une fonction qu'on évalue immédiatement, `void` peut être utilisé pour que le mot-clé `function` soit traité comme une expression plutôt que comme une déclaration. ```js -void function iife() { - var toto = function () {}; - var machin = function () {}; - var truc = function () { - toto(); - machin(); - }; - var bidule = function () {}; - - truc(); - bidule(); -}(); +void (function iife() { + var toto = function () {}; + var machin = function () {}; + var truc = function () { + toto(); + machin(); + }; + var bidule = function () {}; + + truc(); + bidule(); +})(); ``` ## Les URI JavaScript @@ -53,9 +53,7 @@ void function iife() { Lorsqu'un navigateur utilise une URI avec `javascript:`, le code de l'URI est évalué et le résultat remplace le contenu de la page, sauf si la valeur renvoyée vaut {{jsxref("Objets_globaux/undefined","undefined")}}. L'utilisateur `void` peut alors être utilisé pour renvoyer cette valeur. Par exemple : ```html - - Cliquer ici (sans effet) - + Cliquer ici (sans effet) Cliquer ici pour rendre le fond vert diff --git a/files/fr/web/javascript/reference/operators/yield/index.md b/files/fr/web/javascript/reference/operators/yield/index.md index d598aa792bce82..d948e7b2e90b91 100644 --- a/files/fr/web/javascript/reference/operators/yield/index.md +++ b/files/fr/web/javascript/reference/operators/yield/index.md @@ -13,7 +13,7 @@ Le mot-clé `yield` est utilisé pour suspendre et reprendre une fonction géné ## Syntaxe ```js -[rv] = yield [expression] +[rv] = yield[expression]; ``` - `expression` @@ -45,7 +45,7 @@ Entre le chemin de code du générateur, ses opérateurs `yield`, et la possibil Le code suivant est la déclaration d'un exemple de fonction génératrice : ```js -function* compteVentesPommes () { +function* compteVentesPommes() { var listeVentes = [3, 7, 5]; for (var i = 0; i < listeVentes.length; i++) { yield listeVentes[i]; diff --git a/files/fr/web/javascript/reference/operators/yield_star_/index.md b/files/fr/web/javascript/reference/operators/yield_star_/index.md index ad0bcce49f57b8..53f3e3790e0162 100644 --- a/files/fr/web/javascript/reference/operators/yield_star_/index.md +++ b/files/fr/web/javascript/reference/operators/yield_star_/index.md @@ -13,7 +13,7 @@ Une **expression `yield*`** est utilisée afin de déléguer le mécanisme d'it ## Syntaxe ```js -yield* expression +yield * expression; ``` - `expression` @@ -96,10 +96,9 @@ var iterator = g5(); console.log(iterator.next()); // { value: 1, done: false } console.log(iterator.next()); // { value: 2, done: false } console.log(iterator.next()); // { value: 3, done: false } -console.log(iterator.next()); // { value: undefined, done: true }, - // g4() renvoie{ value: "toto", done: true } at this point +console.log(iterator.next()); // { value: undefined, done: true }, g4() renvoie{ value: "toto", done: true } at this point -console.log(résultat); // "toto" +console.log(résultat); // "toto" ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/regular_expressions/unicode_character_class_escape/index.md b/files/fr/web/javascript/reference/regular_expressions/unicode_character_class_escape/index.md index 72537455154e7c..e06eb93c648de9 100644 --- a/files/fr/web/javascript/reference/regular_expressions/unicode_character_class_escape/index.md +++ b/files/fr/web/javascript/reference/regular_expressions/unicode_character_class_escape/index.md @@ -26,44 +26,44 @@ Les séquences d'échappement pour les propriétés Unicode permettent de distin ### Non-binaires -| Échappements | Signification | -| ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | -| `\p{LC} \p{Cased_Letter} \p{UnicodePropertyName=Cased_Letter}` | N'importe quelle lettre avec la version minuscule et la version majuscule. Équivalent à `\p{Lu}\|\p{Ll}\|p{Lt}`. | -| `\p{Close_Punctuation} \p{UnicodePropertyName=Close_Punctuation}` | | -| `\p{Connector_Punctuation} \p{UnicodePropertyName=Connector_Punctuation}` | | -| `\p{Control} \p{UnicodePropertyName=Control}` | | -| `\p{Currency_Symbol} \p{UnicodePropertyName=Currency_Symbol}` | | -| `\p{Dash_Punctuation} \p{UnicodePropertyName=Dash_Punctuation}` | | -| `\p{Decimal_Number} \p{UnicodePropertyName=Decimal_Number}` | | -| `\p{Enclosing_Mark} \p{UnicodePropertyName=Enclosing_Mark}` | | -| `\p{Final_Punctuation} \p{UnicodePropertyName=Final_Punctuation}` | | -| `\p{Format} \p{UnicodePropertyName=Format}` | | -| `\p{Initial_Punctuation} \p{UnicodePropertyName=Initial_Punctuation}` | | -| `\p{Letter} \p{UnicodePropertyName=Letter}` | | -| `\p{Letter_Number} \p{UnicodePropertyName=Line_Separator}` | | -| `\p{Lowercase_Letter} \p{UnicodePropertyName=Lowercase_Letter}` | | -| `\p{Mark} \p{UnicodePropertyName=Mark}` | | -| `\p{Math_Symbol;} \p{UnicodePropertyName=Math_Symbol}` | | -| `\p{Modifier_Letter} \p{UnicodePropertyName=Modifier_Letter}` | | -| `\p{Modifier_Symbol} \p{UnicodePropertyName=Modifier_Symbol}` | | -| `\p{Nonspacing_Mark} \p{UnicodePropertyName=Nonspacing_Mark}` | | -| `\p{Number} \p{UnicodePropertyName=Number}` | | -| `\p{Open_Punctuation} \p{UnicodePropertyName=Open_Punctuation}` | | -| `\p{Other} \p{UnicodePropertyName=Other_Letter}` | | -| `\p{Other_Letter} \p{UnicodePropertyName=Other_Letter}` | | -| `\p{Other_Number} \p{UnicodePropertyName=Other_Number}` | | -| `\p{Other_Punctuation} \p{UnicodePropertyName=Other_Punctuation}` | | -| `\p{Paragraph_Separator} \p{UnicodePropertyName=Paragraph_Separator}` | | -| `\p{Private_Use} \p{UnicodePropertyName=Private_Use}` | | -| `\p{Punctuation} \p{UnicodePropertyName=Punctuation}` | | -| `\p{Separator} \p{UnicodePropertyName=Separator}` | | -| `\p{Space_Separator} \p{UnicodePropertyName=Space_Separator}` | | -| `\p{Spaceing_Mark} \p{UnicodePropertyName=Spacing_Mark}` | | -| `\p{Surrogate} \p{UnicodePropertyName=Surrogate}` | | -| `\p{Symbol} \p{UnicodePropertyName=Symbol}` | | -| `\p{Titlecase_Letter} \p{UnicodePropertyName=Titlecase_Letter}` | | -| `\p{Unassigned} \p{UnicodePropertyName=Unassigned}` | | -| `\p{Uppercase_Letter} \p{UnicodePropertyName=UppercaseLetter}` | | +| Échappements | Signification | +| ------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | +| `\p{LC} \p{Cased_Letter} \p{UnicodePropertyName=Cased_Letter}` | N'importe quelle lettre avec la version minuscule et la version majuscule. Équivalent à `\p{Lu}\|\p{Ll}\|p{Lt}`. | +| `\p{Close_Punctuation} \p{UnicodePropertyName=Close_Punctuation}` | | +| `\p{Connector_Punctuation} \p{UnicodePropertyName=Connector_Punctuation}` | | +| `\p{Control} \p{UnicodePropertyName=Control}` | | +| `\p{Currency_Symbol} \p{UnicodePropertyName=Currency_Symbol}` | | +| `\p{Dash_Punctuation} \p{UnicodePropertyName=Dash_Punctuation}` | | +| `\p{Decimal_Number} \p{UnicodePropertyName=Decimal_Number}` | | +| `\p{Enclosing_Mark} \p{UnicodePropertyName=Enclosing_Mark}` | | +| `\p{Final_Punctuation} \p{UnicodePropertyName=Final_Punctuation}` | | +| `\p{Format} \p{UnicodePropertyName=Format}` | | +| `\p{Initial_Punctuation} \p{UnicodePropertyName=Initial_Punctuation}` | | +| `\p{Letter} \p{UnicodePropertyName=Letter}` | | +| `\p{Letter_Number} \p{UnicodePropertyName=Line_Separator}` | | +| `\p{Lowercase_Letter} \p{UnicodePropertyName=Lowercase_Letter}` | | +| `\p{Mark} \p{UnicodePropertyName=Mark}` | | +| `\p{Math_Symbol;} \p{UnicodePropertyName=Math_Symbol}` | | +| `\p{Modifier_Letter} \p{UnicodePropertyName=Modifier_Letter}` | | +| `\p{Modifier_Symbol} \p{UnicodePropertyName=Modifier_Symbol}` | | +| `\p{Nonspacing_Mark} \p{UnicodePropertyName=Nonspacing_Mark}` | | +| `\p{Number} \p{UnicodePropertyName=Number}` | | +| `\p{Open_Punctuation} \p{UnicodePropertyName=Open_Punctuation}` | | +| `\p{Other} \p{UnicodePropertyName=Other_Letter}` | | +| `\p{Other_Letter} \p{UnicodePropertyName=Other_Letter}` | | +| `\p{Other_Number} \p{UnicodePropertyName=Other_Number}` | | +| `\p{Other_Punctuation} \p{UnicodePropertyName=Other_Punctuation}` | | +| `\p{Paragraph_Separator} \p{UnicodePropertyName=Paragraph_Separator}` | | +| `\p{Private_Use} \p{UnicodePropertyName=Private_Use}` | | +| `\p{Punctuation} \p{UnicodePropertyName=Punctuation}` | | +| `\p{Separator} \p{UnicodePropertyName=Separator}` | | +| `\p{Space_Separator} \p{UnicodePropertyName=Space_Separator}` | | +| `\p{Spaceing_Mark} \p{UnicodePropertyName=Spacing_Mark}` | | +| `\p{Surrogate} \p{UnicodePropertyName=Surrogate}` | | +| `\p{Symbol} \p{UnicodePropertyName=Symbol}` | | +| `\p{Titlecase_Letter} \p{UnicodePropertyName=Titlecase_Letter}` | | +| `\p{Unassigned} \p{UnicodePropertyName=Unassigned}` | | +| `\p{Uppercase_Letter} \p{UnicodePropertyName=UppercaseLetter}` | | ### Binaires diff --git a/files/fr/web/javascript/reference/statements/async_function/index.md b/files/fr/web/javascript/reference/statements/async_function/index.md index 12e3678d4ae333..65512c0627430c 100644 --- a/files/fr/web/javascript/reference/statements/async_function/index.md +++ b/files/fr/web/javascript/reference/statements/async_function/index.md @@ -48,28 +48,28 @@ Le mot-clé `await` est uniquement valide au sein des fonctions asynchrones. Si ### Exemple simple ```js -var resolveAfter2Seconds = function() { +var resolveAfter2Seconds = function () { console.log("Initialisation de la promesse lente"); - return new Promise(resolve => { - setTimeout(function() { + return new Promise((resolve) => { + setTimeout(function () { resolve("lente"); console.log("La promesse lente est terminée"); }, 2000); }); }; -var resolveAfter1Second = function() { +var resolveAfter1Second = function () { console.log("Initialisation de la promesse rapide"); - return new Promise(resolve => { - setTimeout(function() { + return new Promise((resolve) => { + setTimeout(function () { resolve("rapide"); console.log("La promesse rapide est terminée"); }, 1000); }); }; -var sequentialStart = async function() { - console.log('==Début séquentiel=='); +var sequentialStart = async function () { + console.log("==Début séquentiel=="); // 1. L'exécution atteint ce point quasi-instantanément const lente = await resolveAfter2Seconds(); @@ -77,47 +77,49 @@ var sequentialStart = async function() { const rapide = await resolveAfter1Second(); console.log(rapide); // 3. cela s'exécute 3s après 1. -} +}; -var concurrentStart = async function() { - console.log('==Début concurrentiel avec await=='); +var concurrentStart = async function () { + console.log("==Début concurrentiel avec await=="); const lente = resolveAfter2Seconds(); // le minuteur démarre immédiatement - const rapide = resolveAfter1Second(); // le minuteur démarre immédiatement + const rapide = resolveAfter1Second(); // le minuteur démarre immédiatement // 1. L'exécution atteint ce point quasi-instantanément console.log(await lente); // 2. s'exécute 2s après 1. console.log(await rapide); // 3. s'exécute 2s après 1., immédiatement après 2., - // car "rapide" est déjà résolue -} + // car "rapide" est déjà résolue +}; -var concurrentPromise = function() { - console.log('==Début concurrentiel avec Promise.all=='); - return Promise.all([resolveAfter2Seconds(), resolveAfter1Second()]).then((messages) => { - console.log(messages[0]); // lente - console.log(messages[1]); // rapide - }); -} +var concurrentPromise = function () { + console.log("==Début concurrentiel avec Promise.all=="); + return Promise.all([resolveAfter2Seconds(), resolveAfter1Second()]).then( + (messages) => { + console.log(messages[0]); // lente + console.log(messages[1]); // rapide + }, + ); +}; -var parallel = async function() { - console.log('==Exécution parallèle avec await Promise.all=='); +var parallel = async function () { + console.log("==Exécution parallèle avec await Promise.all=="); // Démarre 2 tâches en parallèle et on attend que les deux soient finies await Promise.all([ - (async()=>console.log(await resolveAfter2Seconds()))(), - (async()=>console.log(await resolveAfter1Second()))() + (async () => console.log(await resolveAfter2Seconds()))(), + (async () => console.log(await resolveAfter1Second()))(), ]); -} +}; // Cette fonction ne gère pas les erreurs // voir les avertissement ci-après ! -var parallelPromise = function() { - console.log('==Exécution parallèle avec Promise.then=='); - resolveAfter2Seconds().then((message)=>console.log(message)); - resolveAfter1Second().then((message)=>console.log(message)); -} +var parallelPromise = function () { + console.log("==Exécution parallèle avec Promise.then=="); + resolveAfter2Seconds().then((message) => console.log(message)); + resolveAfter1Second().then((message) => console.log(message)); +}; sequentialStart(); // après 2 secondes, "lente" est affichée, après une - // autre seconde, c'est "rapide" qui est affichée +// autre seconde, c'est "rapide" qui est affichée // on attend que l'étape précédente soit terminée setTimeout(concurrentStart, 4000); // 2s avant d'afficher "lente" puis "rapide" @@ -127,8 +129,8 @@ setTimeout(concurrentPromise, 7000); // identique à concurrentStart // on attend à nouveau setTimeout(parallel, 10000); // réellement parallele : après 1 seconde, - // affiche "rapide" et après une autre seconde - // affiche "lente" +// affiche "rapide" et après une autre seconde +// affiche "lente" // on attend à nouveau setTimeout(parallelPromise, 13000); // identique à parallel @@ -161,10 +163,10 @@ Lorsqu'on utilise une API qui renvoie des promesses ({{jsxref("Promise")}}), on ```js function getProcessedData(url) { return downloadData(url) // renvoie une promesse - .catch(e => { - return downloadFallbackData(url); // renvoie une promesse + .catch((e) => { + return downloadFallbackData(url); // renvoie une promesse }) - .then(v => { + .then((v) => { return processDataInWorker(v); // renvoie une promesse }); } @@ -177,7 +179,7 @@ async function getProcessedData(url) { let v; try { v = await downloadData(url); - } catch(e) { + } catch (e) { v = await downloadFallbackData(url); } return processDataInWorker(v); @@ -196,13 +198,13 @@ Si on reprend l'exemple précédent et qu'on le réécrit avec `return await` et async function getProcessedData(url) { let v; try { - v = await downloadData(url); - } catch(e) { + v = await downloadData(url); + } catch (e) { v = await downloadFallbackData(url); } try { return await processDataInWorker(v); // et non plus simplement return - } catch(e) { + } catch (e) { return null; } } diff --git a/files/fr/web/javascript/reference/statements/async_function_star_/index.md b/files/fr/web/javascript/reference/statements/async_function_star_/index.md index de9411cff24e66..4292e8a1a8b6fc 100644 --- a/files/fr/web/javascript/reference/statements/async_function_star_/index.md +++ b/files/fr/web/javascript/reference/statements/async_function_star_/index.md @@ -17,13 +17,13 @@ Il est aussi possible de définir des fonctions génératrices asynchrones à l' ```js async function* nom(param0) { - instructions + instructions; } async function* nom(param0, param1) { - instructions + instructions; } async function* nom(param0, param1, /* … ,*/ paramN) { - instructions + instructions; } ``` @@ -51,7 +51,9 @@ async function* toto() { yield Promise.reject(1); } -toto().next().catch((e) => console.error(e)); +toto() + .next() + .catch((e) => console.error(e)); ``` Qui affichera `1` dans la console, car la promesse ainsi générée déclenche une erreur et le résultat dans l'itérateur déclenche une erreur également. La propriété `value` du résultat d'un générateur asynchrone résolu ne sera pas une autre promesse. @@ -71,7 +73,8 @@ async function* monGenerateur(etape) { } const gen = monGenerateur(2); -gen.next() +gen + .next() .then((res) => { console.log(res); // { value: 0, done: false } return gen.next(); @@ -102,13 +105,13 @@ async function* readFiles(directory) { if (stats.isFile()) { yield { name: file, - content: await fs.readFile(file, 'utf8'), + content: await fs.readFile(file, "utf8"), }; } } } -const files = readFiles('.'); +const files = readFiles("."); console.log((await files.next()).value); // Exemple de sortie : { name: 'fichier1.txt', content: '...' } console.log((await files.next()).value); diff --git a/files/fr/web/javascript/reference/statements/break/index.md b/files/fr/web/javascript/reference/statements/break/index.md index cb606a3e593af3..7633fabcb380f6 100644 --- a/files/fr/web/javascript/reference/statements/break/index.md +++ b/files/fr/web/javascript/reference/statements/break/index.md @@ -33,15 +33,15 @@ La fonction qui suit utilise une instruction `break` qui interrompt la boucle {{ ```js function testBreak(x) { - var i = 0; - - while (i < 6) { - if (i == 3) { - break; - } - i += 1; - } - return i * x; + var i = 0; + + while (i < 6) { + if (i == 3) { + break; + } + i += 1; + } + return i * x; } ``` @@ -51,14 +51,13 @@ Dans le code suivant, on utilise les instructions `break` avec des blocs étique ```js bloc_externe: { - bloc_interne: { - console.log ('1'); - break bloc_externe; // interrompt bloc_externe ET bloc_interne - console.log (':-('); // ignoré + console.log("1"); + break bloc_externe; // interrompt bloc_externe ET bloc_interne + console.log(":-("); // ignoré } - console.log ('2'); // ignoré + console.log("2"); // ignoré } ``` diff --git a/files/fr/web/javascript/reference/statements/class/index.md b/files/fr/web/javascript/reference/statements/class/index.md index 8776765fc793c4..ee6184a75b5fa6 100644 --- a/files/fr/web/javascript/reference/statements/class/index.md +++ b/files/fr/web/javascript/reference/statements/class/index.md @@ -35,7 +35,7 @@ Dans l'exemple qui suit, on définit une classe `Polygone` pour laquelle on cré ```js class Polygone { constructor(hauteur, largeur) { - this.nom = 'Polygone'; + this.nom = "Polygone"; this.hauteur = hauteur; this.largeur = largeur; } @@ -43,8 +43,8 @@ class Polygone { class Carré extends Polygone { constructor(longueur) { - super(longueur,longueur); - this.nom = 'Carré'; + super(longueur, longueur); + this.nom = "Carré"; } } ``` @@ -53,12 +53,12 @@ class Carré extends Polygone { > > ```js > // Deux déclarations avec le même nom -> class Toto {}; -> class Toto {}; // Uncaught SyntaxError: Identifier 'Toto' has already been declared +> class Toto {} +> class Toto {} // Uncaught SyntaxError: Identifier 'Toto' has already been declared > > // Expression puis déclaration > var Truc = class {}; -> class Truc {}; // Uncaught TypeError: Identifier 'Truc' has already been declared +> class Truc {} // Uncaught TypeError: Identifier 'Truc' has already been declared > ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/statements/continue/index.md b/files/fr/web/javascript/reference/statements/continue/index.md index 7804d129526006..fbc2f79649a5f7 100644 --- a/files/fr/web/javascript/reference/statements/continue/index.md +++ b/files/fr/web/javascript/reference/statements/continue/index.md @@ -66,46 +66,46 @@ vérifIetJ: while (i < 4) { i += 1; vérifJ: while (j > 4) { - console.log("j : "+ j); + console.log("j : " + j); j -= 1; - if ((j % 2) == 0){ + if (j % 2 == 0) { continue vérifJ; } console.log(j + " est impaire."); - } - console.log("i = " + i); - console.log("j = " + j); + } + console.log("i = " + i); + console.log("j = " + j); } ``` En utilisant le fragment ci-avant, on aura le résultat suivant : ```js -"i : 0" +"i : 0"; // début de vérifJ -"j : 8" -"7 est impair" -"j : 7" -"j : 6" -"5 est impair." -"j : 5" +"j : 8"; +"7 est impair"; +"j : 7"; +"j : 6"; +"5 est impair."; +"j : 5"; // fin de vérifJ -"i = 1" -"j = 4" +"i = 1"; +"j = 4"; -"i : 1" -"i = 2" -"j = 4" +"i : 1"; +"i = 2"; +"j = 4"; -"i : 2" -"i = 3" -"j = 4" +"i : 2"; +"i = 3"; +"j = 4"; -"i : 3" -"i = 4" -"j = 4" +"i : 3"; +"i = 4"; +"j = 4"; ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/statements/debugger/index.md b/files/fr/web/javascript/reference/statements/debugger/index.md index 8d00e6bab003ce..43c3f5f239e102 100644 --- a/files/fr/web/javascript/reference/statements/debugger/index.md +++ b/files/fr/web/javascript/reference/statements/debugger/index.md @@ -20,9 +20,9 @@ Dans l'exemple qui suit, on utilise un code avec l'instruction `debugger` qui pe ```js function codeProbablementBogue() { - debugger; - // exécuter des instructions qu'on veut - // examiner, exécuter pas à pas etc. + debugger; + // exécuter des instructions qu'on veut + // examiner, exécuter pas à pas etc. } ``` diff --git a/files/fr/web/javascript/reference/statements/do...while/index.md b/files/fr/web/javascript/reference/statements/do...while/index.md index 08a5f9db76f5f4..a16eafc1f75b50 100644 --- a/files/fr/web/javascript/reference/statements/do...while/index.md +++ b/files/fr/web/javascript/reference/statements/do...while/index.md @@ -13,8 +13,7 @@ L'instruction **`do...while`** crée une boucle qui exécute une instruction jus ## Syntaxe ```js -do - instruction +do instruction; while (condition); ``` @@ -32,8 +31,8 @@ Dans l'exemple suivant, la boucle `do...while` est parcourue au moins une fois e ```js var i = 0; do { - i += 1; - console.log(i); + i += 1; + console.log(i); } while (i < 5); ``` diff --git a/files/fr/web/javascript/reference/statements/empty/index.md b/files/fr/web/javascript/reference/statements/empty/index.md index f9b5be043fee59..a335a8cffaa991 100644 --- a/files/fr/web/javascript/reference/statements/empty/index.md +++ b/files/fr/web/javascript/reference/statements/empty/index.md @@ -12,7 +12,7 @@ Une **instruction vide** est utilisée pour ne fournir aucune instruction là o ## Syntaxe -```js +```js-nolint ; ``` @@ -28,32 +28,29 @@ L'instruction vide peut être utilisée dans les boucles. Par exemple, ici on a var arr = [1, 2, 3]; // Affecter 0 pour toutes les valeurs du tableau -for (i = 0; i < arr.length; arr[i++] = 0) /* instruction vide */ ; +for (i = 0; i < arr.length; arr[i++] = 0 /* instruction vide */); -console.log(arr) +console.log(arr); // [0, 0, 0] ``` > **Note :** Cela peut être raisonnable que de commenter l'utilisation d'une instruction vide pour la rendre visible et l'expliciter. Par exemple, dans le code qui suit, le point-virgule ne semble pas intentionnel : ```js -if (condition); // Attention, ce "if" ne fait rien ! - finDuMonde() // Cette méthode est donc toujours lancée !!! +if (condition); // Attention, ce "if" ne fait rien ! +finDuMonde(); // Cette méthode est donc toujours lancée !!! ``` Un autre exemple avec une instruction {{jsxref("Instructions/if...else")}} sans accolade (`{}`). Si `trois` vaut `true`, rien ne sera exécuté, peu importera la valeur de `quatre`, la fonction `chargerFusée()` ne sera pas exécutée. ```js -if (un) - faire1èreEtape(); -else if (deux) - faire4èmeEtape(); -else if (trois) - ; // rien ici +if (un) faire1èreEtape(); +else if (deux) faire4èmeEtape(); +else if (trois); else if (quatre) + // rien ici faire4èmeEtape(); -else - chargerFusée(); +else chargerFusée(); ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/statements/export/index.md b/files/fr/web/javascript/reference/statements/export/index.md index 0bef40024a10bc..a9c1e8b02e1b97 100644 --- a/files/fr/web/javascript/reference/statements/export/index.md +++ b/files/fr/web/javascript/reference/statements/export/index.md @@ -51,24 +51,24 @@ Il existe deux types d'export différents : les exports **nommés** et les expor - Les exports nommés : ```js - // exporte une fonction déclarée précédemment - export { maFonction }; + // exporte une fonction déclarée précédemment + export { maFonction }; - // exporte une constante - export const machin = Math.sqrt(2); - ``` + // exporte une constante + export const machin = Math.sqrt(2); + ``` - Les exports par défaut (fonction) : ```js - export default function() {} - ``` + export default function () {} + ``` - Les exports par défaut (classe) : ```js - export default class {} - ``` + export default class {} + ``` Les exports nommés sont utiles pour exporter plusieurs valeurs. Lors de l'importation, il est obligatoire d'utiliser le même nom de l'objet correspondant. @@ -77,8 +77,8 @@ Mais un export par défaut peut être importé avec n'importe quel nom, par exem ```js let k; export default k = 12; // dans le fichier test.js -import m from './test'; // notez que nous avons la liberté d'utiliser import m au lieu de import k, parce que k était l'export par défaut -console.log (m); // enregistrera 12 +import m from "./test"; // notez que nous avons la liberté d'utiliser import m au lieu de import k, parce que k était l'export par défaut +console.log(m); // enregistrera 12 ``` La syntaxe suivante n'exporte pas le défaut depuis le module importé : @@ -90,7 +90,7 @@ export * from …; Si vous avez besoin d'exporter le défaut, écrivez ce qui suit à la place : ```js -export {default} from 'mod'; +export { default } from "mod"; ``` Il est possible de renommer un export afin d'éviter des conflits de nommage : @@ -104,11 +104,11 @@ On peut également agréger les valeurs exportées à celles d'autres modules qu ```js // Dans moduleParent.js -export { maFonction, maVariable } from 'moduleFils1.js'; -export { maClasse } from 'moduleFils2.js' +export { maFonction, maVariable } from "moduleFils1.js"; +export { maClasse } from "moduleFils2.js"; // Dans le module de plus haut niveau -import { maFonction, maVariable, maClasse } from 'moduleParent.js'; +import { maFonction, maVariable, maClasse } from "moduleParent.js"; ``` ## Exemples @@ -129,9 +129,9 @@ export { cube, machin }; De cette façon, dans un autre script, on pourra avoir : ```js -import { cube, machin } from 'mon-module'; +import { cube, machin } from "mon-module"; console.log(cube(3)); // 27 -console.log(machin); // 4.555806215962888 +console.log(machin); // 4.555806215962888 ``` > **Note :** Si l'import est réalisé dans un script HTML, il faut que celui-ci soit chargé avec l'attribut [`type`](/fr/docs/Web/HTML/Global_attributes#type) `"module"` : `` sinon il y aura une erreur quant aux origines multiples ([CORS](/fr/docs/Web/HTTP/CORS)). @@ -151,7 +151,7 @@ export default function cube(x) { Alors, dans un autre script, il sera facile d'importer l'export par défaut : ```js -import cube from './mon-module.js'; +import cube from "./mon-module.js"; console.log(cube(3)); // 27 ``` diff --git a/files/fr/web/javascript/reference/statements/for-await...of/index.md b/files/fr/web/javascript/reference/statements/for-await...of/index.md index da17e31fe159ad..8bfd590e511f80 100644 --- a/files/fr/web/javascript/reference/statements/for-await...of/index.md +++ b/files/fr/web/javascript/reference/statements/for-await...of/index.md @@ -12,7 +12,7 @@ L'instruction **`for await…of`** permet de créer une boucle qui parcourt les ```js for await (const variable of iterable) { - instruction + instruction; } ``` @@ -36,14 +36,14 @@ var asyncIterable = { } return Promise.resolve({ done: true }); - } + }, }; - } + }, }; -(async function() { - for await (let num of asyncIterable) { - console.log(num); +(async function () { + for await (let num of asyncIterable) { + console.log(num); } })(); // 0 @@ -63,7 +63,7 @@ async function* asyncGenerator() { } } -(async function() { +(async function () { for await (let num of asyncGenerator()) { console.log(num); } @@ -106,7 +106,7 @@ async function getResponseSize(url) { console.log(`Taille de la réponse : ${responseSize} octets`); return responseSize; } -getResponseSize('https://jsonplaceholder.typicode.com/photos'); +getResponseSize("https://jsonplaceholder.typicode.com/photos"); ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/statements/for...in/index.md b/files/fr/web/javascript/reference/statements/for...in/index.md index 3f4e42f1cdde3a..7f6938b1f2bc0c 100644 --- a/files/fr/web/javascript/reference/statements/for...in/index.md +++ b/files/fr/web/javascript/reference/statements/for...in/index.md @@ -14,7 +14,7 @@ L'**instruction `for...in`** permet d'itérer sur les [propriétés énumérable ```js for (variable in objet) { - instructions + instructions; } ``` @@ -52,7 +52,7 @@ Si on souhaite ne parcourir que les propriétés propres d'un objet et pas celle La boucle `for...in` qui suit utilise parcourt l'objet `obj` et ses propriétés énumérables qui ne sont pas des symboles en fournissant la chaîne de caractères qui décrit le nom de la propriété et sa valeur. ```js -var obj = {a:1, b:2, c:3}; +var obj = { a: 1, b: 2, c: 3 }; for (var prop in obj) { console.log(`obj.${prop} = ${obj[prop]}`); @@ -67,7 +67,7 @@ for (var prop in obj) { La fonction qui suit utilise {{jsxref("Object.hasOwnProperty", "hasOwnProperty()")}} pour ne pas afficher les propriétés héritées : ```js -var triangle = {a:1, b:2, c:3}; +var triangle = { a: 1, b: 2, c: 3 }; function TriangleCouleur() { this.couleur = "rouge"; @@ -78,7 +78,7 @@ TriangleCouleur.prototype = triangle; var obj = new TriangleCouleur(); for (var prop in obj) { - if( obj.hasOwnProperty( prop ) ) { + if (obj.hasOwnProperty(prop)) { console.log(`obj.${prop} = ${obj[prop]}`); } } diff --git a/files/fr/web/javascript/reference/statements/for...of/index.md b/files/fr/web/javascript/reference/statements/for...of/index.md index 64859c1ddfc89d..c8646fde8a1394 100644 --- a/files/fr/web/javascript/reference/statements/for...of/index.md +++ b/files/fr/web/javascript/reference/statements/for...of/index.md @@ -14,7 +14,7 @@ L'**instruction `for...of`** permet de créer une boucle {{jsxref("Array")}} qui ```js for (variable of iterable) { - instruction + instruction; } ``` @@ -56,7 +56,7 @@ for (const valeur of tableauItérable) { ### Parcourir une chaîne de caractères avec `for...of` ```js -let iterable = 'pixel'; +let iterable = "pixel"; for (let valeur of iterable) { console.log(valeur); @@ -83,7 +83,11 @@ for (let valeur of iterable) { ### Parcourir une {{jsxref("Map")}} ```js -let iterable = new Map([['a', 1], ['b', 2], ['c', 3]]); +let iterable = new Map([ + ["a", 1], + ["b", 2], + ["c", 3], +]); for (let element of iterable) { console.log(element); @@ -110,14 +114,14 @@ arr.toto = "coucou"; arr.forEach(function (element, index) { console.log(element); // affiche "3", "5", "7" - console.log(index); // affiche "0", "1", "2" + console.log(index); // affiche "0", "1", "2" }); // ou avec Object.keys() Object.keys(arr).forEach(function (element, index) { console.log(arr[element]); // affiche "3", "5", "7", "coucou" - console.log(arr[index]); // affiche "3", "5", "7", undefined + console.log(arr[index]); // affiche "3", "5", "7", undefined }); ``` @@ -126,8 +130,8 @@ Object.keys(arr).forEach(function (element, index) { Il est possible de parcourir l'objet {{jsxref("Fonctions/arguments", "arguments")}} afin d'examiner l'ensemble des paramètres passés à la fonction : ```js -(function() { - for (let argument of arguments){ +(function () { + for (let argument of arguments) { console.log(argument); } })(1, 2, 3); @@ -160,7 +164,7 @@ function* toto() { yield 1; yield 2; yield 3; -}; +} for (let o of toto()) { console.log(o); @@ -173,7 +177,8 @@ for (let o of toto()) { Grâce à cette instruction, on peut également itérer sur les {{jsxref("Instructions/function*","générateurs","",1)}} : ```js -function* fibonacci() { // une fonction génératrice +function* fibonacci() { + // une fonction génératrice let [prev, curr] = [0, 1]; while (true) { [prev, curr] = [curr, prev + curr]; @@ -184,7 +189,7 @@ function* fibonacci() { // une fonction génératrice for (let n of fibonacci()) { console.log(n); // on arrête la séquence à 1000 - if (n >= 1000){ + if (n >= 1000) { break; } } @@ -204,9 +209,9 @@ var iterable = { return { value: this.i++, done: false }; } return { value: undefined, done: true }; - } + }, }; - } + }, }; for (let value of iterable) { @@ -229,15 +234,15 @@ L'instruction `for...of` permet quant à elle de parcourir les données contenue Dans l'exemple qui suit, on illustre la différence de comportement entre une boucle `for...of` et une boucle `for...in` utilisées sur un tableau ({{jsxref("Array")}}). ```js -Object.prototype.objCustom = function() {}; -Array.prototype.arrCustom = function() {}; +Object.prototype.objCustom = function () {}; +Array.prototype.arrCustom = function () {}; let iterable = [3, 5, 7]; -iterable.toto = 'coucou'; +iterable.toto = "coucou"; for (let i in iterable) { console.log(i); // affiche 0, 1, 2, "toto", - // "arrCustom", "objCustom" + // "arrCustom", "objCustom" } for (let i in iterable) { @@ -256,7 +261,7 @@ Chaque objet héritera de la propriété `objCustom` et chaque objet qui est un ```js for (let i in iterable) { console.log(i); // affiche 0, 1, 2, "toto", - // "arrCustom" et "objCustom" + // "arrCustom" et "objCustom" } ``` @@ -285,7 +290,7 @@ Cette boucle parcourt les valeurs définies comme itérables par [l'objet itéra Les générateurs ne doivent pas être réutilisés, même lorsque la boucle `for...of` a été interrompue (par exemple lorsque {{jsxref("Instructions/break","break")}} est utilisé). Lorsqu'on quitte une boucle, le générateur est clôturé et si on l'utilise à nouveau, il ne fournira aucun résultat. Firefox n'a pas encore implémenté ce comportement standard (cf. [bug Firefox 1147371](https://bugzil.la/1147371)). ```js -var gen = (function *(){ +var gen = (function* () { yield 1; yield 2; yield 3; @@ -296,7 +301,7 @@ for (let o of gen) { } // Le générateur ne doit pas être réutilisé ! -for (let o of gen){ +for (let o of gen) { console.log(o); // Ceci n'est jamais exécuté } ``` diff --git a/files/fr/web/javascript/reference/statements/for/index.md b/files/fr/web/javascript/reference/statements/for/index.md index 54867152565294..7eda8ff37a3cad 100644 --- a/files/fr/web/javascript/reference/statements/for/index.md +++ b/files/fr/web/javascript/reference/statements/for/index.md @@ -13,8 +13,7 @@ L'instruction **`for`** crée une boucle composée de trois expressions optionne ## Syntaxe ```js -for ([initialisation]; [condition]; [expression-finale]) - instruction +for ([initialisation]; [condition]; [expression_finale]) instruction; ``` ### Paramètres @@ -36,8 +35,8 @@ L'instruction `for` qui suit débute en déclarant la variable `i` et en l'initi ```js for (var i = 0; i < 9; i++) { - n += i; - myfunc(n); + n += i; + myfunc(n); } ``` @@ -50,18 +49,18 @@ Par exemple, le bloc pour l'initialisation peut ne pas être utilisé : ```js var i = 0; for (; i < 9; i++) { - console.log(i); - // d'autres instructions + console.log(i); + // d'autres instructions } ``` De même que pour le bloc d'initialisation, l'expression de condition est optionnelle. Attention, si l'expression de condition n'est pas utilisée, il faut s'assurer d'interrompre la boucle et de ne pas créer une boucle infinie. ```js -for (var i = 0;; i++) { - console.log(i); - if (i > 3) break; - // d'autres instructions +for (var i = 0; ; i++) { + console.log(i); + if (i > 3) break; + // d'autres instructions } ``` @@ -82,12 +81,27 @@ for (;;) { L'instruction `for` qui suit calcule le décalage d'un nœud et le fait dans la section qui correspond à l'expression finale. Il n'y a donc aucun intérêt à ajouter une instruction ou un bloc d'instruction dans la boucle pour faire ce calcul. ```js -function showOffsetPos (sId) { - var nLeft = 0, nTop = 0; - - for (var oItNode = document.getElementById(sId); oItNode; nLeft += oItNode.offsetLeft, nTop += oItNode.offsetTop, oItNode = oItNode.offsetParent); - - console.log("Décalage de position : \"" + sId + "\" element:\n left: " + nLeft + "px;\n top: " + nTop + "px;"); +function showOffsetPos(sId) { + var nLeft = 0, + nTop = 0; + + for ( + var oItNode = document.getElementById(sId); + oItNode; + nLeft += oItNode.offsetLeft, + nTop += oItNode.offsetTop, + oItNode = oItNode.offsetParent + ); + + console.log( + 'Décalage de position : "' + + sId + + '" element:\n left: ' + + nLeft + + "px;\n top: " + + nTop + + "px;", + ); } ``` diff --git a/files/fr/web/javascript/reference/statements/function/index.md b/files/fr/web/javascript/reference/statements/function/index.md index b2deac8bf6f8b2..f4ed5d361fc39a 100644 --- a/files/fr/web/javascript/reference/statements/function/index.md +++ b/files/fr/web/javascript/reference/statements/function/index.md @@ -41,9 +41,15 @@ Il est possible de déclarer des fonctions de façon conditionnelle (c'est-à-di ```js var remontee = "toto" in this; -console.log(`'toto' ${remontee ? "est" : "n'est pas"} remontée. typeof toto vaut ${typeof toto}`); +console.log( + `'toto' ${ + remontee ? "est" : "n'est pas" + } remontée. typeof toto vaut ${typeof toto}`, +); if (false) { - function toto(){ return 1; } + function toto() { + return 1; + } } // Pour Chrome: @@ -63,9 +69,15 @@ On obtient exactement les mêmes résultats si la condition est vérifiée (ici ```js var remontee = "toto" in this; -console.log(`'toto' ${remontee ? "est" : "n'est pas"} remontée. typeof toto vaut ${typeof toto}`); +console.log( + `'toto' ${ + remontee ? "est" : "n'est pas" + } remontée. typeof toto vaut ${typeof toto}`, +); if (true) { - function toto(){ return 1; } + function toto() { + return 1; + } } // Pour Chrome: @@ -98,8 +110,8 @@ On notera que les {{jsxref("Opérateurs/L_opérateur_function", "expressions de ```js nonRemontée(); // TypeError: nonRemontée is not a function -var nonRemontée = function() { - console.log("truc"); +var nonRemontée = function () { + console.log("truc"); }; ``` @@ -111,7 +123,7 @@ Dans l'exemple qui suit, on déclare une fonction qui renvoie le total des vente ```js function calc_ventes(nb_produits_a, nb_produits_b, nb_produits_c) { - return nb_produits_a*79 + nb_produits_b * 129 + nb_produits_c * 699; + return nb_produits_a * 79 + nb_produits_b * 129 + nb_produits_c * 699; } ``` diff --git a/files/fr/web/javascript/reference/statements/function_star_/index.md b/files/fr/web/javascript/reference/statements/function_star_/index.md index f48afb136148d0..91420d22da8d65 100644 --- a/files/fr/web/javascript/reference/statements/function_star_/index.md +++ b/files/fr/web/javascript/reference/statements/function_star_/index.md @@ -44,7 +44,7 @@ On peut utiliser une instruction `return` dans un générateur. Lorsque cette in ### Exemple simple ```js -function* creerID(){ +function* creerID() { var index = 0; while (true) { yield index++; @@ -73,9 +73,9 @@ var gen = logGenerator(); // le premier appel à next exécute la fonction depuis son // début jusqu'au premier yield rencontré gen.next(); -gen.next('bretzel'); // bretzel -gen.next('california'); // california -gen.next('mayonnaise'); // mayonnaise +gen.next("bretzel"); // bretzel +gen.next("california"); // california +gen.next("mayonnaise"); // mayonnaise ``` ### Exemple utilisant yield\* @@ -86,7 +86,7 @@ function* autreGenerateur(i) { yield i + 2; yield i + 3; } -function* generateur(i){ +function* generateur(i) { yield i; yield* autreGenerateur(i); yield i + 10; @@ -121,11 +121,11 @@ console.log(gen.next()); // { value: undefined, done: true } ```js const monObj = { - *generator () { + *generator() { yield "a"; yield "b"; - } -} + }, +}; const gen = monObj.generator(); @@ -138,28 +138,28 @@ console.log(gen.next()); // { value: undefined, done: true } ```js class Toto { - *[Symbol.iterator] () { + *[Symbol.iterator]() { yield 1; yield 2; } } const monObj = { - *[Symbol.iterator] () { + *[Symbol.iterator]() { yield "a"; yield "b"; - } -} + }, +}; -console.log(Array.from(new Toto)); // [1, 2] -console.log(Array.from(monObj)); // [ "a", "b"] +console.log(Array.from(new Toto())); // [1, 2] +console.log(Array.from(monObj)); // [ "a", "b"] ``` ### Les générateurs ne sont pas constructibles ```js example-bad function* f() {} -var obj = new f; // lève une TypeError: f n'est pas un constructeur +var obj = new f(); // lève une TypeError: f n'est pas un constructeur ``` ### Générateur défini avec une expression diff --git a/files/fr/web/javascript/reference/statements/if...else/index.md b/files/fr/web/javascript/reference/statements/if...else/index.md index ebb58f099ae6e4..c4ce24ce286832 100644 --- a/files/fr/web/javascript/reference/statements/if...else/index.md +++ b/files/fr/web/javascript/reference/statements/if...else/index.md @@ -14,9 +14,9 @@ L'instruction **`if`** exécute une instruction si une condition donnée est vra ```js if (condition) { - statement1 + statement1; } else { - statement2 + statement2; } ``` @@ -60,9 +60,9 @@ Afin d'exécuter plusieurs instructions, on utilisera un {{jsxref("Statements/bl ```js if (condition) { - instructions1 + instructions1; } else { - instructions2 + instructions2; } ``` @@ -91,7 +91,7 @@ if (cipher_char == from_char) { Bien qu'il n'y ait pas de mot-clé elseif dans le langage JavaScript, il est possible d'imbriquer des instructions if...else à la suite les une des autres en plaçant un espace entre else et le début de l'instruction if imbriquée : ```js -if (x > 50){ +if (x > 50) { // faire quelque chose } else if (x > 5) { // faire autre chose @@ -105,7 +105,7 @@ if (x > 50){ Il est conseillé de ne pas utiliser d'affectation au sein des expressions conditionnelles. En effet, l'affectation peut être confondue avec un test d'égalité lorsqu'on analyse le code. Il ne faut donc pas utiliser le code suivant (bien qu'il fonctionne) : ```js example-bad -if (x = y) { +if ((x = y)) { /* exécuter les instructions */ } ``` diff --git a/files/fr/web/javascript/reference/statements/import/index.md b/files/fr/web/javascript/reference/statements/import/index.md index f7068d3d426770..70903e2863bfa3 100644 --- a/files/fr/web/javascript/reference/statements/import/index.md +++ b/files/fr/web/javascript/reference/statements/import/index.md @@ -46,7 +46,7 @@ Le paramètre `nom` est le nom de l'"objet module" qui sera utilisé comme un ge Ce qui suit insère `monModule` dans la portée courante, contenant tous les exports du module dans le fichier situé dans `/modules/mon-module.js`. ```js -import * as monModule from '/modules/mon-module.js'; +import * as monModule from "/modules/mon-module.js"; ``` Ici, accéder aux exports signifie utiliser le nom du module (ici `monModule`) comme un espace de noms. Par exemple, si le module importé ci-dessus incluait un export `faireToutesLesChosesIncroyables()`, vous l'écririez comme ceci : @@ -60,7 +60,7 @@ monModule.faireToutesLesChosesIncroyables(); Étant donné un objet ou une valeur nommé(e) `monExport` qui est exporté(e) depuis le module `mon-module`, soit implicitement (parce que l'intégralité du module est exportée), soit explicitement (en utilisant l'instruction {{jsxref("Statements/export", "export")}}), ce qui suit insére `monExport` dans la portée courante. ```js -import {monExport} from '/modules/mon-module.js'; +import { monExport } from "/modules/mon-module.js"; ``` ### Importer plusieurs éléments exportés depuis un module @@ -68,7 +68,7 @@ import {monExport} from '/modules/mon-module.js'; Ce qui suit insère à la fois `machin` et `truc` dans la portée courante. ```js -import {machin, truc} from '/modules/mon-module.js'; +import { machin, truc } from "/modules/mon-module.js"; ``` ### Importer un élément exporté avec un alias @@ -76,8 +76,7 @@ import {machin, truc} from '/modules/mon-module.js'; Vous pouvez renommer un export lors de l'importation. Par exemple, ce qui suit insére `nomCourt` dans la portée courante. ```js -import {nomDExportDeModuleVraimentVraimentLong as nomCourt} - from '/modules/mon-module.js'; +import { nomDExportDeModuleVraimentVraimentLong as nomCourt } from "/modules/mon-module.js"; ``` ### Renommer plusieurs exports pendant l'import @@ -87,8 +86,8 @@ Importe des exports multiples depuis un module avec des alias commodes : ```js import { nomDExportDeModuleVraimentVraimentLong as nomCourt, - unAutreNomDeModuleLong as court -} from '/modules/mon-module.js'; + unAutreNomDeModuleLong as court, +} from "/modules/mon-module.js"; ``` ### Importer un module uniquement pour ses effets de bord @@ -96,7 +95,7 @@ import { Importe un module complet pour ses effets de bord seulement, sans importer quoi que ce soit. Ce qui suit exécute le code global du module, mais n'importe en fait aucune valeur. ```js -import '/modules/mon-module.js'; +import "/modules/mon-module.js"; ``` ### Importation des défauts @@ -106,20 +105,20 @@ Il est possible d'avoir un {{jsxref("Statements/export", "export")}} par défaut La version la plus simple importe directement le défaut : ```js -import monDefaut from '/modules/mon-module.js'; +import monDefaut from "/modules/mon-module.js"; ``` Il est également possible d'utiliser la syntaxe de défaut avec celles vues ci-dessus (imports d'espaces de noms ou imports nommés). Dans de tels cas, l'import par défaut devra être déclaré en premier. Par exemple : ```js -import monDefaut, * as monModule from '/modules/mon-module.js'; +import monDefaut, * as monModule from "/modules/mon-module.js"; // monModule utilisé comme un espace de noms ``` ou ```js -import monDefaut, {machin, truc} from '/modules/mon-module.js'; +import monDefaut, { machin, truc } from "/modules/mon-module.js"; // imports nommés spécifiques ``` @@ -128,16 +127,15 @@ import monDefaut, {machin, truc} from '/modules/mon-module.js'; Le mot-clé `import` peut être utilisé comme une fonction afin d'importer dynamiquement un module (utile lorsqu'on souhaite charger un module selon une condition donnée ou faire du chargement à la demande). Lorsqu'il est utilisé de cette façon, il renvoie une promesse : ```js -import('/modules/mon-module.js') - .then((module) => { - // Faire quelque chose avec le module - }); +import("/modules/mon-module.js").then((module) => { + // Faire quelque chose avec le module +}); ``` On peut utiliser cette forme avec le mot-clé `await` : ```js -let module = await import('/modules/mon-module.js'); +let module = await import("/modules/mon-module.js"); ``` ## Exemples @@ -150,24 +148,25 @@ Importation depuis un module secondaire pour aider le traitement d'une requête function getJSON(url, rappel) { let xhr = new XMLHttpRequest(); xhr.onload = function () { - rappel(this.responseText) + rappel(this.responseText); }; - xhr.open('GET', url, true); + xhr.open("GET", url, true); xhr.send(); } export function recupererContenuUtile(url, rappel) { - getJSON(url, donnees => rappel(JSON.parse(donnees))); + getJSON(url, (donnees) => rappel(JSON.parse(donnees))); } ``` ### Le programme principal : principal.js ```js -import { recupererContenuUtile } from '/modules/fichier.js'; +import { recupererContenuUtile } from "/modules/fichier.js"; -recupererContenuUtile('http://www.example.com', - donnees => { faireQuelqueChoseDUtile(donnees); }); +recupererContenuUtile("http://www.example.com", (donnees) => { + faireQuelqueChoseDUtile(donnees); +}); ``` ### Import dynamique @@ -177,20 +176,18 @@ Dans cet exemple, on voit comment charger une fonctionnalité sur une page lorsq ```js const main = document.querySelector("main"); for (const link of document.querySelectorAll("nav > a")) { - link.addEventListener("click", e => { + link.addEventListener("click", (e) => { e.preventDefault(); - import('/modules/mon-module.js') - .then(module => { + import("/modules/mon-module.js") + .then((module) => { module.loadPageInto(main); }) - .catch(err => { + .catch((err) => { main.textContent = err.message; }); }); } - -; ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/statements/label/index.md b/files/fr/web/javascript/reference/statements/label/index.md index 2e06d34fbb7e8d..ac22074c8955af 100644 --- a/files/fr/web/javascript/reference/statements/label/index.md +++ b/files/fr/web/javascript/reference/statements/label/index.md @@ -15,8 +15,7 @@ Une **instruction étiquetée (_labeled_ en anglais)** peut être utilisée avec ## Syntaxe ```js -label : - instruction +label: instruction; ``` - `label` @@ -39,16 +38,16 @@ En [mode strict](/fr/docs/Web/JavaScript/Reference/Strict_mode), on ne peut pas ```js var i, j; -boucle1: -for (i = 0; i < 3; i++) { //Le premier for correspond à "boucle1" - boucle2: - for (j = 0; j < 3; j++) { //Le second for correspond à "boucle2" - if (i === 1 && j === 1) { - continue boucle1; - } else { - console.log("i = " + i + ", j = " + j); - } - } +boucle1: for (i = 0; i < 3; i++) { + //Le premier for correspond à "boucle1" + boucle2: for (j = 0; j < 3; j++) { + //Le second for correspond à "boucle2" + if (i === 1 && j === 1) { + continue boucle1; + } else { + console.log("i = " + i + ", j = " + j); + } + } } // On aura les résultats suivants : @@ -70,10 +69,9 @@ for (i = 0; i < 3; i++) { //Le premier for correspond à "boucle1" var nbItemsReussis = 0; var i, j; -top: -for (i = 0; i < items.length; i++){ - for (j = 0; j < tests.length; j++){ - if (!tests[j].reussi(items[i])){ +top: for (i = 0; i < items.length; i++) { + for (j = 0; j < tests.length; j++) { + if (!tests[j].reussi(items[i])) { continue top; } } @@ -86,10 +84,10 @@ for (i = 0; i < items.length; i++){ ```js var i, j; -boucle1: -for (i = 0; i < 3; i++) { // première boucle étiquetée « boucle1 » - boucle2: - for (j =0; j < 3; j++) { // seconde boucle étiquetée « boucle2 » +boucle1: for (i = 0; i < 3; i++) { + // première boucle étiquetée « boucle1 » + boucle2: for (j = 0; j < 3; j++) { + // seconde boucle étiquetée « boucle2 » if (i == 1 && j == 1) { break boucle1; } @@ -114,10 +112,9 @@ for (i = 0; i < 3; i++) { // première boucle étiquetée « boucle1 » var toutReussi = true; var i, j; -top: -for (i = 0; items.length; i++) +top: for (i = 0; items.length; i++) for (j = 0; j < tests.length; i++) - if (!tests[j].reusi(items[i])){ + if (!tests[j].reusi(items[i])) { toutReussi = false; break top; } @@ -138,7 +135,7 @@ console.log("swap"); // On aura alors dans la console : // "face" -// "swap +// "swap ``` ### Déclarations de fonctions étiquetées diff --git a/files/fr/web/javascript/reference/statements/let/index.md b/files/fr/web/javascript/reference/statements/let/index.md index 9dadde75343dae..f9abbe33761f0e 100644 --- a/files/fr/web/javascript/reference/statements/let/index.md +++ b/files/fr/web/javascript/reference/statements/let/index.md @@ -46,19 +46,19 @@ if (x > y) { function varTest() { var x = 1; if (true) { - var x = 2; // c'est la même variable ! - console.log(x); // 2 + var x = 2; // c'est la même variable ! + console.log(x); // 2 } - console.log(x); // 2 + console.log(x); // 2 } function letTest() { let x = 1; if (true) { - let x = 2; // c'est une variable différente - console.log(x); // 2 + let x = 2; // c'est une variable différente + console.log(x); // 2 } - console.log(x); // 1 + console.log(x); // 1 } ``` @@ -87,8 +87,8 @@ for (var i = 1; i <= 5; i++) { var item = document.createElement("li"); item.appendChild(document.createTextNode("Item " + i)); - (function(i) { - item.onclick = function(ev) { + (function (i) { + item.onclick = function (ev) { console.log("Item " + i + " a reçu un clic."); }; })(i); @@ -106,30 +106,30 @@ Les variables déclarées avec `let` appartiennent à la portée du bloc dans le function varTest() { var x = 31; if (true) { - var x = 71; // c'est la même variable ! - console.log(x); // 71 + var x = 71; // c'est la même variable ! + console.log(x); // 71 } - console.log(x); // 71 + console.log(x); // 71 } function letTest() { let x = 31; if (true) { - let x = 71; // c'est une variable différente - console.log(x); // 71 + let x = 71; // c'est une variable différente + console.log(x); // 71 } - console.log(x); // 31 + console.log(x); // 31 } ``` Au niveau le plus haut (la portée globale), `let` crée une variable globale alors que `var` ajoute une propriété à l'objet global : ```js -var x = 'global'; -let y = 'global2'; +var x = "global"; +let y = "global2"; console.log(this.x); // "global" console.log(this.y); // undefined -console.log(y); // "global2" +console.log(y); // "global2" ``` ### Émuler le fonctionnement des interfaces privées @@ -143,19 +143,19 @@ var Truc; let porteePrivee = new WeakMap(); let compteur = 0; - Truc = function() { - this.unePropriete = 'toto'; + Truc = function () { + this.unePropriete = "toto"; porteePrivee.set(this, { cachee: ++compteur, }); }; - Truc.prototype.montrerPublique = function() { + Truc.prototype.montrerPublique = function () { return this.unePropriete; }; - Truc.prototype.montrerPrivee = function() { + Truc.prototype.montrerPrivee = function () { return porteePrivee.get(this).cachee; }; } @@ -219,7 +219,7 @@ Par contre, si on ajoute une instruction de bloc dans la clause `case`, cela cr ```js let x = 1; -switch(x) { +switch (x) { case 0: { let toto; break; @@ -243,8 +243,8 @@ if (a === 1) { var a = 11; // la portée est la portée globale let b = 22; // la portée est celle du bloc if - console.log(a); // 11 - console.log(b); // 22 + console.log(a); // 11 + console.log(b); // 22 } console.log(a); // 11 @@ -277,10 +277,10 @@ let i = 10; Dans l'exemple qui suit, dans l'expression `toto + 55`, l'identifiant `toto` fait référence à la variable du bloc courant et non à celle qui est déclarée au dessus et qui a la valeur 33. Dans l'instruction `let toto = (toto + 55);` l'instruction est bien remontée mais l'endroit où on utilise `toto` (dans le fragment `(toto + 55`)) est toujours dans la zone morte temporaire car `toto` n'a pas encore été affecté. ```js example-bad -function test(){ +function test() { var toto = 33; if (true) { - let toto = (toto + 55); // ReferenceError: can't access lexical declaration `toto` before initialization + let toto = toto + 55; // ReferenceError: can't access lexical declaration `toto` before initialization } } test(); @@ -290,11 +290,12 @@ Si on utilise `let` avec un nom de variable qui est le même que celui de l'argu ```js example-bad function go(n) { - for (let n of n.a){ // ReferenceError: can't access lexical declaration `n' before initialization + for (let n of n.a) { + // ReferenceError: can't access lexical declaration `n' before initialization console.log(n); } } -go({a:[1, 2, 3]}); +go({ a: [1, 2, 3] }); ``` ### Les variables déclarées avec `let` et les boucles `for` @@ -303,7 +304,7 @@ Le mot-clé `let` permet de lier des variables localement dans la portée des bo ```js var a = 0; -for ( let i = a; i < 10; i++ ) { +for (let i = a; i < 10; i++) { console.log(i); } ``` @@ -311,7 +312,7 @@ for ( let i = a; i < 10; i++ ) { #### Règles de portées ```js -for (let expr1; expr2; expr3) instruction +for (let expr1; expr2; expr3) instruction; ``` Dans cet exemple, `expr2`, `expr3`, et `instruction` sont contenues dans un bloc implicite qui contient la variable de bloc local déclarée avec `let expr1`. @@ -330,8 +331,8 @@ if (a === 5) { let a = 4; // La portée est celle du bloc if var b = 1; // La portée est celle interne à la fonction - console.log(a); // 4 - console.log(b); // 1 + console.log(a); // 4 + console.log(b); // 1 } console.log(a); // 5 @@ -343,7 +344,7 @@ console.log(b); // 1 Le mot-clé let permet de lier des variables à la portée de la boucle plutôt qu'à celle de la fonction (avec `var`) : ```js -for (let i = 0; i<10; i++) { +for (let i = 0; i < 10; i++) { console.log(i); // 0, 1, 2, 3, 4 ... 9 } diff --git a/files/fr/web/javascript/reference/statements/return/index.md b/files/fr/web/javascript/reference/statements/return/index.md index 672717e392bc6f..429ea6ee5585ee 100644 --- a/files/fr/web/javascript/reference/statements/return/index.md +++ b/files/fr/web/javascript/reference/statements/return/index.md @@ -46,7 +46,7 @@ return x + y / 3; L'instruction `return` peut être impactée par [l'ajout automatique de point-virgule (_ASI_ en anglais)](/fr/docs/Web/JavaScript/Reference/Grammaire_lexicale#Insertion_automatique_de_points-virgules). Il est interdit d'avoir un caractère de fin de ligne entre le mot-clé `return` et l'expression : ```js -return +return; a + b; ``` @@ -77,7 +77,7 @@ La fonction suivante renvoie le carré de son argument : ```js function carré(x) { - return x * x; + return x * x; } ``` @@ -87,14 +87,15 @@ Une fonction s'arrête immédiatement à l'instant où l'instruction `return` es ```js function compteur() { - for (var compte = 1; ; compte++) { // boucle infinie + for (var compte = 1; ; compte++) { + // boucle infinie console.log(compte + "A"); // jusqu'à 5 - if (compte === 5) { - return; - } - console.log(compte + "B"); // jusqu'à 4 + if (compte === 5) { + return; } - console.log(compte + "C"); // cette instruction n'est jamais utilisée + console.log(compte + "B"); // jusqu'à 4 + } + console.log(compte + "C"); // cette instruction n'est jamais utilisée } compteur(); @@ -117,7 +118,9 @@ Pour en savoir plus sur les fermetures (_closures_), voir [cet article sur les f ```js function magique() { - return function calc(x) { return x * 42 }; + return function calc(x) { + return x * 42; + }; } var réponse = magique(); diff --git a/files/fr/web/javascript/reference/statements/switch/index.md b/files/fr/web/javascript/reference/statements/switch/index.md index c88bf303627129..7d8a4d95ac69ac 100644 --- a/files/fr/web/javascript/reference/statements/switch/index.md +++ b/files/fr/web/javascript/reference/statements/switch/index.md @@ -95,22 +95,22 @@ Si on omet une instruction `break`, le script exécutera les instructions pour l ```js var toto = 0; switch (toto) { - case -1: - console.log('moins un'); - break; - case 0: // toto vaut 0 donc ce cas correspond - console.log(0); - // NOTE : le break aurait du être placé ici - case 1: // pas de break pour 'case 0:' les instructions de ce cas sont - // exécutées aussi - console.log(1); - break; // on a un break a ce niveau donc les instructions - // des cas suivants ne seront pas exécutées - case 2: - console.log(2); - break; - default: - console.log('default'); + case -1: + console.log("moins un"); + break; + case 0: // toto vaut 0 donc ce cas correspond + console.log(0); + // NOTE : le break aurait du être placé ici + case 1: // pas de break pour 'case 0:' les instructions de ce cas sont + // exécutées aussi + console.log(1); + break; // on a un break a ce niveau donc les instructions + // des cas suivants ne seront pas exécutées + case 2: + console.log(2); + break; + default: + console.log("default"); } ``` @@ -119,7 +119,7 @@ switch (toto) { Oui, il est possible de placer le cas `default` entre deux autres cas. Ainsi, si on a une valeur qui ne correspond pas aux différents cas, elle passera par le bloc `default` puis par les autres s'il n'y a pas de `break`. Par exemple : ```js -var toto = 5 +var toto = 5; switch (toto) { case 2: console.log(2); // ne sera pas exécuté @@ -128,7 +128,7 @@ switch (toto) { console.log("default"); // sera exécuté case 1: console.log("1"); // sera exécuté car il n'y a - // pas de break avant + // pas de break avant } // La console affichera "default" puis "1" ``` @@ -144,17 +144,17 @@ Cette méthode utilise le fait que s'il n'y a pas d'instruction {{jsxref("Instru On peut donc regrouper différentes valeurs les unes à la suite des autres pour exécuter des instructions pour ces valeurs : ```js -var animal = 'girafe'; +var animal = "girafe"; switch (animal) { - case 'vache': - case 'girafe': - case 'chien': - case 'cochon': - console.log('Cet animal est un mammifère'); - break; - case 'oiseau': - default: - console.log('Cet animal n\'est pas un mammifère.'); + case "vache": + case "girafe": + case "chien": + case "cochon": + console.log("Cet animal est un mammifère"); + break; + case "oiseau": + default: + console.log("Cet animal n'est pas un mammifère."); } ``` @@ -164,41 +164,41 @@ Dans l'exemple qui suit, on illustre comment exécuter une série d'instructions ```js var toto = 1; -var output = 'Résultat : '; +var output = "Résultat : "; switch (toto) { - case 0: - output += 'Donc '; - case 1: - output += 'quel '; - output += 'est '; - case 2: - output += 'votre '; - case 3: - output += 'nom '; - case 4: - output += '?'; - console.log(output); - break; - case 5: - output += '!'; - console.log(output); - break; - default: - console.log('Veuillez choisir un nombre entre 0 et 5 !'); + case 0: + output += "Donc "; + case 1: + output += "quel "; + output += "est "; + case 2: + output += "votre "; + case 3: + output += "nom "; + case 4: + output += "?"; + console.log(output); + break; + case 5: + output += "!"; + console.log(output); + break; + default: + console.log("Veuillez choisir un nombre entre 0 et 5 !"); } ``` Selon les valeurs fournies à la variable `toto`, on aura les résultats suivants : -| Valeur | Texte | -| ------------------------------------------------------------------------- | ----------------------------------------- | +| Valeur | Texte | +| ------------------------------------------------------------------ | ----------------------------------------- | | toto vaut {{jsxref("NaN")}} ou est différent de 1, 2, 3, 4, 5 ou 0 | Veuillez choisir un nombre entre 0 et 5 ! | -| 0 | Résultat : Donc quel est votre nom ? | -| 1 | Résultat : quel est votre nom ? | -| 2 | Résultat : votre nom ? | -| 3 | Résultat : nom ? | -| 4 | Résultat : ? | -| 5 | Résultat : ! | +| 0 | Résultat : Donc quel est votre nom ? | +| 1 | Résultat : quel est votre nom ? | +| 2 | Résultat : votre nom ? | +| 3 | Résultat : nom ? | +| 4 | Résultat : ? | +| 5 | Résultat : ! | ### `switch` et les variables avec une portée de bloc @@ -207,18 +207,18 @@ Avec ECMAScript 2015 (ES6), on peut utiliser les instructions [`let`](/fr/docs/W Prenons cet exemple : ```js -const action = 'dire_bonjour'; +const action = "dire_bonjour"; switch (action) { - case 'dire_bonjour': - let message = 'bonjour'; + case "dire_bonjour": + let message = "bonjour"; console.log(message); break; - case 'dire_coucou': - let message = 'coucou'; + case "dire_coucou": + let message = "coucou"; console.log(message); break; default: - console.log('Aucune action reçue.'); + console.log("Aucune action reçue."); break; } ``` @@ -230,20 +230,23 @@ Cela se produit car la première instruction `let message = 'bonjour';` entre en Pour régler ce problème, il suffit de rajouter des accolades pour définir un bloc d'instructions pour chaque `case` : ```js -const action = 'dire_bonjour'; +const action = "dire_bonjour"; switch (action) { - case 'dire_bonjour': { // accolade ajoutée - let message = 'bonjour'; + case "dire_bonjour": { + // accolade ajoutée + let message = "bonjour"; console.log(message); break; } // accolade ajoutée - case 'dire_coucou': { // accolade ajoutée - let message = 'coucou'; + case "dire_coucou": { + // accolade ajoutée + let message = "coucou"; console.log(message); break; } // accolade ajoutée - default: { // accolade ajoutée - console.log('Aucune action reçue.'); + default: { + // accolade ajoutée + console.log("Aucune action reçue."); break; } // accolade ajoutée } diff --git a/files/fr/web/javascript/reference/statements/throw/index.md b/files/fr/web/javascript/reference/statements/throw/index.md index 077a9a2ba3864a..0642a9d7f32f0d 100644 --- a/files/fr/web/javascript/reference/statements/throw/index.md +++ b/files/fr/web/javascript/reference/statements/throw/index.md @@ -25,9 +25,9 @@ L'instruction `throw` permet de lever (_throw_ en anglais) une exception. Lorsqu ```js throw "monErreur"; // génère une exception étant une chaîne de caractères -throw 42; // génère une exception ayant la valeur 42 -throw true; // génère une exception ayant la valeur true -throw new Error("Obligatoire"); // génère un objet Error avec le message "Obligatoire" +throw 42; // génère une exception ayant la valeur 42 +throw true; // génère une exception ayant la valeur true +throw new Error("Obligatoire"); // génère un objet Error avec le message "Obligatoire" ``` On notera également que l'instruction `throw` est affectée par {{jsxref("Grammaire_lexicale","l'insertion automatique de point-virgule","#Insertion_automatique_de_points-virgules",1)}} car il n'est pas permis d'avoir un caractère de fin de ligne entre le mot-clé `throw` et l'expression. @@ -40,28 +40,40 @@ Il est possible de lever une exception qui est un objet et de faire référence ```js function ExceptionUtilisateur(message) { - this.message = message; - this.name = "ExceptionUtilisateur"; + this.message = message; + this.name = "ExceptionUtilisateur"; } function getNomMois(mo) { - mo = mo-1; // Adjust month number for array index (1=Jan, 12=Dec) - var mois = ["Jan", "Fév", "Mar", "Avr", "Mai", "Juin", "Juil", - "Août", "Sept", "Oct", "Nov", "Déc"]; - if (mois[mo] !== undefined) { - return mois[mo]; - } else { - throw new ExceptionUtilisateur("Numéro de mois invalide"); - } + mo = mo - 1; // Adjust month number for array index (1=Jan, 12=Dec) + var mois = [ + "Jan", + "Fév", + "Mar", + "Avr", + "Mai", + "Juin", + "Juil", + "Août", + "Sept", + "Oct", + "Nov", + "Déc", + ]; + if (mois[mo] !== undefined) { + return mois[mo]; + } else { + throw new ExceptionUtilisateur("Numéro de mois invalide"); + } } try { - // les instructions à tenter - var monMois = 15; // 15 est en dehors des limites prévues - var nomMois = getNomMois(monMois); + // les instructions à tenter + var monMois = 15; // 15 est en dehors des limites prévues + var nomMois = getNomMois(monMois); } catch (e) { - nomMois = "unknown"; - console.error(e.message, e.name); // on passe les caractéristiques de l'exception - // à un gestionnaire d'erreur + nomMois = "unknown"; + console.error(e.message, e.name); // on passe les caractéristiques de l'exception + // à un gestionnaire d'erreur } ``` @@ -84,29 +96,29 @@ Ici, on cherche à valider une chaîne de caractères représentant un code post */ function ZipCode(zip) { - zip = new String(zip); - pattern = /[0-9]{5}([- ]?[0-9]{4})?/; - if (pattern.test(zip)) { - // la valeur du code sera la première correspondance - // dans la chaîne - this.value = zip.match(pattern)[0]; - this.valueOf = function() { - return this.value - }; - this.toString = function() { - return String(this.value) - }; - } else { - throw new ZipFormatIncorrectException(zip); - } + zip = new String(zip); + pattern = /[0-9]{5}([- ]?[0-9]{4})?/; + if (pattern.test(zip)) { + // la valeur du code sera la première correspondance + // dans la chaîne + this.value = zip.match(pattern)[0]; + this.valueOf = function () { + return this.value; + }; + this.toString = function () { + return String(this.value); + }; + } else { + throw new ZipFormatIncorrectException(zip); + } } function ZipFormatIncorrectException(value) { - this.value = value; - this.message = "le format n'est pas conforme"; - this.toString = function() { - return this.value + this.message; - }; + this.value = value; + this.message = "le format n'est pas conforme"; + this.toString = function () { + return this.value + this.message; + }; } /* @@ -118,23 +130,23 @@ const ZIPCODE_INVALID = -1; const ZIPCODE_UNKNOWN_ERROR = -2; function vérifierZipCode(z) { - try { - z = new ZipCode(z); - } catch (e) { - if (e instanceof ZipFormatIncorrectException) { - return ZIPCODE_INVALID; - } else { - return ZIPCODE_UNKNOWN_ERROR; - } - } - return z; + try { + z = new ZipCode(z); + } catch (e) { + if (e instanceof ZipFormatIncorrectException) { + return ZIPCODE_INVALID; + } else { + return ZIPCODE_UNKNOWN_ERROR; + } + } + return z; } -a = vérifierZipCode(95060); // renvoie 95060 -b = vérifierZipCode(9560); // renvoie -1 -c = vérifierZipCode("a"); // renvoie -1 -d = vérifierZipCode("95060"); // renvoie 95060 -e = vérifierZipCode("95060 1234"); // renvoie 95060 1234 +a = vérifierZipCode(95060); // renvoie 95060 +b = vérifierZipCode(9560); // renvoie -1 +c = vérifierZipCode("a"); // renvoie -1 +d = vérifierZipCode("95060"); // renvoie 95060 +e = vérifierZipCode("95060 1234"); // renvoie 95060 1234 ``` ### Propager une exception @@ -143,14 +155,14 @@ L'instruction `throw` peut être utilisée pour transmettre une exception qui au ```js try { - throw n; // lève une exception avec une valeur numérique + throw n; // lève une exception avec une valeur numérique } catch (e) { - if (e <= 50) { - // des instructions pour gérer les cas entre 1 et 50 - } else { - // ce cas ne peut pas être géré maintenant, on transmet l'exception - throw e; - } + if (e <= 50) { + // des instructions pour gérer les cas entre 1 et 50 + } else { + // ce cas ne peut pas être géré maintenant, on transmet l'exception + throw e; + } } ``` diff --git a/files/fr/web/javascript/reference/statements/try...catch/index.md b/files/fr/web/javascript/reference/statements/try...catch/index.md index 24973df9bf3773..d4495773013ff6 100644 --- a/files/fr/web/javascript/reference/statements/try...catch/index.md +++ b/files/fr/web/javascript/reference/statements/try...catch/index.md @@ -61,13 +61,12 @@ Lorsqu'une seule clause `catch` inconditionnelle est utilisée, le bloc `catch` ```js try { - throw "monException"; // génère une exception -} -catch (e) { - // les instructions utilisées pour gérer les - // exceptions - logErreurs(e); // on transfère l'objet de l'exception à une méthode - // gestionnaire + throw "monException"; // génère une exception +} catch (e) { + // les instructions utilisées pour gérer les + // exceptions + logErreurs(e); // on transfère l'objet de l'exception à une méthode + // gestionnaire } ``` @@ -99,17 +98,17 @@ Dans le fragment de code qui suit, on aura le même fonctionnement mais en utili ```js try { - maRoutine(); // may throw three types of exceptions + maRoutine(); // may throw three types of exceptions } catch (e) { - if (e instanceof TypeError) { - // les instructions pour gérer TypeError - } else if (e instanceof RangeError) { - // les instructions pour gérer RangeError - } else if (e instanceof EvalError) { - // les instructions pour gérer EvalError - } else { - // les instructions pour gérer les autres exceptions - } + if (e instanceof TypeError) { + // les instructions pour gérer TypeError + } else if (e instanceof RangeError) { + // les instructions pour gérer RangeError + } else if (e instanceof EvalError) { + // les instructions pour gérer EvalError + } else { + // les instructions pour gérer les autres exceptions + } } ``` @@ -118,7 +117,7 @@ try { Lorsqu'une exception est levée dans le bloc `try`, `exception_var` (par exemple le `e` dans « `catch (e)` ») contient la valeur définie par l'instruction {{jsxref("Instructions/throw","throw")}}. Cet identifiant peut être utilisé pour accéder aux propriétés de l'objet et ainsi obtenir des informations sur l'exception qui a eu lieu. Cet identifiant est local à la clause `catch`, il est créé lorsqu'on rentre dans la clause `catch` et n'est plus disponible une fois que la clause a fini son exécution. ```js -function isValidJSON(txt){ +function isValidJSON(txt) { try { JSON.parse(txt); return true; @@ -137,13 +136,12 @@ Cela peut paraître étrange qu'un bloc de code qui s'exécute même lorsqu'il y La clause `finally` peut être utilisée afin d'exécuter les actions nécessaires pour que le script « échoue correctement » en cas d'erreur. On peut par exemple tirer parti de `finally` pour fermer un flux, libérer une ressource, etc. Dans l'exemple suivant, exécuté côté serveur, le script accède à un fichier. Si une exception se produit lorsque le fichier est ouvert, la clause `finally` permet de fermer le fichier avant que le script échoue. Le code contenu dans le bloc `finally` sera exécuté même si on a une instruction `return` dans la section `try` ou dans la section `catch`. ```js -ouvrirMonFichier() +ouvrirMonFichier(); try { - // on utilise une ressource - écrireDansMonFichier(mesDonnées); -} -finally { - fermerMonFichier(); // on ferme toujours la ressource + // on utilise une ressource + écrireDansMonFichier(mesDonnées); +} finally { + fermerMonFichier(); // on ferme toujours la ressource } ``` @@ -157,12 +155,10 @@ Tout d'abord, on utilise ce fragment de code, qui produit le résultat suivant : try { try { throw new Error("oups"); - } - finally { + } finally { console.log("finally"); } -} -catch (ex) { +} catch (ex) { console.error("externe", ex.message); } @@ -177,15 +173,12 @@ Et maintenant, si on a déjà intercepté l'exception avec une clause `catch` da try { try { throw new Error("oups"); - } - catch (ex) { + } catch (ex) { console.error("interne", ex.message); - } - finally { + } finally { console.log("finally"); } -} -catch (ex) { +} catch (ex) { console.error("externe", ex.message); } @@ -200,16 +193,13 @@ Ensuite, si on propage l'erreur à nouveau : try { try { throw new Error("oups"); - } - catch (ex) { + } catch (ex) { console.error("interne", ex.message); throw ex; - } - finally { + } finally { console.log("finally"); } -} -catch (ex) { +} catch (ex) { console.error("externe", ex.message); } @@ -229,17 +219,14 @@ Lorsque le bloc `finally` renvoie une valeur, c'est cette valeur qui devient la try { try { throw new Error("oups"); - } - catch (ex) { + } catch (ex) { console.error("interne", ex.message); throw ex; - } - finally { + } finally { console.log("finally"); return; } -} -catch (ex) { +} catch (ex) { console.error("externe", ex.message); } diff --git a/files/fr/web/javascript/reference/statements/var/index.md b/files/fr/web/javascript/reference/statements/var/index.md index d2d718d7901013..c6c501def11892 100644 --- a/files/fr/web/javascript/reference/statements/var/index.md +++ b/files/fr/web/javascript/reference/statements/var/index.md @@ -29,44 +29,44 @@ Si on affecte une valeur à une variable qui n'a pas été déclarée (le mot-cl 1. Les variables déclarées sont contraintes dans le contexte d'exécution dans lequel elles sont déclarées. Les variables non-déclarées sont toujours globales. - ```js - function x() { - y = 1; // Lève une exception ReferenceError en mode strict - var z = 2; - } + ```js + function x() { + y = 1; // Lève une exception ReferenceError en mode strict + var z = 2; + } - x(); + x(); - console.log(y); // Affiche "1" dans la console - console.log(z); // Lève une exception ReferenceError: - // z n'est pas définie en dehors de x - ``` + console.log(y); // Affiche "1" dans la console + console.log(z); // Lève une exception ReferenceError: + // z n'est pas définie en dehors de x + ``` 2. Les variables déclarées sont créées avant que n'importe quel autre code soit exécuté. Les variables non-déclarées n'existent pas tant que leur code n'est pas exécuté. - ```js - console.log(a); // Lève une exception ReferenceError. - console.log('on continue...'); // N'est jamais exécuté - ``` + ```js + console.log(a); // Lève une exception ReferenceError. + console.log("on continue..."); // N'est jamais exécuté + ``` - ```js - var a; - console.log(a); // Affiche "undefined". - console.log('on continue...'); // Affiche "on continue...". - ``` + ```js + var a; + console.log(a); // Affiche "undefined". + console.log("on continue..."); // Affiche "on continue...". + ``` 3. Les variables déclarées sont des propriétés non-configurables de leur contexte d'exécution (la fonction courante ou le contexte global). Les variables non-déclarées sont configurables (ce qui signifie qu'elles peuvent être supprimées). - ```js - var a = 1; - b = 2; + ```js + var a = 1; + b = 2; - delete this.a; // Lève une TypeError en mode strict. Échoue silencieusement sinon. - delete this.b; + delete this.a; // Lève une TypeError en mode strict. Échoue silencieusement sinon. + delete this.b; - console.log(a, b); // Lève une exception ReferenceError. - // La propriété 'b' a été supprimée et n'existe plus. - ``` + console.log(a, b); // Lève une exception ReferenceError. + // La propriété 'b' a été supprimée et n'existe plus. + ``` En raison de ces trois différences, il faut éviter de ne pas déclarer une variable car cela peut provoquer des résultats inattendus. **Il est donc fortement recommandé de toujours déclarer les variables, qu'elles soient dans une fonction ou dans la portée globale.** Le [mode strict](/fr/docs/Web/JavaScript/Reference/Strict_mode), introduit avec ECMAScript 5, lève une exception lorsqu'une variable n'est pas déclarée. @@ -75,7 +75,7 @@ En raison de ces trois différences, il faut éviter de ne pas déclarer une var Les déclarations de variables (et les déclarations en général) sont traitées avant que n'importe quel autre code soit exécuté. Ainsi, déclarer une variable n'importe où dans le code équivaut à la déclarer au début de son contexte d'exécution. Cela signifie qu'une variable peut également apparaître dans le code avant d'avoir été déclarée. Ce comportement est appelé « remontée » (_hoisting_ en anglais) car la déclaration de la variable est « remontée » au début de la fonction courante ou du contexte global. ```js -bla = 2 +bla = 2; var bla; // ... @@ -110,7 +110,8 @@ function faireQuelqueChose() { ### Déclarer et initialiser deux variables ```js -var a = 0, b = 0; +var a = 0, + b = 0; ``` ### Affecter deux variables avec la même chaîne de caractères @@ -121,13 +122,15 @@ var b = a; // est équivalent à : -var a, b = a = "A"; +var a, + b = (a = "A"); ``` Attention à l'ordre : ```js -var x = y, y = 'A'; +var x = y, + y = "A"; console.log(x + y); // undefinedA ``` @@ -138,9 +141,9 @@ Ici, `x` et `y` sont déclarées avant que n'importe quel code soit exécuté, * ```js var x = 0; // Variable dans la portée globale (le fichier) -function f(){ - var x = y = 1; // x est déclaré localement - // ce qui n'est pas le cas de y ! +function f() { + var x = (y = 1); // x est déclaré localement + // ce qui n'est pas le cas de y ! } f(); @@ -156,31 +159,31 @@ console.log(x, y); // 0, 1 Il est possible de faire référence à des variables qui sont des variables globales implicites depuis la portée d'une fonction externe : ```js -var x = 0; // Déclare x comme variable globale du fichier, on lui affecte 0 +var x = 0; // Déclare x comme variable globale du fichier, on lui affecte 0 console.log(typeof z); // "undefined", car z n'existe pas encore function a() { - var y = 2; // Déclare y dans la portée de la fonction a - // Affecte 2 comme valeur à y + var y = 2; // Déclare y dans la portée de la fonction a + // Affecte 2 comme valeur à y - console.log(x, y); // 0 2 + console.log(x, y); // 0 2 function b() { - x = 3; // Affecte 3 à la variable globale x - // Ne crée pas une nouvelle variable globale - y = 4; // Affecte 4 à la variable externe y, - // Ne crée pas une nouvelle variable globale - z = 5; // Crée une nouvelle variable globale - // et lui affecte la valeur 5. - } // (lève une ReferenceError en mode strict.) - - b(); // Crée z en tant que variable globale - console.log(x, y, z); // 3 4 5 + x = 3; // Affecte 3 à la variable globale x + // Ne crée pas une nouvelle variable globale + y = 4; // Affecte 4 à la variable externe y, + // Ne crée pas une nouvelle variable globale + z = 5; // Crée une nouvelle variable globale + // et lui affecte la valeur 5. + } // (lève une ReferenceError en mode strict.) + + b(); // Crée z en tant que variable globale + console.log(x, y, z); // 3 4 5 } -a(); // l'appel à a() entraîne un appel à b() -console.log(x, z); // 3 5 +a(); // l'appel à a() entraîne un appel à b() +console.log(x, z); // 3 5 console.log(typeof y); // "undefined" car y est local à la fonction a ``` diff --git a/files/fr/web/javascript/reference/statements/while/index.md b/files/fr/web/javascript/reference/statements/while/index.md index b795d1f2fd4f97..17c7b7a18d16f8 100644 --- a/files/fr/web/javascript/reference/statements/while/index.md +++ b/files/fr/web/javascript/reference/statements/while/index.md @@ -55,9 +55,9 @@ Dans la fonction qui suit, on incrémente un compteur grâce à une boucle `whil ```js const maFonctionAvecWhile = () => { let i = 0; - while (i< 20){ + while (i < 20) { i++; - }; + } console.log(i); }; ``` @@ -75,7 +75,7 @@ Par exemple, le fragment qui suit causera une boucle infinie : ```js example-bad const seuil = 14; let compteur = 0; -while (compteur = seuil) { +while ((compteur = seuil)) { compteur++; /* Faire quelque chose avec compteur */ } diff --git a/files/fr/web/javascript/reference/statements/with/index.md b/files/fr/web/javascript/reference/statements/with/index.md index abcb568d2a9543..12d862a669666a 100644 --- a/files/fr/web/javascript/reference/statements/with/index.md +++ b/files/fr/web/javascript/reference/statements/with/index.md @@ -14,7 +14,7 @@ L'instruction **`with`** permet d'étendre la portée chaînée d'une instructio ```js with (expression) { - instruction + instruction; } ``` @@ -39,23 +39,22 @@ Dès qu'un nom non-qualifié est utilisé, JavaScript cherche dans la chaîne de - **Inconvénient :** l'instruction `with` peut rendre plus compliquée, que ce soit pour un humain ou un compilateur, la recherche d'un nom non-qualifié le long de la chaîne des portées. Ainsi, avec cet exemple : ```js - function f(x, o) { - with (o) - console.log(x); - } - ``` + function f(x, o) { + with (o) console.log(x); + } + ``` ce n'est que quand `f` est appelée que `x` est trouvé ou non, s'il est trouvé à partir de `o` ou (si o n'a pas de telle propriété) dans l'objet d'activation de `f` où `x` représente le premier argument de la fonction. Si `x` n'est pas défini dans l'objet passé en second argument, il n'y aura pas d'erreur renvoyée, juste des résultats imprévus. - **Inconvénient :** Du code utilisant l'instruction `with` pourrait ne pas être compatible dans le futur, en particulier lorsqu'il est utilisé avec autre chose qu'un objet simple. Par exemple : ```js - function f(toto, values) { - with (toto) { - console.log(values) - } + function f(toto, values) { + with (toto) { + console.log(values); } - ``` + } + ``` Si vous appelez `f([1,2,3], obj)` dans un environnement ECMAScript 5, la référence à `values` à l'intérieur de l'instruction `with` sera liée avec `obj`. Cependant, ECMAScript 2015 (ES6) a introduit une propriété `values` pour {{jsxref("Array.prototype")}} (afin qu'elle soit disponible pour chaque tableau). Dans un environnement ECMAScript 2015, la référence à `values` utilisée à l'intérieur de l'instruction `with` sera résolue avec `[1,2,3].values`. diff --git a/files/fr/web/javascript/reference/strict_mode/index.md b/files/fr/web/javascript/reference/strict_mode/index.md index 197b28bd684f1f..20b7f2dd11d77d 100644 --- a/files/fr/web/javascript/reference/strict_mode/index.md +++ b/files/fr/web/javascript/reference/strict_mode/index.md @@ -43,11 +43,15 @@ De même, pour activer le mode strict pour une fonction, on placera l'instructio ```js function strict() { // Syntaxe en mode strict au niveau de la fonction - 'use strict'; - function nested() { return "Ho que oui, je le suis !"; } + "use strict"; + function nested() { + return "Ho que oui, je le suis !"; + } return "Allô ! Je suis une fonction en mode strict ! " + nested(); } -function notStrict() { return "Je ne suis pas strict."; } +function notStrict() { + return "Je ne suis pas strict."; +} ``` ### Mode strict pour les modules @@ -83,8 +87,8 @@ Deuxièmement, le mode strict fait en sorte que les affectations qui échoueraie "use strict"; // Affectation à une propriété globale en lecture seule -var undefined = 5; // déclenche une exception TypeError -var Infinity = 5; // déclenche une exception TypeError +var undefined = 5; // déclenche une exception TypeError +var Infinity = 5; // déclenche une exception TypeError // Affectation à une propriété en lecture seule var obj1 = {}; @@ -92,11 +96,15 @@ Object.defineProperty(obj1, "x", { value: 42, writable: false }); obj1.x = 9; // lève un TypeError // Affectation à une propriété qui n'a qu'une méthode get -var obj2 = { get x() { return 17; } }; +var obj2 = { + get x() { + return 17; + }, +}; obj2.x = 5; // lève un TypeError // Affectation d'une nouvelle propriété à un objet non-extensible -var gele= {}; +var gele = {}; Object.preventExtensions(gele); gele.nouvelleProp = "ohé"; // lève un TypeError ``` @@ -120,7 +128,8 @@ var o = { p: 1, p: 2 }; // !!! erreur de syntaxe Cinquièmement, le mode strict requiert que les noms de paramètres de fonction soient uniques. En mode non-strict, le dernier argument dupliqué cache les arguments précédents ayant le même nom. Ces arguments précédents demeurent disponibles via `arguments[i]`, ils ne sont donc pas complètement inaccessibles. Pourtant, cette cachette n'a guère de sens et n'est probablement pas souhaitable (cela pourrait cacher une faute de frappe, par exemple). Donc en mode strict, les doublons de noms d'arguments sont une erreur de syntaxe : ```js -function somme(a, a, c) { // !!! erreur de syntaxe +function somme(a, a, c) { + // !!! erreur de syntaxe "use strict"; return a + b + c; // Ce code va planter s'il est exécuté } @@ -136,21 +145,21 @@ Les développeurs novices croient parfois qu'un zéro débutant un nombre n'a pa ```js "use strict"; -var somme = 015 + // !!! erreur de syntaxe - 197 + - 142; +var somme = + 015 + // !!! erreur de syntaxe + 197 + + 142; ``` Septièmement, le mode strict, à partir d'ECMAScript 2015 interdit de définir des propriétés sur des valeurs primitives. Sans mode strict, de telles définitions sont ignorées. En activant le mode strict cela lèvera une exception {{jsxref("TypeError")}}. ```js -(function() { -"use strict"; - -false.true = ""; // TypeError -(14).calvados= "maison"; // TypeError -"une chaîne".de = "caractères"; // TypeError +(function () { + "use strict"; + false.true = ""; // TypeError + (14).calvados = "maison"; // TypeError + "une chaîne".de = "caractères"; // TypeError })(); ``` @@ -163,8 +172,7 @@ Premièrement, le mode strict interdit l'utilisation de `with`. Le problème ave ```js "use strict"; var x = 17; -with (obj) // !!! erreur de syntaxe -{ +with (obj) { // !!! erreur de syntaxe // Si on n'était pas en mode strict, serait-ce var x, // ou serait-ce plutôt obj.x? Il est impossible en général // de le dire sans faire tourner le code, donc @@ -227,12 +235,13 @@ Premièrement, les chaînes `eval` et `arguments` ne peuvent pas être utilisée eval = 17; arguments++; ++eval; -var obj = { set p(arguments) { } }; +var obj = { set p(arguments) {} }; var eval; -try { } catch (arguments) { } -function x(eval) { } -function arguments() { } -var y = function eval() { }; +try { +} catch (arguments) {} +function x(eval) {} +function arguments() {} +var y = function eval() {}; var f = new Function("arguments", "'use strict'; return 17;"); ``` @@ -253,7 +262,9 @@ Troisièmement, `arguments.callee` n'est plus supporté. En temps normal `argume ```js "use strict"; -var f = function() { return arguments.callee; }; +var f = function () { + return arguments.callee; +}; f(); // lève une TypeError ``` @@ -265,7 +276,9 @@ Tout d'abord, la valeur passée en tant que `this` à une fonction n'est pas né ```js "use strict"; -function fun() { return this; } +function fun() { + return this; +} console.log(fun() === undefined); console.log(fun.call(2) === 2); console.log(fun.apply(null) === null); @@ -278,14 +291,12 @@ Cela signifie entre autres qu'il est impossible de faire référence à l'objet Ensuite, en mode strict, il n'est plus possible de remonter la pile d'appels grâce aux extensions communément implémentées. Par exemple, dans du code non strict, lorsqu'une fonction `fun` est en train d'être appelée, `fun.caller` fait référence à la fonction qui a appelé `fun` la dernière et `fun.arguments` correspond à l'objet `arguments` pour cet appel à `fun`. Ces deux extensions posent problème pour la sécurité car elles permettent au code d'accéder à des fonctions privilégiées et à leurs arguments (éventuellement non sécurisés). Si `fun` est passée en mode strict, `fun.caller` et `fun.arguments` seront des propriétés non-supprimables qui lèveront une exception pour chaque tentative d'accès ou de modification : ```js -function restricted() -{ +function restricted() { "use strict"; - restricted.caller; // lève une TypeError + restricted.caller; // lève une TypeError restricted.arguments; // lève une TypeError } -function privilegedInvoker() -{ +function privilegedInvoker() { return restricted(); } privilegedInvoker(); @@ -295,8 +306,7 @@ Enfin, pour une fonction en mode strict, `arguments` ne permet pas d'accéder au ```js "use strict"; -function fun(a, b) -{ +function fun(a, b) { "use strict"; var v = 12; return arguments.caller; // lève une TypeError @@ -311,18 +321,21 @@ Les prochaines versions d'ECMAScript inclueront certainement une nouvelle syntax Premièrement, en mode strict, une liste d'identifiants fait partie des mots-clés réservés. Ces termes sont : `implements`, `interface`, `let`, `package`, `private`, `protected`, `public`, `static`, et `yield`. En mode strict, il est donc impossible de nommer des variables ou des arguments avec ces noms. ```js -function package(protected) { // !!! +function package(protected) { + // !!! "use strict"; var implements; // !!! - interface: // !!! - while (true) { + // !!! + interface: while (true) { break interface; // !!! } - function private() { } // !!! + function private() {} // !!! } -function fun(static) { 'use strict'; } // !!! +function fun(static) { + "use strict"; +} // !!! ``` Deux défauts liés à Mozilla Firefox : tout d'abord si votre code est en JavaScript 1.7 ou supérieur (par exemple pour du code qui concerne le chrome dans les extensions ou lorsqu'on utilise les balises ``, on ne pourra pas utiliser `let`/`yield` comme identifiants. Ensuite, bien qu'ES5 réserve les mots-clés `class`, `enum`, `export`, `extends`, `import`, et `super` pour le mode strict et le mode non strict, les versions antérieures à Firefox 5 ne réservaient ces mots-clés que pour le mode strict. @@ -332,17 +345,18 @@ Deuxièmement, [le mode strict interdit les déclarations de fonctions qui ne so ```js "use strict"; if (true) { - function f() { } // !!! erreur de syntaxe + function f() {} // !!! erreur de syntaxe f(); } for (var i = 0; i < 5; i++) { - function f2() { } // !!! erreur de syntaxe + function f2() {} // !!! erreur de syntaxe f2(); } -function truc() { // OK - function bidule() { } // OK également +function truc() { + // OK + function bidule() {} // OK également } ``` diff --git a/files/fr/web/javascript/reference/template_literals/index.md b/files/fr/web/javascript/reference/template_literals/index.md index c829ab34c6d965..e98d1419c6069d 100644 --- a/files/fr/web/javascript/reference/template_literals/index.md +++ b/files/fr/web/javascript/reference/template_literals/index.md @@ -13,14 +13,10 @@ Les littéraux de gabarits sont des littéraux de chaînes de caractères permet ## Syntaxe ```js -`texte` +`texte``ligne de texte 1 + ligne de texte 2``texte ${expression} texte`; -`ligne de texte 1 - ligne de texte 2` - -`texte ${expression} texte` - -etiquette `texte ${expression} texte` +etiquette`texte ${expression} texte`; ``` ## Description @@ -33,9 +29,9 @@ Pour créer la chaîne finale, la fonction par défaut concatène simplement les let rep = 42; console.log(`La réponse est ${rep}`); // Gabarit simple avec la concaténation par défaut -function concatenationAdHoc(chaines, reponse){ +function concatenationAdHoc(chaines, reponse) { let parite; - if(reponse % 2 === 0){ + if (reponse % 2 === 0) { parite = "paire"; } else { parite = "impaire"; @@ -57,8 +53,7 @@ Pour utiliser des accents graves dans un gabarit, on les échappera avec une bar Tous les caractères de saut de ligne insérés dans la source font partie du gabarit. Avec des chaînes de caractères normales, il aurait fallu utiliser la syntaxe suivante pour obtenir des chaînes multi-lignes : ```js -console.log('ligne de texte 1\n'+ -'ligne de texte 2'); +console.log("ligne de texte 1\n" + "ligne de texte 2"); // "ligne de texte 1 // ligne de texte 2" ``` @@ -79,7 +74,7 @@ Pour intégrer des expressions dans des chaînes de caractères normales, il fal ```js let a = 5; let b = 10; -console.log('Quinze vaut ' + (a + b) + ' et\nnon ' + (2 * a + b) + '.'); +console.log("Quinze vaut " + (a + b) + " et\nnon " + (2 * a + b) + "."); // "Quinze vaut 15 et // non 20." ``` @@ -102,24 +97,28 @@ Parfois, l'imbrication d'un gabarit est la solution la plus simple (et peut-êtr En ES5 : ```js -let classes = 'header' -classes += (isLargeScreen() ? - '' : item.isCollapsed ? - ' icon-expander' : ' icon-collapser'); +let classes = "header"; +classes += isLargeScreen() + ? "" + : item.isCollapsed + ? " icon-expander" + : " icon-collapser"; ``` En ES2015 avec des gabarits et sans imbrication : ```js -const classes = `header ${ isLargeScreen() ? '' : - (item.isCollapsed ? 'icon-expander' : 'icon-collapser') }`; +const classes = `header ${ + isLargeScreen() ? "" : item.isCollapsed ? "icon-expander" : "icon-collapser" +}`; ``` En ES2015 avec des gabarits imbriqués : ```js -const classes = `header ${ isLargeScreen() ? '' : - `icon-${item.isCollapsed ? 'expander' : 'collapser'}` }`; +const classes = `header ${ + isLargeScreen() ? "" : `icon-${item.isCollapsed ? "expander" : "collapser"}` +}`; ``` ### Gabarits étiquetés @@ -127,7 +126,7 @@ const classes = `header ${ isLargeScreen() ? '' : Les _gabarits étiquetés_ (_tagged templates_) sont une forme plus avancée de gabarits. On peut ici utiliser une fonction pour analyser les différents fragments du gabarit. Le premier argument passé à la fonction est l'ensemble de valeurs issues de chaînes de caractères sous la forme d'un tableau. Les arguments ensuite passés à la fonction seront les expressions contenues dans le gabarit. La fonction pourra ainsi créer une chaîne avec une autre forme de concaténation et utiliser une logique spécifique. La fonction utilisée pour le formatage du gabarit peut être nommée comme n'importe quelle autre fonction. ```js -let personne = 'Michou'; +let personne = "Michou"; let age = 28; function monEtiquette(chaines, expPersonne, expAge) { @@ -140,17 +139,17 @@ function monEtiquette(chaines, expPersonne, expAge) { // var chn2 = chaines[2]; let chnAge; - if (expAge > 99){ - chnAge = 'centenaire'; + if (expAge > 99) { + chnAge = "centenaire"; } else { - chnAge = 'jeunot'; + chnAge = "jeunot"; } // On peut tout à fait renvoyer une chaîne construite // avec un gabarit return `${chn0}${expPersonne}${chn1}${chnAge}`; } -let sortie = monEtiquette`ce ${ personne } est un ${ age }`; +let sortie = monEtiquette`ce ${personne} est un ${age}`; console.log(sortie); // ce Michou est un jeunot @@ -173,13 +172,13 @@ etiquette`ligne de texte 1 \n ligne de texte 2`; En outre, la méthode {{jsxref("String.raw()")}} a pour fonction de créer des chaînes de caractères brutes, exactement comme la fonction de gabarit et de concaténation de chaînes par défaut le ferait : ```js -let chn = String.raw`Salut\n${2+3}!`; +let chn = String.raw`Salut\n${2 + 3}!`; // "Salut\n5!" chn.length; // 9 -chn.split('').join(','); +chn.split("").join(","); // "S,a,l,u,t,\,n,5,!" ``` @@ -197,7 +196,7 @@ Quant à ECMAScript 2016, les gabarits étiquetés se conforment aux règles de Cela signifie qu'un gabarit étiqueté comme celui qui suit pose problème du fait que, selon la grammaire ECMAScript, un analyseur recherchera des séquences d'échappement Unicode valides, mais trouvera la syntaxe mal formée : ```js -latex`\unicode` +latex`\unicode`; // Génère, dans les anciennes versions ECMAScript (ES2016 et précédentes) // SyntaxError: malformed Unicode character escape sequence ``` @@ -210,15 +209,15 @@ Toutefois, les séquences d'échappement illégales doivent toujours être repr ```js function latex(chn) { - return { "bidouillee": chn[0], "brute": chn.raw[0] } + return { bidouillee: chn[0], brute: chn.raw[0] }; } -latex`\unicode` +latex`\unicode`; // { bidouillee: undefined, brute: "\\unicode" } ``` -Notez que la restriction sur les séquences d'échappement est uniquement supprimée pour les gabarits _étiquetés_, et non pour les gabarits de libellés *non étiquetés* : +Notez que la restriction sur les séquences d'échappement est uniquement supprimée pour les gabarits _étiquetés_, et non pour les gabarits de libellés _non étiquetés_ : ```js example-bad let mauvaise = `mauvaise séquence d'échappement : \unicode`; diff --git a/files/fr/web/javascript/reference/trailing_commas/index.md b/files/fr/web/javascript/reference/trailing_commas/index.md index e52e9b1fed581e..8610b83a900dfa 100644 --- a/files/fr/web/javascript/reference/trailing_commas/index.md +++ b/files/fr/web/javascript/reference/trailing_commas/index.md @@ -19,11 +19,7 @@ Les virgules finales peuvent être utilisées dans les littéraux de tableau dep JavaScript ignore les virgules finales dans les tableaux : ```js -var arr = [ - 1, - 2, - 3, -]; +var arr = [1, 2, 3]; arr; // [1, 2, 3] arr.length; // 3 @@ -32,7 +28,7 @@ arr.length; // 3 Si plusieurs virgules finales sont utilisées, cela crée un vide dans le tableau. Un tableau avec des vides est parfois qualifié de _parsemé_ (ou _sparse_ en anglais). Lorsqu'on parcourt un tableau avec les méthodes {{jsxref("Array.prototype.forEach()")}} ou {{jsxref("Array.prototype.map()")}}, par exemple, ces vides sont ignorés. ```js -var arr = [1, 2, 3,,,]; +var arr = [1, 2, 3, , ,]; arr.length; // 5 ``` @@ -58,10 +54,10 @@ Pour chacune des deux paires de définitions qui suivent, les deux définitions ```js function f(p) {} -function f(p,) {} +function f(p) {} (p) => {}; -(p,) => {}; +(p) => {}; ``` Les virgules finales peuvent également être utilisées lors [des définitions de méthodes](/fr/docs/Web/JavaScript/Reference/Fonctions/Définition_de_méthode) dans les objets et les classes : @@ -84,10 +80,10 @@ Pour chacune des deux paires d'appels qui suivent, les deux appels sont équival ```js f(p); -f(p,); +f(p); Math.max(10, 20); -Math.max(10, 20,); +Math.max(10, 20); ``` ### Virgules finales non-autorisées @@ -110,7 +106,7 @@ On peut aussi utiliser une virgule finale dans l'opérande gauche lorsqu'on util ```js // Décomposition d'un tableau avec // une virgule finale -[a, b,] = [1, 2]; +[a, b] = [1, 2]; // Décomposition d'un objet avec une // virgule finale @@ -118,13 +114,13 @@ var o = { p: 42, q: true, }; -var {p, q,} = o; +var { p, q } = o; ``` Là encore, si on utilise un élément du reste, une exception {{jsxref("SyntaxError")}} sera levée : ```js example-bad -var [a, ...b,] = [1, 2, 3]; +var [a, ...b] = [1, 2, 3]; // SyntaxError: rest element may not have a trailing comma ``` @@ -135,7 +131,7 @@ L'utilisation des virgules finales dans les objets a été introduite avec ECMAS Les deux lignes suivantes lèveront une exception {{jsxref("SyntaxError")}} : ```js example-bad -JSON.parse('[1, 2, 3, 4, ]'); +JSON.parse("[1, 2, 3, 4, ]"); JSON.parse('{"foo" : 1, }'); // SyntaxError JSON.parse: unexpected character // at line 1 column 14 of the JSON data @@ -144,7 +140,7 @@ JSON.parse('{"foo" : 1, }'); Pour analyser le JSON correctement, on évitera les virgules finales : ```js example-good -JSON.parse('[1, 2, 3, 4 ]'); +JSON.parse("[1, 2, 3, 4 ]"); JSON.parse('{"foo" : 1 }'); ``` From 5ffbcae2df66184f8a2a5991f4f168acf47ca266 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 01:56:41 -0700 Subject: [PATCH 15/30] fr: Format /web/javascript using Prettier (part 6) (#14644) --- .../global_objects/intl/listformat/listformat/index.md | 6 +++--- .../global_objects/intl/numberformat/numberformat/index.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/files/fr/web/javascript/reference/global_objects/intl/listformat/listformat/index.md b/files/fr/web/javascript/reference/global_objects/intl/listformat/listformat/index.md index 6400b218131a28..49c7d80644ba80 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/listformat/listformat/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/listformat/listformat/index.md @@ -26,11 +26,11 @@ new Intl.ListFormat(locales, options); - : Un objet avec une ou plusieurs des propriétés suivantes : - `localeMatcher` - - : - : L'algorithme de correspondance des locales à utiliser. Les valeurs possibles sont "`lookup`" et "`best fit`" ; la valeur par défaut est "`best fit`". Pour plus d'information, voir la page [`Intl`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Intl#négociation_de_la_locale). + - : L'algorithme de correspondance des locales à utiliser. Les valeurs possibles sont "`lookup`" et "`best fit`" ; la valeur par défaut est "`best fit`". Pour plus d'information, voir la page [`Intl`](/fr/docs/Web/JavaScript/Reference/Global_Objects/Intl#négociation_de_la_locale). - `type` - : Le format de sortie produit. Les valeurs possibles sont "`conjunction`" qui indique une liste additive (par exemple "`A, B, et C`"), c'est la valeur par défaut, ou "`disjunction`" qui indique une liste d'options distinctes (par exemple, "`A, B, ou C`"), ou "`unit`" qui indique une liste de valeurs avec des unités (par exemple, "`5 kg, 12 L`"). - - `style` - : La longueur du message formaté. Les valeurs possibles sont "`long`", la valeur par défaut (par exemple "`A, B, et C`") ; "`short`" (par exemple - "`A, B, C`"), ou "`narrow`" (par exemple, "`A B C`"). Lorsque la valeur de `style` est "`short`" ou "`narrow`", seule la valeur "`unit`" est autorisée pour l'option "type". + - `style` + - : La longueur du message formaté. Les valeurs possibles sont "`long`", la valeur par défaut (par exemple "`A, B, et C`") ; "`short`" (par exemple "`A, B, C`"), ou "`narrow`" (par exemple, "`A B C`"). Lorsque la valeur de `style` est "`short`" ou "`narrow`", seule la valeur "`unit`" est autorisée pour l'option "type". ## Exemples diff --git a/files/fr/web/javascript/reference/global_objects/intl/numberformat/numberformat/index.md b/files/fr/web/javascript/reference/global_objects/intl/numberformat/numberformat/index.md index 686fa81bc3b1e3..b024c4693cfd60 100644 --- a/files/fr/web/javascript/reference/global_objects/intl/numberformat/numberformat/index.md +++ b/files/fr/web/javascript/reference/global_objects/intl/numberformat/numberformat/index.md @@ -167,7 +167,7 @@ new Intl.NumberFormat("fr", { currency: "EUR", currencySign: "accounting", }).format(amount); -// → "(3 500,00 €)" +// → "(3 500,00 €)" ``` ### Notations scientifique, ingénieur et compacte From 056ff8b6757352ae9e32fc9e0a72695db1b1fd01 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 02:08:48 -0700 Subject: [PATCH 16/30] zh-cn: Format /web/http using Prettier (#14670) --- .prettierignore | 1 - .../basics_of_http/evolution_of_http/index.md | 6 +- .../identifying_resources_on_the_web/index.md | 22 ++--- .../http/basics_of_http/mime_types/index.md | 6 +- .../index.md | 2 +- files/zh-cn/web/http/caching/index.md | 2 +- files/zh-cn/web/http/compression/index.md | 4 +- .../index.md | 4 +- .../web/http/content_negotiation/index.md | 4 +- .../list_of_default_accept_values/index.md | 8 +- files/zh-cn/web/http/cookies/index.md | 4 +- files/zh-cn/web/http/cors/index.md | 12 +-- files/zh-cn/web/http/csp/index.md | 2 +- .../http/headers/accept-ch-lifetime/index.md | 6 +- .../zh-cn/web/http/headers/accept-ch/index.md | 6 +- .../web/http/headers/accept-charset/index.md | 6 +- .../web/http/headers/accept-encoding/index.md | 6 +- .../web/http/headers/accept-language/index.md | 8 +- .../web/http/headers/accept-patch/index.md | 6 +- .../web/http/headers/accept-ranges/index.md | 8 +- files/zh-cn/web/http/headers/accept/index.md | 8 +- .../access-control-allow-credentials/index.md | 12 +-- .../access-control-allow-headers/index.md | 6 +- .../access-control-allow-methods/index.md | 6 +- .../access-control-allow-origin/index.md | 1 + .../headers/access-control-max-age/index.md | 6 +- .../access-control-request-headers/index.md | 6 +- .../access-control-request-method/index.md | 6 +- files/zh-cn/web/http/headers/age/index.md | 6 +- files/zh-cn/web/http/headers/allow/index.md | 6 +- .../web/http/headers/authorization/index.md | 2 +- .../web/http/headers/cache-control/index.md | 8 +- .../web/http/headers/clear-site-data/index.md | 8 +- .../web/http/headers/connection/index.md | 6 +- .../http/headers/content-disposition/index.md | 2 + .../http/headers/content-language/index.md | 14 +-- .../web/http/headers/content-length/index.md | 6 +- .../http/headers/content-location/index.md | 6 +- .../web/http/headers/content-range/index.md | 8 +- .../index.md | 4 +- .../content-security-policy/base-uri/index.md | 12 +-- .../block-all-mixed-content/index.md | 2 +- .../child-src/index.md | 2 +- .../connect-src/index.md | 5 +- .../default-src/index.md | 10 +- .../content-security-policy/font-src/index.md | 2 +- .../form-action/index.md | 21 ++-- .../frame-ancestors/index.md | 2 + .../headers/content-security-policy/index.md | 7 +- .../content-security-policy/sandbox/index.md | 2 +- .../script-src-elem/index.md | 2 +- .../upgrade-insecure-requests/index.md | 10 +- .../worker-src/index.md | 2 +- .../web/http/headers/content-type/index.md | 12 +-- .../cross-origin-embedder-policy/index.md | 8 +- .../cross-origin-resource-policy/index.md | 6 +- files/zh-cn/web/http/headers/date/index.md | 6 +- .../web/http/headers/device-memory/index.md | 6 +- files/zh-cn/web/http/headers/digest/index.md | 6 +- files/zh-cn/web/http/headers/dnt/index.md | 6 +- files/zh-cn/web/http/headers/dpr/index.md | 6 +- .../web/http/headers/early-data/index.md | 6 +- files/zh-cn/web/http/headers/etag/index.md | 6 +- .../zh-cn/web/http/headers/expect-ct/index.md | 5 + files/zh-cn/web/http/headers/expect/index.md | 6 +- files/zh-cn/web/http/headers/expires/index.md | 8 +- .../zh-cn/web/http/headers/forwarded/index.md | 8 +- files/zh-cn/web/http/headers/from/index.md | 6 +- files/zh-cn/web/http/headers/host/index.md | 6 +- .../zh-cn/web/http/headers/if-match/index.md | 6 +- .../http/headers/if-modified-since/index.md | 6 +- .../web/http/headers/if-none-match/index.md | 6 +- .../zh-cn/web/http/headers/if-range/index.md | 6 +- .../http/headers/if-unmodified-since/index.md | 6 +- .../web/http/headers/keep-alive/index.md | 7 +- .../http/headers/large-allocation/index.md | 8 +- .../web/http/headers/last-modified/index.md | 8 +- .../zh-cn/web/http/headers/location/index.md | 6 +- .../permissions-policy/autoplay/index.md | 2 +- .../permissions-policy/camera/index.md | 2 +- .../http/headers/permissions-policy/index.md | 6 +- .../picture-in-picture/index.md | 2 +- files/zh-cn/web/http/headers/pragma/index.md | 8 +- .../http/headers/proxy-authenticate/index.md | 6 +- .../http/headers/proxy-authorization/index.md | 7 +- files/zh-cn/web/http/headers/range/index.md | 6 +- files/zh-cn/web/http/headers/referer/index.md | 6 +- .../web/http/headers/referrer-policy/index.md | 45 ++++----- .../web/http/headers/retry-after/index.md | 6 +- .../sec-ch-ua-full-version-list/index.md | 2 +- .../web/http/headers/sec-fetch-dest/index.md | 2 +- .../web/http/headers/sec-fetch-mode/index.md | 6 +- .../web/http/headers/sec-fetch-site/index.md | 8 +- .../web/http/headers/sec-fetch-user/index.md | 6 +- .../web/http/headers/server-timing/index.md | 6 +- files/zh-cn/web/http/headers/server/index.md | 6 +- .../web/http/headers/set-cookie/index.md | 10 ++ .../zh-cn/web/http/headers/sourcemap/index.md | 6 +- files/zh-cn/web/http/headers/te/index.md | 6 +- .../http/headers/timing-allow-origin/index.md | 6 +- files/zh-cn/web/http/headers/tk/index.md | 6 +- files/zh-cn/web/http/headers/trailer/index.md | 7 +- .../http/headers/transfer-encoding/index.md | 6 +- .../upgrade-insecure-requests/index.md | 6 +- .../http/headers/user-agent/firefox/index.md | 2 +- .../web/http/headers/user-agent/index.md | 10 +- files/zh-cn/web/http/headers/vary/index.md | 6 +- files/zh-cn/web/http/headers/via/index.md | 6 +- files/zh-cn/web/http/headers/warning/index.md | 26 ++--- .../headers/x-content-type-options/index.md | 7 +- .../headers/x-dns-prefetch-control/index.md | 10 +- .../http/headers/x-forwarded-host/index.md | 6 +- .../http/headers/x-forwarded-proto/index.md | 6 +- .../web/http/headers/x-frame-options/index.md | 8 +- .../http/headers/x-xss-protection/index.md | 6 +- files/zh-cn/web/http/messages/index.md | 30 +++--- files/zh-cn/web/http/overview/index.md | 34 +++---- .../http/protocol_upgrade_mechanism/index.md | 2 +- .../http/proxy_servers_and_tunneling/index.md | 6 +- .../index.md | 97 +++++++++--------- files/zh-cn/web/http/redirections/index.md | 2 +- .../resources_and_specifications/index.md | 98 +++++++++---------- files/zh-cn/web/http/session/index.md | 4 +- files/zh-cn/web/http/status/408/index.md | 2 +- 124 files changed, 538 insertions(+), 510 deletions(-) diff --git a/.prettierignore b/.prettierignore index 673b43dfe86422..1eb334753678fc 100644 --- a/.prettierignore +++ b/.prettierignore @@ -95,6 +95,5 @@ build/ /files/zh-cn/web/api/**/*.md /files/zh-cn/web/css/**/*.md /files/zh-cn/web/html/**/*.md -/files/zh-cn/web/http/**/*.md /files/zh-cn/web/javascript/reference/**/*.md /files/zh-cn/web/svg/**/*.md diff --git a/files/zh-cn/web/http/basics_of_http/evolution_of_http/index.md b/files/zh-cn/web/http/basics_of_http/evolution_of_http/index.md index 3969a90d20ef48..623c7ea4c69fd9 100644 --- a/files/zh-cn/web/http/basics_of_http/evolution_of_http/index.md +++ b/files/zh-cn/web/http/basics_of_http/evolution_of_http/index.md @@ -31,9 +31,9 @@ GET /mypage.html 响应也极其简单的:只包含响应文档本身。 ```html - -这是一个非常简单的 HTML 页面 - + + 这是一个非常简单的 HTML 页面 + ``` 跟后来的版本不同,HTTP/0.9 的响应内容并不包含 HTTP 头。这意味着只有 HTML 文件可以传送,无法传输其他类型的文件。也没有状态码或错误代码。一旦出现问题,一个特殊的包含问题描述信息的 HTML 文件将被发回,供人们查看。 diff --git a/files/zh-cn/web/http/basics_of_http/identifying_resources_on_the_web/index.md b/files/zh-cn/web/http/basics_of_http/identifying_resources_on_the_web/index.md index 804a728c6ad17f..49efe7a29fa56f 100644 --- a/files/zh-cn/web/http/basics_of_http/identifying_resources_on_the_web/index.md +++ b/files/zh-cn/web/http/basics_of_http/identifying_resources_on_the_web/index.md @@ -50,18 +50,18 @@ urn:ietf:rfc:7230 - ![Protocol](mdn-url-protocol@x2.png) - : `http://`告诉浏览器使用何种协议。对于大部分 Web 资源,通常使用 HTTP 协议或其安全版本,HTTPS 协议。另外,浏览器也知道如何处理其他协议。例如, `mailto:` 协议指示浏览器打开邮件客户端;`ftp:`协议指示浏览器处理文件传输。常见的方案有: -| 方案 | 描述 | -| ----------- | --------------------------------------------------------------------- | -| data | [Data URIs](/zh-CN/docs/Web/HTTP/data_URIs) | -| file | 指定主机上文件的名称 | -| ftp | [文件传输协议](/zh-CN/docs/Glossary/FTP) | +| 方案 | 描述 | +| ----------- | ------------------------------------------------------------------ | +| data | [Data URIs](/zh-CN/docs/Web/HTTP/data_URIs) | +| file | 指定主机上文件的名称 | +| ftp | [文件传输协议](/zh-CN/docs/Glossary/FTP) | | http/https | [超文本传输 协议/安全的超文本传输协议](/zh-CN/docs/Glossary/HTTP) | -| mailto | 电子邮件地址 | -| ssh | 安全 shell | -| tel | 电话 | -| urn | 统一资源名称 | -| view-source | 资源的源代码 | -| ws/wss | (加密的)[WebSocket](/zh-CN/docs/WebSockets) 连接 | +| mailto | 电子邮件地址 | +| ssh | 安全 shell | +| tel | 电话 | +| urn | 统一资源名称 | +| view-source | 资源的源代码 | +| ws/wss | (加密的)[WebSocket](/zh-CN/docs/WebSockets) 连接 | ### 主机 diff --git a/files/zh-cn/web/http/basics_of_http/mime_types/index.md b/files/zh-cn/web/http/basics_of_http/mime_types/index.md index 8e2332a03fe1f9..507e4e5da526e7 100644 --- a/files/zh-cn/web/http/basics_of_http/mime_types/index.md +++ b/files/zh-cn/web/http/basics_of_http/mime_types/index.md @@ -141,9 +141,9 @@ HTML 并没有明确定义被用于{{HTMLElement("audio")}}和{{HTMLElement("vid | `audio/wave` `audio/wav` `audio/x-wav` `audio/x-pn-wav` | 音频流媒体文件。一般支持 PCM 音频编码 (WAVE codec "1") ,其他解码器有限支持(如果有的话)。 | | `audio/webm` | WebM 音频文件格式。Vorbis 和 Opus 是其最常用的解码器。 | | `video/webm` | 采用 WebM 视频文件格式的音视频文件。VP8 和 VP9 是其最常用的视频解码器。Vorbis 和 Opus 是其最常用的音频解码器。 | -| `audio/ogg` | 采用 OGG 多媒体文件格式的音频文件。Vorbis 是这个多媒体文件格式最常用的音频解码器。 | -| `video/ogg` | 采用 OGG 多媒体文件格式的音视频文件。常用的视频解码器是 Theora;音频解码器为 Vorbis。 | -| `application/ogg` | 采用 OGG 多媒体文件格式的音视频文件。常用的视频解码器是 Theora;音频解码器为 Vorbis。 | +| `audio/ogg` | 采用 OGG 多媒体文件格式的音频文件。Vorbis 是这个多媒体文件格式最常用的音频解码器。 | +| `video/ogg` | 采用 OGG 多媒体文件格式的音视频文件。常用的视频解码器是 Theora;音频解码器为 Vorbis。 | +| `application/ogg` | 采用 OGG 多媒体文件格式的音视频文件。常用的视频解码器是 Theora;音频解码器为 Vorbis。 | | `application/json` | application/json (MIME_type) | ### multipart/form-data diff --git a/files/zh-cn/web/http/browser_detection_using_the_user_agent/index.md b/files/zh-cn/web/http/browser_detection_using_the_user_agent/index.md index 528fafaff032a9..13409612ebe9fa 100644 --- a/files/zh-cn/web/http/browser_detection_using_the_user_agent/index.md +++ b/files/zh-cn/web/http/browser_detection_using_the_user_agent/index.md @@ -96,7 +96,7 @@ slug: Web/HTTP/Browser_detection_using_the_user_agent | 浏览器 | 规则 | 示例 | | ------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Mozilla (Gecko, Firefox) | 注释中的 [**Mobile 或 Tablet 标记**](/zh-CN/docs/Gecko_user_agent_string_reference) | Mozilla/5.0 (Android; Mobile; rv:13.0) Gecko/13.0 Firefox/13.0 | +| Mozilla (Gecko, Firefox) | 注释中的 [**Mobile 或 Tablet 标记**](/zh-CN/docs/Gecko_user_agent_string_reference) | Mozilla/5.0 (Android; Mobile; rv:13.0) Gecko/13.0 Firefox/13.0 | | WebKit-based (Android, Safari) | 注释外的[**Mobile Safari 标记**](https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html#//apple_ref/doc/uid/TP40006517-SW3) | Mozilla/5.0 (Linux; U; Android 4.0.3; de-ch; HTC Sensation Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 | | Blink-based (Chromium, Google Chrome, Opera 15+) | 注释外的[**Mobile Safari 标记**](https://developers.google.com/chrome/mobile/docs/user-agent) | Mozilla/5.0 (Linux; Android 4.4.2); Nexus 5 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Mobile Safari/537.36 OPR/20.0.1396.72047 | | Presto-based (Opera 12-) | 注释中的[**Opera Mobi/xyz 标记**](http://my.opera.com/community/openweb/idopera/)(Opera 12-) | Opera/9.80 (Android 2.3.3; Linux; Opera Mobi/ADR-1111101157; U; es-ES) Presto/2.9.201 Version/11.50 | diff --git a/files/zh-cn/web/http/caching/index.md b/files/zh-cn/web/http/caching/index.md index 8963c610602f17..66ed66fdd5f225 100644 --- a/files/zh-cn/web/http/caching/index.md +++ b/files/zh-cn/web/http/caching/index.md @@ -462,7 +462,7 @@ Cache-Control: max-age=31536000 共享缓存主要位于源服务器之前,旨在减少到源服务器的流量。 -因此,如果多个相同的请求同时到达共享缓存,中间缓存将代表自己将单个请求转发到源,然后源可以将结果重用于所有客户端。这称为***请求折叠***。 +因此,如果多个相同的请求同时到达共享缓存,中间缓存将代表自己将单个请求转发到源,然后源可以将结果重用于所有客户端。这称为**_请求折叠_**。 当请求同时到达时会发生请求折叠,因此即使响应中给出了 `max-age=0` 或 `no-cache`,它也会被重用。 diff --git a/files/zh-cn/web/http/compression/index.md b/files/zh-cn/web/http/compression/index.md index 470885111cdcab..2fa13629d64439 100644 --- a/files/zh-cn/web/http/compression/index.md +++ b/files/zh-cn/web/http/compression/index.md @@ -17,8 +17,8 @@ slug: Web/HTTP/Compression 每一种文件类型都会存有冗余,也就是*浪费的空间*。如果一个典型的文本文件存在 60% 的冗余的话,那么对于其他类型的文件,例如音频或视频文件来说,这个比率会更高。不同于文本文件,这些其他类型的媒体文件占据的空间也更大,所以很早就出现了回收这些浪费的空间的需求。工程师们设计了可以应用于特定用途的文件类型的经过优化的算法。用于文件的压缩算法可以大致分为两类: -- *无损压缩*。在压缩与解压缩的循环期间,不会对要恢复的数据进行修改。复原后的数据与原始数据是一致的(比特与比特之间一一对应)。对于图片文件来说,`gif` 或者 `png` 格式的文件就是采用了无损压缩算法。 -- *有损压缩*。在压缩与解压缩的循环期间,会对原始数据进行修改,但是会(希望)以用户无法觉察的方式进行。网络上的视频文件通常采用有损压缩算法,`jpeg` 格式的图片也是有损压缩。 +- _无损压缩_。在压缩与解压缩的循环期间,不会对要恢复的数据进行修改。复原后的数据与原始数据是一致的(比特与比特之间一一对应)。对于图片文件来说,`gif` 或者 `png` 格式的文件就是采用了无损压缩算法。 +- _有损压缩_。在压缩与解压缩的循环期间,会对原始数据进行修改,但是会(希望)以用户无法觉察的方式进行。网络上的视频文件通常采用有损压缩算法,`jpeg` 格式的图片也是有损压缩。 一些特定的文件格式既可以采用无损压缩算法,又可以采用有损压缩算法,例如 `webp`,并且有损压缩算法可以对压缩比率进行配置,当然这会导致压缩品质的不同。为了使一个站点获得更好的性能,理想情况是在保持可以接受的品质水准的前提下,压缩比率尽可能得高。对于图片来说,通过压缩工具生成的图片对于 Web 应用来说,优化程度可能依然不够高。一般建议选用在保持所要求的品质的前提下压缩比率尽可能高的工具。这里有[各种各样的工具](https://www.creativebloq.com/design/image-compression-tools-1132865)专门用来干这个。 diff --git a/files/zh-cn/web/http/connection_management_in_http_1.x/index.md b/files/zh-cn/web/http/connection_management_in_http_1.x/index.md index b70728711e5c31..1fb4341aa24105 100644 --- a/files/zh-cn/web/http/connection_management_in_http_1.x/index.md +++ b/files/zh-cn/web/http/connection_management_in_http_1.x/index.md @@ -5,7 +5,7 @@ slug: Web/HTTP/Connection_management_in_HTTP_1.x {{HTTPSidebar}} -连接管理是一个 HTTP 的关键话题:打开和保持连接在很大程度上影响着网站和 Web 应用程序的性能。在 HTTP/1.x 里有多种模型:*短连接*、*长连接*和 *HTTP 流水线*。 +连接管理是一个 HTTP 的关键话题:打开和保持连接在很大程度上影响着网站和 Web 应用程序的性能。在 HTTP/1.x 里有多种模型:_短连接_、*长连接*和 _HTTP 流水线_。 HTTP 的传输协议主要依赖于 TCP 来提供从客户端到服务器端之间的连接。在早期,HTTP 使用一个简单的模型来处理这样的连接。这些连接的生命周期是短暂的:每发起一个请求时都会创建一个新的连接,并在收到应答时立即关闭。 @@ -51,7 +51,7 @@ HTTP/1.0 里默认并不使用长连接。把 {{HTTPHeader("Connection")}} 设 > - 正确的实现流水线是复杂的:传输中的资源大小、多少有效的 [RTT](https://zh.wikipedia.org/wiki/來回通訊延遲) 会被用到以及有效带宽都会直接影响到流水线提供的改善。不知道这些的话,重要的消息可能被延迟到不重要的消息后面。这个重要性的概念甚至会演变为影响到页面布局!因此 HTTP 流水线在大多数情况下带来的改善并不明显。 > - 流水线受制于[队头阻塞(HOL)](https://zh.wikipedia.org/wiki/队头阻塞)问题。 > -> 由于这些原因,流水线已被 HTTP/2 中更好的算法——*多路复用*(multiplexing)所取代。 +> 由于这些原因,流水线已被 HTTP/2 中更好的算法——_多路复用_(multiplexing)所取代。 默认情况下,[HTTP](/zh-CN/docs/Web/HTTP) 请求是按顺序发出的。下一个请求只有在当前请求收到响应过后才会被发出。由于会受到网络延迟和带宽的限制,在下一个请求被发送到服务器之前,可能需要等待很长时间。 diff --git a/files/zh-cn/web/http/content_negotiation/index.md b/files/zh-cn/web/http/content_negotiation/index.md index a2ebca63f3388a..dffea6dacae449 100644 --- a/files/zh-cn/web/http/content_negotiation/index.md +++ b/files/zh-cn/web/http/content_negotiation/index.md @@ -5,7 +5,7 @@ slug: Web/HTTP/Content_negotiation {{HTTPSidebar}} -在 [HTTP](/zh-CN/docs/Glossary/HTTP) 协议中,***内容协商***是一种机制,用于为同一 URI 提供资源不同的{{Glossary("Representation header","表示")}}形式,以帮助用户代理指定最适合用户的表示形式(例如,哪种文档语言、哪种图片格式或者哪种内容编码)。 +在 [HTTP](/zh-CN/docs/Glossary/HTTP) 协议中,**_内容协商_**是一种机制,用于为同一 URI 提供资源不同的{{Glossary("Representation header","表示")}}形式,以帮助用户代理指定最适合用户的表示形式(例如,哪种文档语言、哪种图片格式或者哪种内容编码)。 > **备注:** 你可以在[来自 WHATWG 的维基页面](https://wiki.whatwg.org/wiki/Why_not_conneg)发现 HTTP 内容协商的一些缺点。HTML5 提供其他的选择来进行内容协商,例如 [`` 元素](/zh-CN/docs/Web/HTML/Element/source)。 @@ -97,7 +97,7 @@ HTTP/1.1 规范指定了一系列的标准标头用于启动服务端驱动型 服务端驱动型内容协商也有一些缺点:它不能很好的扩展。在协商机制中,每一个特性需要对应一个标头。如果想要使用屏幕大小、分辨率或者其他方面的特性,就需要创建一个新的 HTTP 标头。而且在每一次请求中都必须发送这些标头。在标头很少的时候,这并不是问题,但是随着数量的增多,消息的体积会导致性能的下降。带有精确信息的标头发送的越多,信息熵就会越大,也就准许了更多 HTTP 指纹识别行为,以及与此相关的隐私问题的发生。 -从 HTTP 协议制定之初,该协议就准许另外一种协商机制:*代理驱动型内容协商*,或称为*响应式协商*。在这种协商机制中,当面临不明确的请求时,服务器会返回一个页面,其中包含了可供选择的资源的链接。资源呈现给用户,由用户做出选择。 +从 HTTP 协议制定之初,该协议就准许另外一种协商机制:_代理驱动型内容协商_,或称为*响应式协商*。在这种协商机制中,当面临不明确的请求时,服务器会返回一个页面,其中包含了可供选择的资源的链接。资源呈现给用户,由用户做出选择。 ![客户端请求一个 URL,其中标头表示对内容类型的偏好。服务器有多个由 URL 表示的资源并发回多个响应,因此客户端可以选择应用了首选压缩算法的主体。](httpnego3.png) diff --git a/files/zh-cn/web/http/content_negotiation/list_of_default_accept_values/index.md b/files/zh-cn/web/http/content_negotiation/list_of_default_accept_values/index.md index 8209346148bcff..c83385bd25b67e 100644 --- a/files/zh-cn/web/http/content_negotiation/list_of_default_accept_values/index.md +++ b/files/zh-cn/web/http/content_negotiation/list_of_default_accept_values/index.md @@ -14,7 +14,7 @@ original_slug: Web/HTTP/Content_negotiation/Accept_默认值 | User Agent | Value | Comment | | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -| Firefox | `text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8` | 这个值可以通过 `network.http.accept.default` 参数来修改。 | +| Firefox | `text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8` | 这个值可以通过 `network.http.accept.default` 参数来修改。 | | Safari, Chrome | `application/xml,application/xhtml+xml,text/html;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5` | [source](http://www.newmediacampaigns.com/page/browser-rest-http-accept-headers) | | Safari 5 | `text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8` | 这是对早期 `Accept` 头的改进,不再把 `image/png` 排在 `text/html` 之前。 | | Internet Explorer 8 | `image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/x-shockwave-flash, application/msword, */*` | 请参见 [IE and the Accept Header (IEInternals' MSDN blog)](http://blogs.msdn.com/b/ieinternals/archive/2009/07/01/ie-and-the-accept-header.aspx). | @@ -39,10 +39,10 @@ original_slug: Web/HTTP/Content_negotiation/Accept_默认值 | User Agent | Value | Comment | | -------------------------------- | -------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | -| Firefox 3.6 之前的版本 | _不支持 {{HTMLElement("video")}}_ | | +| Firefox 3.6 之前的版本 | _不支持 {{HTMLElement("video")}}_ | | | Firefox 3.6 及以上版本 | `audio/webm, audio/ogg, audio/wav, audio/*;q=0.9, application/ogg;q=0.7, video/*;q=0.6; */*;q=0.5` | 请参见[bug 489071](https://bugzilla.mozilla.org/show_bug.cgi?id=489071) | | Chrome | `*/*` | | -| Internet Explorer 8 或更早的版本 | _不支持 {{HTMLElement("video")}}_ | | +| Internet Explorer 8 或更早的版本 | _不支持 {{HTMLElement("video")}}_ | | ## audio 请求 @@ -52,7 +52,7 @@ original_slug: Web/HTTP/Content_negotiation/Accept_默认值 | ------------------------------ | -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | | Firefox 3.6 及以上版本 | `audio/webm,audio/ogg,audio/wav,audio/*;q=0.9,application/ogg;q=0.7,video/*;q=0.6,*/*;q=0.5` | See [bug 489071](https://bugzilla.mozilla.org/show_bug.cgi?id=489071) | | Safari, Chrome | ? | | -| Internet Explorer 8 及更早版本 | _不支持 {{HTMLElement("audio")}}_ | | +| Internet Explorer 8 及更早版本 | _不支持 {{HTMLElement("audio")}}_ | | | Internet Explorer 9 | ? | | ## scripts 请求 diff --git a/files/zh-cn/web/http/cookies/index.md b/files/zh-cn/web/http/cookies/index.md index ef9092179b4a9f..ddeea914457270 100644 --- a/files/zh-cn/web/http/cookies/index.md +++ b/files/zh-cn/web/http/cookies/index.md @@ -95,7 +95,7 @@ Set-Cookie: id=a3fWa; Expires=Wed, 21 Oct 2015 07:28:00 GMT; Secure; HttpOnly #### Domain 属性 -`Domain` 指定了哪些主机可以接受 Cookie。如果不指定,该属性默认为同一 {{Glossary("host")}} 设置 cookie,*不包含子域名*。如果指定了 `Domain`,则一般包含子域名。因此,指定 `Domain` 比省略它的限制要少。但是,当子域需要共享有关用户的信息时,这可能会有所帮助。 +`Domain` 指定了哪些主机可以接受 Cookie。如果不指定,该属性默认为同一 {{Glossary("host")}} 设置 cookie,_不包含子域名_。如果指定了 `Domain`,则一般包含子域名。因此,指定 `Domain` 比省略它的限制要少。但是,当子域需要共享有关用户的信息时,这可能会有所帮助。 例如,如果设置 `Domain=mozilla.org`,则 Cookie 也包含在子域名中(如 `developer.mozilla.org`)。 @@ -187,7 +187,7 @@ Cookie 与特定域和方案(例如,`http` 或 `https`)相关联,如果 第三方服务器可以基于同一浏览器在访问多个站点时发送给它的 cookie 来建立用户浏览历史和习惯的配置文件。Firefox 默认情况下会阻止已知包含跟踪器的第三方 cookie。第三方 cookie(或仅跟踪 cookie)也可能被其他浏览器设置或扩展程序阻止。阻止 Cookie 会导致某些第三方组件(例如社交媒体窗口小部件)无法正常运行。 ->**备注:** 服务器可以(并且应该)设置 cookie [SameSite 属性](/zh-CN/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value)以指定是否可以将 cookie 发送到第三方站点。 +> **备注:** 服务器可以(并且应该)设置 cookie [SameSite 属性](/zh-CN/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value)以指定是否可以将 cookie 发送到第三方站点。 ### Cookie 相关规定 diff --git a/files/zh-cn/web/http/cors/index.md b/files/zh-cn/web/http/cors/index.md index c5d3d3406304de..f68f12a719ecbc 100644 --- a/files/zh-cn/web/http/cors/index.md +++ b/files/zh-cn/web/http/cors/index.md @@ -84,9 +84,9 @@ CORS 请求失败会产生错误,但是为了安全,在 JavaScript 代码层 ```js const xhr = new XMLHttpRequest(); -const url = 'https://bar.other/resources/public-data/'; +const url = "https://bar.other/resources/public-data/"; -xhr.open('GET', url); +xhr.open("GET", url); xhr.onreadystatechange = someHandler; xhr.send(); ``` @@ -147,11 +147,11 @@ Access-Control-Allow-Origin: https://foo.example ```js const xhr = new XMLHttpRequest(); -xhr.open('POST', 'https://bar.other/resources/post-here/'); -xhr.setRequestHeader('X-PINGOTHER', 'pingpong'); -xhr.setRequestHeader('Content-Type', 'application/xml'); +xhr.open("POST", "https://bar.other/resources/post-here/"); +xhr.setRequestHeader("X-PINGOTHER", "pingpong"); +xhr.setRequestHeader("Content-Type", "application/xml"); xhr.onreadystatechange = handler; -xhr.send('Arun'); +xhr.send("Arun"); ``` 上面的代码使用 `POST` 请求发送一个 XML 请求体,该请求包含了一个非标准的 HTTP `X-PINGOTHER` 请求标头。这样的请求标头并不是 HTTP/1.1 的一部分,但通常对于 web 应用很有用处。另外,该请求的 `Content-Type` 为 `application/xml`,且使用了自定义的请求标头,所以该请求需要首先发起“预检请求”。 diff --git a/files/zh-cn/web/http/csp/index.md b/files/zh-cn/web/http/csp/index.md index 755306e670a26a..cb51b0ad314283 100644 --- a/files/zh-cn/web/http/csp/index.md +++ b/files/zh-cn/web/http/csp/index.md @@ -165,7 +165,7 @@ Content-Security-Policy: default-src 'none'; style-src cdn.example.com; report-u `signup.html` 的 HTML 像这样: ```html - + diff --git a/files/zh-cn/web/http/headers/accept-ch-lifetime/index.md b/files/zh-cn/web/http/headers/accept-ch-lifetime/index.md index 6da26e6062c284..c49b6d73ac7e89 100644 --- a/files/zh-cn/web/http/headers/accept-ch-lifetime/index.md +++ b/files/zh-cn/web/http/headers/accept-ch-lifetime/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/Accept-CH-Lifetime 服务器设置 **`Accept-CH-Lifetime`** 标头以指定{{HTTPHeader("Accept-CH")}}标头值的持久性,该值指定客户端应在后续请求中包括哪些[Client Hints](/zh-CN/docs/Glossary/Client_hints)标头。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | ? | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | ? | > **备注:** [Client Hints](/zh-CN/docs/Glossary/Client_hints)只能在安全源(通过 TLS)上访问。所有安全的请求都应该持久化 Accept-CH 和 Accept-CH-Lifetime 头,以确保[Client Hints](/zh-CN/docs/Glossary/Client_hints)可靠地发送。 diff --git a/files/zh-cn/web/http/headers/accept-ch/index.md b/files/zh-cn/web/http/headers/accept-ch/index.md index 5786c62b2c31c9..c3f9c6ff87c75d 100644 --- a/files/zh-cn/web/http/headers/accept-ch/index.md +++ b/files/zh-cn/web/http/headers/accept-ch/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/Accept-CH **`Accept-CH`** 头由服务器设置,以指定客户端应在后续请求中应包含哪些客户端 [Client Hints](/zh-CN/docs/Glossary/Client_hints) 提示头。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | ? | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | ? | > **备注:** [Client Hints](/zh-CN/docs/Glossary/Client_hints) 只能在安全源(通过 TLS)上访问。所有安全的请求都应该持久化 Accept-CH 和 Accept-CH-Lifetime 头,以确保 [Client Hints](/zh-CN/docs/Glossary/Client_hints) 可靠地发送。 diff --git a/files/zh-cn/web/http/headers/accept-charset/index.md b/files/zh-cn/web/http/headers/accept-charset/index.md index e1ad882dd4d1d7..bbc885fc6c33ce 100644 --- a/files/zh-cn/web/http/headers/accept-charset/index.md +++ b/files/zh-cn/web/http/headers/accept-charset/index.md @@ -11,9 +11,9 @@ slug: Web/HTTP/Headers/Accept-Charset > **备注:** 在早期版本的 HTTP/1.1 协议中,规定了一个默认的字符集 (ISO-8859-1)。但是现在情况不同了,目前每一种内容类型都有自己的默认字符集。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | yes | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | yes | ## 句法 diff --git a/files/zh-cn/web/http/headers/accept-encoding/index.md b/files/zh-cn/web/http/headers/accept-encoding/index.md index d6b80bd568e0f8..1941a8f98d50c9 100644 --- a/files/zh-cn/web/http/headers/accept-encoding/index.md +++ b/files/zh-cn/web/http/headers/accept-encoding/index.md @@ -18,9 +18,9 @@ HTTP 请求头 **Accept-Encoding** 会将客户端能够理解的内容编码方 > > - 另外两种编码方式—— bzip 和 bzip2 ——有时候也会用到,尽管并未在标准中出现。这两种方式实现了 UNIX 系统上的同名程序所采用的算法。注意第一种由于专利许可问题已经停止维护。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | yes | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | yes | ## 语法 diff --git a/files/zh-cn/web/http/headers/accept-language/index.md b/files/zh-cn/web/http/headers/accept-language/index.md index 22a8d9e203095c..6847503e440881 100644 --- a/files/zh-cn/web/http/headers/accept-language/index.md +++ b/files/zh-cn/web/http/headers/accept-language/index.md @@ -11,10 +11,10 @@ slug: Web/HTTP/Headers/Accept-Language 如果服务器不能提供任何可以匹配的语言的版本,那么理论上来说应该返回一个 {{HTTPStatus("406")}}(Not Acceptable,不被接受)的错误码。但是为了更好的用户体验,这种方法很少被采用,取而代之的是将其忽略。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | -| {{Glossary("Simple header", "CORS-safelisted request-header")}} | yes | +| Header type | {{Glossary("Request header")}} | +| --------------------------------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | no | +| {{Glossary("Simple header", "CORS-safelisted request-header")}} | yes | ## 语法 diff --git a/files/zh-cn/web/http/headers/accept-patch/index.md b/files/zh-cn/web/http/headers/accept-patch/index.md index 7ac8a7aa36a2a7..7bb375803986dc 100644 --- a/files/zh-cn/web/http/headers/accept-patch/index.md +++ b/files/zh-cn/web/http/headers/accept-patch/index.md @@ -15,9 +15,9 @@ A server receiving a PATCH request with an unsupported media type could reply wi > > - Two others content encoding, `bzip` and `bzip2`, are sometimes used, though not standard. They implement the algorithm used by these two UNIX programs. Note that the first one was discontinued due to patent licensing problems. -| 头部类型 | {{Glossary("Response header")}} | -| ---------------------------------------------------------------------- | ---------------------------------------- | -| {{Glossary("Forbidden header name")}}(禁止修改的 HTTP 头) | yes | +| 头部类型 | {{Glossary("Response header")}} | +| ----------------------------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}}(禁止修改的 HTTP 头) | yes | ## 语法 diff --git a/files/zh-cn/web/http/headers/accept-ranges/index.md b/files/zh-cn/web/http/headers/accept-ranges/index.md index da73a8cd92cc54..20563ba64082bb 100644 --- a/files/zh-cn/web/http/headers/accept-ranges/index.md +++ b/files/zh-cn/web/http/headers/accept-ranges/index.md @@ -7,11 +7,11 @@ slug: Web/HTTP/Headers/Accept-Ranges 服务器使用 HTTP 响应头 **`Accept-Ranges`** 标识自身支持范围请求 (partial requests)。字段的具体值用于定义范围请求的单位。 -当浏览器发现` Accept-Ranges `头时,可以尝试*继续*中断了的下载,而不是重新开始。 +当浏览器发现`Accept-Ranges`头时,可以尝试*继续*中断了的下载,而不是重新开始。 -| 头部类型 | {{Glossary("Response header")}} | -| ---------------------------------------------------------------------- | ---------------------------------------- | -| {{Glossary("Forbidden header name")}}(禁止修改的 HTTP 头) | 否 | +| 头部类型 | {{Glossary("Response header")}} | +| ----------------------------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}}(禁止修改的 HTTP 头) | 否 | ## 语法 diff --git a/files/zh-cn/web/http/headers/accept/index.md b/files/zh-cn/web/http/headers/accept/index.md index 44bc60508a8814..cc50dd90899404 100644 --- a/files/zh-cn/web/http/headers/accept/index.md +++ b/files/zh-cn/web/http/headers/accept/index.md @@ -7,10 +7,10 @@ slug: Web/HTTP/Headers/Accept **`Accept`** 请求头用来告知(服务器)客户端可以处理的内容类型,这种内容类型用[MIME 类型](/zh-CN/docs/Web/HTTP/Basics_of_HTTP/MIME_types)来表示。借助[内容协商机制](/zh-CN/docs/Web/HTTP/Content_negotiation), 服务器可以从诸多备选项中选择一项进行应用,并使用 {{HTTPHeader("Content-Type")}} 应答头通知客户端它的选择。浏览器会基于请求的上下文来为这个请求头设置合适的值,比如获取一个 CSS 层叠样式表时值与获取图片、视频或脚本文件时的值是不同的。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | -| {{Glossary("Simple header", "CORS-safelisted request-header")}} | yes | +| Header type | {{Glossary("Request header")}} | +| --------------------------------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | no | +| {{Glossary("Simple header", "CORS-safelisted request-header")}} | yes | ## 语法 diff --git a/files/zh-cn/web/http/headers/access-control-allow-credentials/index.md b/files/zh-cn/web/http/headers/access-control-allow-credentials/index.md index f9c42052f99849..34f623017bb166 100644 --- a/files/zh-cn/web/http/headers/access-control-allow-credentials/index.md +++ b/files/zh-cn/web/http/headers/access-control-allow-credentials/index.md @@ -15,9 +15,9 @@ Credentials 可以是 cookies、authorization headers 或 TLS client certificate `Access-Control-Allow-Credentials` 标头需要与 {{domxref("XMLHttpRequest.withCredentials")}} 或 Fetch API 的 {{domxref("Request.Request()", "Request()")}} 构造函数中的 `credentials` 选项结合使用。Credentials 必须在前后端都被配置(即 `Access-Control-Allow-Credentials` header 和 XHR 或 Fetch request 中都要配置)才能使带 credentials 的 CORS 请求成功。 -| 头部类型 | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| 头部类型 | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 @@ -42,7 +42,7 @@ Access-Control-Allow-Credentials: true ```js var xhr = new XMLHttpRequest(); -xhr.open('GET', 'http://example.com/', true); +xhr.open("GET", "http://example.com/", true); xhr.withCredentials = true; xhr.send(null); ``` @@ -51,8 +51,8 @@ xhr.send(null); ```js fetch(url, { - credentials: 'include' -}) + credentials: "include", +}); ``` ## 规范 diff --git a/files/zh-cn/web/http/headers/access-control-allow-headers/index.md b/files/zh-cn/web/http/headers/access-control-allow-headers/index.md index dcb03fe38c74ed..6f662d2506fcfc 100644 --- a/files/zh-cn/web/http/headers/access-control-allow-headers/index.md +++ b/files/zh-cn/web/http/headers/access-control-allow-headers/index.md @@ -11,9 +11,9 @@ slug: Web/HTTP/Headers/Access-Control-Allow-Headers 如果请求中含有 {{HTTPHeader("Access-Control-Request-Headers")}} 字段,那么这个首部是必要的。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/access-control-allow-methods/index.md b/files/zh-cn/web/http/headers/access-control-allow-methods/index.md index 3ffbf6b26f87a7..488544acad48c2 100644 --- a/files/zh-cn/web/http/headers/access-control-allow-methods/index.md +++ b/files/zh-cn/web/http/headers/access-control-allow-methods/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/Access-Control-Allow-Methods 响应首部 **`Access-Control-Allow-Methods`** 在对 {{glossary("preflight request")}}.(预检请求)的应答中明确了客户端所要访问的资源允许使用的方法或方法列表。 -| 报头类型 | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| 报头类型 | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/access-control-allow-origin/index.md b/files/zh-cn/web/http/headers/access-control-allow-origin/index.md index 14097309be463f..7db4922610ef9d 100644 --- a/files/zh-cn/web/http/headers/access-control-allow-origin/index.md +++ b/files/zh-cn/web/http/headers/access-control-allow-origin/index.md @@ -35,6 +35,7 @@ Access-Control-Allow-Origin: null - `` - : 指定一个来源(只能指定一个)。如果服务器支持多个来源的客户端,其必须以与指定客户端匹配的来源来响应请求。 - `null` + - : 指定来源为“null”。 > **备注:** `null` [不应该被使用](https://w3c.github.io/webappsec-cors-for-developers/#avoid-returning-access-control-allow-origin-null):“返回 `Access-Control-Allow-Origin: "null"` 似乎是安全的,但任何使用非分级协议(如 `data:` 或 `file:`)的资源和沙盒文件的 Origin 的序列化都被定义为‘null’。许多用户代理将授予这类文件对带有 `Access-Control-Allow-Origin: "null"` 头的响应的访问权,而且任何源都可以用 `null` 源创建一个恶意文件。因此,应该避免将 ACAO 标头设置为‘null’值。” diff --git a/files/zh-cn/web/http/headers/access-control-max-age/index.md b/files/zh-cn/web/http/headers/access-control-max-age/index.md index 96b2918d380d8c..7908284d4a1284 100644 --- a/files/zh-cn/web/http/headers/access-control-max-age/index.md +++ b/files/zh-cn/web/http/headers/access-control-max-age/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/Access-Control-Max-Age The **`Access-Control-Max-Age`** 这个响应头表示 {{glossary("preflight request")}} (预检请求)的返回结果(即 {{HTTPHeader("Access-Control-Allow-Methods")}} 和{{HTTPHeader("Access-Control-Allow-Headers")}} 提供的信息)可以被缓存多久。 -| 报头类型 | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| 报头类型 | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/access-control-request-headers/index.md b/files/zh-cn/web/http/headers/access-control-request-headers/index.md index 515ce13b14f88a..d8f9133dd01ca2 100644 --- a/files/zh-cn/web/http/headers/access-control-request-headers/index.md +++ b/files/zh-cn/web/http/headers/access-control-request-headers/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/Access-Control-Request-Headers 请求头 **`Access-Control-Request-Headers`** 出现于 {{glossary("preflight request")}}(预检请求)中,用于通知服务器在真正的请求中会采用哪些请求头。 -| 报头类型 | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | yes | +| 报头类型 | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | yes | ## 语法 diff --git a/files/zh-cn/web/http/headers/access-control-request-method/index.md b/files/zh-cn/web/http/headers/access-control-request-method/index.md index e08933f2c23249..c7b05977174a8c 100644 --- a/files/zh-cn/web/http/headers/access-control-request-method/index.md +++ b/files/zh-cn/web/http/headers/access-control-request-method/index.md @@ -5,9 +5,9 @@ slug: Web/HTTP/Headers/Access-Control-Request-Method {{HTTPSidebar}}请求头 **`Access-Control-Request-Method`** 出现于 {{glossary("preflight request")}}(预检请求)中,用于通知服务器在真正的请求中会采用哪种 [HTTP 方法](/zh-CN/docs/Web/HTTP/Methods)。因为预检请求所使用的方法总是 {{HTTPMethod("OPTIONS")}} ,与实际请求所使用的方法不一样,所以这个请求头是必要的。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | yes | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | yes | ## 语法 diff --git a/files/zh-cn/web/http/headers/age/index.md b/files/zh-cn/web/http/headers/age/index.md index b31431be5ebe6a..367fa10070ff49 100644 --- a/files/zh-cn/web/http/headers/age/index.md +++ b/files/zh-cn/web/http/headers/age/index.md @@ -9,9 +9,9 @@ slug: Web/HTTP/Headers/Age Age 的值通常接近于 0。表示此对象刚刚从原始服务器获取不久;其他的值则是表示代理服务器当前的系统时间与此应答中的通用头 {{HTTPHeader("Date")}} 的值之差。 -| 报头类型 | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| 报头类型 | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/allow/index.md b/files/zh-cn/web/http/headers/allow/index.md index f1cc3b43ceb385..e552363d18b2ae 100644 --- a/files/zh-cn/web/http/headers/allow/index.md +++ b/files/zh-cn/web/http/headers/allow/index.md @@ -9,9 +9,9 @@ slug: Web/HTTP/Headers/Allow 若服务器返回状态码 {{HTTPStatus("405")}} `Method Not Allowed`,则该首部字段亦需要同时返回给客户端。如果 `Allow` 首部字段的值为空,说明资源不接受使用任何 HTTP 方法的请求。这是可能的,比如服务器需要临时禁止对资源的任何访问。 -| Header type | {{Glossary("Entity header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Entity header")}} | +| ------------------------------------- | ----------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/authorization/index.md b/files/zh-cn/web/http/headers/authorization/index.md index 53465f01b548a7..94007cfc2c1f5b 100644 --- a/files/zh-cn/web/http/headers/authorization/index.md +++ b/files/zh-cn/web/http/headers/authorization/index.md @@ -78,7 +78,7 @@ Authorization: Digest username=, - `username*` - : 使用 RFC5987 中定义的扩展符号格式化的用户名。只有当名称无法在 `username` 中编码并且 `userhash` 设置为 `"false"` 时,才应使用此字段。 - `uri` - - : *有效的请求 URI*。有关更多信息,请参阅规范。 + - : _有效的请求 URI_。有关更多信息,请参阅规范。 - `realm` - : 请求的用户名/密码的 realm(同样,应该与所请求资源中对应的 {{HTTPHeader("WWW-Authenticate")}} 响应中的值相匹配)。 - `opaque` diff --git a/files/zh-cn/web/http/headers/cache-control/index.md b/files/zh-cn/web/http/headers/cache-control/index.md index 5d68778003cd19..9e212eb8b48929 100644 --- a/files/zh-cn/web/http/headers/cache-control/index.md +++ b/files/zh-cn/web/http/headers/cache-control/index.md @@ -7,10 +7,10 @@ slug: Web/HTTP/Headers/Cache-Control **`Cache-Control`** 通用消息头字段,被用于在 http 请求和响应中,通过指定指令来实现缓存机制。缓存指令是单向的,这意味着在请求中设置的指令,不一定被包含在响应中。 -| Header type | {{Glossary("General header")}} | -| ------------------------------------------------------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | -| {{Glossary("Simple response header", "CORS-safelisted response-header")}} | yes | +| Header type | {{Glossary("General header")}} | +| ------------------------------------------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | no | +| {{Glossary("Simple response header", "CORS-safelisted response-header")}} | yes | ## 语法 diff --git a/files/zh-cn/web/http/headers/clear-site-data/index.md b/files/zh-cn/web/http/headers/clear-site-data/index.md index 169fd57a7e2f43..cd29e25e8aeb45 100644 --- a/files/zh-cn/web/http/headers/clear-site-data/index.md +++ b/files/zh-cn/web/http/headers/clear-site-data/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/Clear-Site-Data **`Clear-Site-Data`** 响应头,表示清除当前请求网站有关的浏览器数据(cookie,存储,缓存)。它让 Web 开发人员对浏览器本地存储的数据有更多控制能力。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 @@ -33,6 +33,7 @@ Clear-Site-Data: "*" - `"cookies"` - : 表示服务端希望删除 URL 响应的所有 cookie。HTTP 身份验证凭据也会被清除。会影响整个主域,包括子域。所以 `https://example.com` 以及 `https://stage.example.com` 的 Cookie 都会被清除。 - `"storage"` + - : 表示服务端希望删除 URL 原响应的所有 DOM 存储。这包括存储机制,如 - localStorage (执行 `localStorage.clear`), @@ -43,6 +44,7 @@ Clear-Site-Data: "*" - WebSQL 数据库, - [FileSystem API data](/zh-CN/docs/Web/API/File_and_Directory_Entries_API), - Plugin data (Flash via [`NPP_ClearSiteData`](https://wiki.mozilla.org/NPAPI:ClearSiteData)). + - `"executionContexts"` - : 表示服务端希望浏览器重新加载本请求 ({{domxref("Location.reload")}}). - `"*"` (通配符) diff --git a/files/zh-cn/web/http/headers/connection/index.md b/files/zh-cn/web/http/headers/connection/index.md index ffdfba702c440b..306aa33ad62036 100644 --- a/files/zh-cn/web/http/headers/connection/index.md +++ b/files/zh-cn/web/http/headers/connection/index.md @@ -11,9 +11,9 @@ slug: Web/HTTP/Headers/Connection 除去标准的逐段传输(hop-by-hop)头({{HTTPHeader("Keep-Alive")}}, {{HTTPHeader("Transfer-Encoding")}}, {{HTTPHeader("TE")}}, {{HTTPHeader("Connection")}}, {{HTTPHeader("Trailer")}}, {{HTTPHeader("Upgrade")}}, {{HTTPHeader("Proxy-Authorization")}} and {{HTTPHeader("Proxy-Authenticate")}}),任何逐段传输头都需要在 Connection 头中列出,这样才能让第一个代理知道必须处理它们且不转发这些头。标准的逐段传输头也可以列出(常见的例子是 {{HTTPHeader("Keep-Alive")}},但这不是必须的)。 -| Header type | {{Glossary("General header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | yes | +| Header type | {{Glossary("General header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | yes | ## 语法 diff --git a/files/zh-cn/web/http/headers/content-disposition/index.md b/files/zh-cn/web/http/headers/content-disposition/index.md index a4d33ce0d425d0..11a15f97b0fdfa 100644 --- a/files/zh-cn/web/http/headers/content-disposition/index.md +++ b/files/zh-cn/web/http/headers/content-disposition/index.md @@ -53,9 +53,11 @@ Content-Disposition: form-data; name="fieldName"; filename="filename.jpg" ### 指令 - `name` + - : 后面是一个表单字段名的字符串,每一个字段名会对应一个子部分。在同一个字段名对应多个文件的情况下(例如,带有 [`multiple`](/zh-CN/docs/Web/HTML/Element/input#multiple) 属性的 {{HTMLElement("input","<input type=file>")}} 元素),则多个子部分共用同一个字段名。 如果 `name` 参数的值为 `'_charset_'`,意味着这个子部分表示的不是一个 HTML 字段,而是在未明确指定字符集信息的情况下各部分使用的默认字符集。 + - `filename` - : 后面是要传送的文件的初始名称的字符串。这个参数总是可选的,而且不能盲目使用:路径信息必须舍掉,同时要进行一定的转换以符合服务器文件系统规则。这个参数主要用来提供展示性信息。当与 `Content-Disposition: attachment` 一同使用的时候,它被用作"保存为"对话框中呈现给用户的默认文件名。 - `filename\*` diff --git a/files/zh-cn/web/http/headers/content-language/index.md b/files/zh-cn/web/http/headers/content-language/index.md index ec7abf17065182..c56d67f03f0fb6 100644 --- a/files/zh-cn/web/http/headers/content-language/index.md +++ b/files/zh-cn/web/http/headers/content-language/index.md @@ -11,11 +11,11 @@ slug: Web/HTTP/Headers/Content-Language 如果没有指明 `Content-Language`,那么默认地,文件内容是提供给所有语言的访问者使用的。多个语言标签也是合法的,同样的,这个首部还可以用来描述不同媒体类型的文件,而不单单局限于文本型文档。 -| Header type | {{Glossary("Entity header")}} | -| ------------------------------------------------------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | -| {{Glossary("Simple response header", "CORS-safelisted response-header")}} | yes | -| {{Glossary("Simple header", "CORS-safelisted request-header")}} | yes | +| Header type | {{Glossary("Entity header")}} | +| ------------------------------------------------------------------------- | ----------------------------- | +| {{Glossary("Forbidden header name")}} | no | +| {{Glossary("Simple response header", "CORS-safelisted response-header")}} | yes | +| {{Glossary("Simple header", "CORS-safelisted request-header")}} | yes | ## 语法 @@ -39,14 +39,14 @@ Content-Language: de-DE, en-CA 全局的 [`lang`](/zh-CN/docs/Web/HTML/Global_attributes/lang) 属性使用在 HTML 元素去表达全部的 [HTML](/zh-CN/docs/Web/HTML)文档或者部分的语言。 ```html - + ``` 不要使用这个 meta 元素去声明文档语言: ```html example-bad - + ``` ### 为资源指定目标访问者 diff --git a/files/zh-cn/web/http/headers/content-length/index.md b/files/zh-cn/web/http/headers/content-length/index.md index 4d3ec2675c7a3d..fb7cd2db341b8f 100644 --- a/files/zh-cn/web/http/headers/content-length/index.md +++ b/files/zh-cn/web/http/headers/content-length/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/Content-Length **`Content-Length`** 是一个实体消息首部,用来指明发送给接收方的消息主体的大小,即用十进制数字表示的八位元组的数目。 -| Header type | {{Glossary("Entity header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | yes | +| Header type | {{Glossary("Entity header")}} | +| ------------------------------------- | ----------------------------- | +| {{Glossary("Forbidden header name")}} | yes | ## 语法 diff --git a/files/zh-cn/web/http/headers/content-location/index.md b/files/zh-cn/web/http/headers/content-location/index.md index d7268f021fff51..5c68cae9efad39 100644 --- a/files/zh-cn/web/http/headers/content-location/index.md +++ b/files/zh-cn/web/http/headers/content-location/index.md @@ -9,9 +9,9 @@ slug: Web/HTTP/Headers/Content-Location {{HTTPHeader("Location")}} 与 `Content-Location`是不同的,前者({{HTTPHeader("Location")}} )指定的是一个重定向请求的目的地址(或者新创建的文件的 URL),而后者( `Content-Location`)指向的是可供访问的资源的直接地址,不需要进行进一步的内容协商。Location 对应的是响应,而 Content-Location 对应的是要返回的实体。 -| Header type | {{Glossary("Entity header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Entity header")}} | +| ------------------------------------- | ----------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/content-range/index.md b/files/zh-cn/web/http/headers/content-range/index.md index 93624201fddf40..60628c70da0b6e 100644 --- a/files/zh-cn/web/http/headers/content-range/index.md +++ b/files/zh-cn/web/http/headers/content-range/index.md @@ -7,10 +7,10 @@ slug: Web/HTTP/Headers/Content-Range 在 HTTP 协议中,响应首部 **`Content-Range`** 显示的是一个数据片段在整个文件中的位置。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | -| {{Glossary("Simple response header", "CORS-safelisted response-header")}} | no | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | +| {{Glossary("Simple response header", "CORS-safelisted response-header")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/content-security-policy-report-only/index.md b/files/zh-cn/web/http/headers/content-security-policy-report-only/index.md index a9841a848d1156..27f0c5b8a3a677 100644 --- a/files/zh-cn/web/http/headers/content-security-policy-report-only/index.md +++ b/files/zh-cn/web/http/headers/content-security-policy-report-only/index.md @@ -81,11 +81,11 @@ Content-Security-Policy-Report-Only: default-src 'none'; style-src cdn.example.c `signup.html`的 html 如下: ```html - + Sign Up - + ... Content ... diff --git a/files/zh-cn/web/http/headers/content-security-policy/base-uri/index.md b/files/zh-cn/web/http/headers/content-security-policy/base-uri/index.md index 0a65f20b00d596..5f5355d307f7a3 100644 --- a/files/zh-cn/web/http/headers/content-security-policy/base-uri/index.md +++ b/files/zh-cn/web/http/headers/content-security-policy/base-uri/index.md @@ -1,5 +1,5 @@ --- -title: 'CSP: base-uri' +title: "CSP: base-uri" slug: Web/HTTP/Headers/Content-Security-Policy/base-uri --- @@ -44,7 +44,7 @@ Content-Security-Policy: base-uri ; ### Meta tag 配置 ```html - + ``` ### Apache 配置 @@ -66,12 +66,10 @@ add_header Content-Security-Policy "base-uri 'self';" 假如你的域名不是 `example.com`,那么将 {{HTMLElement("base")}} 元素的 `href` 属性值设置成 `https://example.com` 会违反 CSP 策略。 ```html example-bad - - + + -// Error: Refused to set the document's base URI to 'http://example.com/' -// because it violates the following Content Security Policy -// directive: "base-uri 'self'" + ``` ## 规范 diff --git a/files/zh-cn/web/http/headers/content-security-policy/block-all-mixed-content/index.md b/files/zh-cn/web/http/headers/content-security-policy/block-all-mixed-content/index.md index 37c74b894d2c50..93012db074bf29 100644 --- a/files/zh-cn/web/http/headers/content-security-policy/block-all-mixed-content/index.md +++ b/files/zh-cn/web/http/headers/content-security-policy/block-all-mixed-content/index.md @@ -1,5 +1,5 @@ --- -title: 'CSP: block-all-mixed-content' +title: "CSP: block-all-mixed-content" slug: Web/HTTP/Headers/Content-Security-Policy/block-all-mixed-content --- diff --git a/files/zh-cn/web/http/headers/content-security-policy/child-src/index.md b/files/zh-cn/web/http/headers/content-security-policy/child-src/index.md index 3c72c77005b368..083b2351db25b5 100644 --- a/files/zh-cn/web/http/headers/content-security-policy/child-src/index.md +++ b/files/zh-cn/web/http/headers/content-security-policy/child-src/index.md @@ -1,5 +1,5 @@ --- -title: 'CSP: child-src' +title: "CSP: child-src" slug: Web/HTTP/Headers/Content-Security-Policy/child-src --- diff --git a/files/zh-cn/web/http/headers/content-security-policy/connect-src/index.md b/files/zh-cn/web/http/headers/content-security-policy/connect-src/index.md index 17ce67d5b3db9a..f2f70d9642ccbd 100644 --- a/files/zh-cn/web/http/headers/content-security-policy/connect-src/index.md +++ b/files/zh-cn/web/http/headers/content-security-policy/connect-src/index.md @@ -1,5 +1,5 @@ --- -title: 'CSP: connect-src' +title: "CSP: connect-src" slug: Web/HTTP/Headers/Content-Security-Policy/connect-src --- @@ -76,7 +76,8 @@ Content-Security-Policy: connect-src https://example.com/ navigator.sendBeacon("https://not-example.com/", { /* … */ }); - + ``` ## 规范 diff --git a/files/zh-cn/web/http/headers/content-security-policy/default-src/index.md b/files/zh-cn/web/http/headers/content-security-policy/default-src/index.md index db3cf55469415d..28f31ab2026ce7 100644 --- a/files/zh-cn/web/http/headers/content-security-policy/default-src/index.md +++ b/files/zh-cn/web/http/headers/content-security-policy/default-src/index.md @@ -1,5 +1,5 @@ --- -title: 'CSP: default-src' +title: "CSP: default-src" slug: Web/HTTP/Headers/Content-Security-Policy/default-src --- @@ -19,8 +19,8 @@ slug: Web/HTTP/Headers/Content-Security-Policy/default-src - {{CSP("style-src")}} - {{CSP("worker-src")}} -| CSP 版本 | 1 | -| -------- | ---------------------------------------- | +| CSP 版本 | 1 | +| -------- | ------------------------------- | | 指令类型 | {{Glossary("Fetch directive")}} | ## 语法 @@ -42,12 +42,14 @@ Content-Security-Policy: default-src ; - `mail.example.com:443:`匹配对 mail.example.com 上的 443 端口号的访问。 - `https://store.example.com`: 匹配对使用了 https: 的 store.example.com 的访问。 - \ + - : 协议名如'http:' 或者 'https:'。**必须带有冒号,不要有单引号**。同时你还可以指定数据协议(data schema)(不推荐使用)。 - - `data:` 允许 [`data:` URIs](/zh-CN/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) 作为内容的源*。这是不安全的。攻击者可以注入任意 data: URI。不要轻易使用这种形式的源,尤其是脚本,绝对不要使用。 + - `data:` 允许 [`data:` URIs](/zh-CN/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) 作为内容的源。这是不安全的。攻击者可以注入任意 data: URI。不要轻易使用这种形式的源,尤其是脚本,绝对不要使用。 - `mediastream:` 允许 [`mediastream:` URIs](/zh-CN/docs/Web/API/MediaStream_API) 作为内容的源。 - `blob:` 允许 [`blob:` URIs](/zh-CN/docs/Web/API/Blob) 作为内容的源。 - `filesystem:` 允许 [`filesystem:` URIs](/zh-CN/docs/Web/API/FileSystem) 作为内容的源。 + - `'self'` - : 指向与要保护的文件所在的源,包括相同的 URL scheme 与端口号。必须有单引号。一些浏览器会特意排除 blob 与 filesystem。需要设定这两种内容类型的站点可以在 Data 属性中进行设定。 - `'unsafe-inline'` diff --git a/files/zh-cn/web/http/headers/content-security-policy/font-src/index.md b/files/zh-cn/web/http/headers/content-security-policy/font-src/index.md index f57469a1ac0406..eb0a597a49baf6 100644 --- a/files/zh-cn/web/http/headers/content-security-policy/font-src/index.md +++ b/files/zh-cn/web/http/headers/content-security-policy/font-src/index.md @@ -1,5 +1,5 @@ --- -title: 'CSP: font-src' +title: "CSP: font-src" slug: Web/HTTP/Headers/Content-Security-Policy/font-src --- diff --git a/files/zh-cn/web/http/headers/content-security-policy/form-action/index.md b/files/zh-cn/web/http/headers/content-security-policy/form-action/index.md index 0f9fb0439a38ba..57e1a24ed2a50b 100644 --- a/files/zh-cn/web/http/headers/content-security-policy/form-action/index.md +++ b/files/zh-cn/web/http/headers/content-security-policy/form-action/index.md @@ -1,5 +1,5 @@ --- -title: 'CSP: form-action' +title: "CSP: form-action" slug: Web/HTTP/Headers/Content-Security-Policy/form-action --- @@ -9,10 +9,10 @@ HTTP {{HTTPHeader("Content-Security-Policy")}} (CSP) 的 **`form-action`** 指 > **警告:** 在表单提交之后, `form-action` 指令是否应该阻止重定向仍有待讨论,各个浏览器对于此行为的实现也不尽相同(例如,Chrome 63 会阻止重定向,而 Firefox 57 则不会)。 -| CSP version | 2 | -| ------------------------------------- | ------------------------------------------------ | -| Directive type | {{Glossary("Navigation directive")}} | -| {{CSP("default-src")}} fallback | No. 未设定时允许任何值。 | +| CSP version | 2 | +| ------------------------------- | ------------------------------------ | +| Directive type | {{Glossary("Navigation directive")}} | +| {{CSP("default-src")}} fallback | No. 未设定时允许任何值。 | ## 语法 @@ -28,7 +28,7 @@ Content-Security-Policy: form-action ; ### meta 标签配置 ```html - + ``` ### Apache 服务器配置 @@ -50,15 +50,14 @@ add_header Content-Security-Policy "form-action 'none';" 将 {{HTMLElement("form")}} 元素的 action 设置为内联 JavaScript 会违反 CSP 规则。 ```html example-bad - +
- - + +
-// Error: Refused to send form data because it violates the following -// Content Security Policy directive: "form-action 'none'". + ``` ## 规范 diff --git a/files/zh-cn/web/http/headers/content-security-policy/frame-ancestors/index.md b/files/zh-cn/web/http/headers/content-security-policy/frame-ancestors/index.md index ddebf4c9c3e66b..f34d3cbbe3fbbb 100644 --- a/files/zh-cn/web/http/headers/content-security-policy/frame-ancestors/index.md +++ b/files/zh-cn/web/http/headers/content-security-policy/frame-ancestors/index.md @@ -54,12 +54,14 @@ Content-Security-Policy: frame-ancestors ; - `mail.example.com:443`: 匹配所有对于 mail.example.com 在 443 端口的访问意图。 - `https://store.example.com`: 匹配所有使用 https:访问 store.example.com 的意图。 - \ + - : 一个 schema 配置,比如'http:'或'https:'。注意,冒号是必要的。你同样也可以指定一个 data schema(但并不推荐)。 - '`data:`' 允许 [`data:` URIs](/zh-CN/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) 作为内容源。_这是不安全的,攻击者可以用此来注入恶意代码。请谨慎使用,并不要令其作用于脚本。_ - `'mediastream:'` 允许 [`mediastream:` URIs](/zh-CN/docs/Web/API/MediaStream_API) 作为内容源。 - `'blob:'` 允许 [`blob:` URIs](/zh-CN/docs/Web/API/Blob) 作为内容源。 - `'filesystem:'` 允许 [`filesystem:` URIs](/zh-CN/docs/Web/API/FileSystem) 作为内容源。 + - `'self'` - : 指向一个该受保护文档所在的源,包含同样的 URL schema 和端口号。必须用单引号设置。有些浏览器会从源指令中排`除 blob`和`filesystem`。需要允许这些内容类型的站点可以通过 Data 属性指定它们。 - `'none'` diff --git a/files/zh-cn/web/http/headers/content-security-policy/index.md b/files/zh-cn/web/http/headers/content-security-policy/index.md index b818b70d93f12b..2a62c57843953e 100644 --- a/files/zh-cn/web/http/headers/content-security-policy/index.md +++ b/files/zh-cn/web/http/headers/content-security-policy/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/Content-Security-Policy 如需更多信息,请查阅[Content Security Policy (CSP)](/zh-CN/docs/Web/HTTP/CSP)。 -| 头部类型 | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| 头部类型 | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 @@ -24,6 +24,7 @@ Content-Security-Policy: ; 通过获取指令来控制某些可能被加载的确切的资源类型的位置。 - {{CSP("child-src")}} + - : **child-src**:为 [Web Workers](/zh-CN/docs/Web/API/Web_Workers_API) 和其他内嵌浏览器内容(例如用 {{HTMLElement("frame")}} 和 {{HTMLElement("iframe")}} 加载到页面的内容)定义合法的源地址。 > **警告:** 如果开发者希望管控内嵌浏览器内容和 web worker 应分别使用 {{CSP("frame-src")}} 和 {{CSP("worker-src")}} 指令,来相对的取代 **`child-src`**。 diff --git a/files/zh-cn/web/http/headers/content-security-policy/sandbox/index.md b/files/zh-cn/web/http/headers/content-security-policy/sandbox/index.md index c4a67af9d6543d..058cbea75288e3 100644 --- a/files/zh-cn/web/http/headers/content-security-policy/sandbox/index.md +++ b/files/zh-cn/web/http/headers/content-security-policy/sandbox/index.md @@ -1,5 +1,5 @@ --- -title: 'CSP: sandbox' +title: "CSP: sandbox" slug: Web/HTTP/Headers/Content-Security-Policy/sandbox --- diff --git a/files/zh-cn/web/http/headers/content-security-policy/script-src-elem/index.md b/files/zh-cn/web/http/headers/content-security-policy/script-src-elem/index.md index 76942856c6ec3c..6bfec8420901b1 100644 --- a/files/zh-cn/web/http/headers/content-security-policy/script-src-elem/index.md +++ b/files/zh-cn/web/http/headers/content-security-policy/script-src-elem/index.md @@ -1,5 +1,5 @@ --- -title: 'CSP: script-src-elem' +title: "CSP: script-src-elem" slug: Web/HTTP/Headers/Content-Security-Policy/script-src-elem --- diff --git a/files/zh-cn/web/http/headers/content-security-policy/upgrade-insecure-requests/index.md b/files/zh-cn/web/http/headers/content-security-policy/upgrade-insecure-requests/index.md index dce9566d8bdbd6..45dc909f7d2763 100644 --- a/files/zh-cn/web/http/headers/content-security-policy/upgrade-insecure-requests/index.md +++ b/files/zh-cn/web/http/headers/content-security-policy/upgrade-insecure-requests/index.md @@ -1,5 +1,5 @@ --- -title: 'CSP: upgrade-insecure-requests' +title: "CSP: upgrade-insecure-requests" slug: Web/HTTP/Headers/Content-Security-Policy/upgrade-insecure-requests --- @@ -30,15 +30,15 @@ Content-Security-Policy: upgrade-insecure-requests; 一旦将上述头部设置在计划从 HTTP 迁移到 HTTPS 的 example.com 域名上,非跳转 (non-navigational) 的不安全资源请求会自动升级到 HTTPS(包括第当前域名以及第三方请求)。 ```html - - + + ``` 这些 URL 在请求发送之前都会被改写成 HTTPS,也就意味着不安全的请求都不会发送出去。注意,如果请求的资源在 HTTPS 情况下不可用,则该请求将失败,其也不能回退到 HTTP。 ```html - - + + ``` Navigational upgrades to third-party resources brings a significantly higher potential for breakage, these are not upgraded: diff --git a/files/zh-cn/web/http/headers/content-security-policy/worker-src/index.md b/files/zh-cn/web/http/headers/content-security-policy/worker-src/index.md index af643d2d8e67d0..c1ae59140a6918 100644 --- a/files/zh-cn/web/http/headers/content-security-policy/worker-src/index.md +++ b/files/zh-cn/web/http/headers/content-security-policy/worker-src/index.md @@ -1,5 +1,5 @@ --- -title: 'CSP: worker-src' +title: "CSP: worker-src" slug: Web/HTTP/Headers/Content-Security-Policy/worker-src --- diff --git a/files/zh-cn/web/http/headers/content-type/index.md b/files/zh-cn/web/http/headers/content-type/index.md index 91c584382f594f..3bde2c4dc07ff6 100644 --- a/files/zh-cn/web/http/headers/content-type/index.md +++ b/files/zh-cn/web/http/headers/content-type/index.md @@ -11,10 +11,10 @@ slug: Web/HTTP/Headers/Content-Type 在请求中 (如{{HTTPMethod("POST")}} 或 {{HTTPMethod("PUT")}}),客户端告诉服务器实际发送的数据类型。 -| Header type | {{Glossary("Entity header")}} | -| ------------------------------------------------------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | -| {{Glossary("Simple response header", "CORS-safelisted response-header")}} | yes | +| Header type | {{Glossary("Entity header")}} | +| ------------------------------------------------------------------------- | ----------------------------- | +| {{Glossary("Forbidden header name")}} | no | +| {{Glossary("Simple response header", "CORS-safelisted response-header")}} | yes | ## 句法 @@ -40,8 +40,8 @@ Content-Type: multipart/form-data; boundary=something ```html
- - + +
``` diff --git a/files/zh-cn/web/http/headers/cross-origin-embedder-policy/index.md b/files/zh-cn/web/http/headers/cross-origin-embedder-policy/index.md index d3e30aaba604d4..9e70e09724362b 100644 --- a/files/zh-cn/web/http/headers/cross-origin-embedder-policy/index.md +++ b/files/zh-cn/web/http/headers/cross-origin-embedder-policy/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/Cross-Origin-Embedder-Policy HTTP **`Cross-Origin-Embedder-Policy`** (COEP) 响应标头可防止文档加载未明确授予文档权限 (通过 [CORP]() 或者 [CORS](/zh-CN/docs/Web/HTTP/CORS)) 的任何跨域资源。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 @@ -53,7 +53,7 @@ if (crossOriginIsolated) { If you enable COEP using `require-corp` and have a cross origin resource that needs to be loaded, it needs to support [CORS](/zh-CN/docs/Web/HTTP/CORS) and you need to explicitly mark the resource as loadable from another origin to avoid blockage from COEP. For example, you can use the [`crossorigin`](/zh-CN/docs/Web/HTML/Attributes/crossorigin) attribute for this image from a third-party site: ```html - + ``` ## 规范 diff --git a/files/zh-cn/web/http/headers/cross-origin-resource-policy/index.md b/files/zh-cn/web/http/headers/cross-origin-resource-policy/index.md index d44b8d870940f4..851e9b18b5f96b 100644 --- a/files/zh-cn/web/http/headers/cross-origin-resource-policy/index.md +++ b/files/zh-cn/web/http/headers/cross-origin-resource-policy/index.md @@ -9,9 +9,9 @@ slug: Web/HTTP/Headers/Cross-Origin-Resource-Policy **`Cross-Origin-Resource-Policy`** 响应头会指示浏览器阻止对指定资源的无源跨域/跨站点请求。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/date/index.md b/files/zh-cn/web/http/headers/date/index.md index ae358f2cee7382..c5a598e9206a56 100644 --- a/files/zh-cn/web/http/headers/date/index.md +++ b/files/zh-cn/web/http/headers/date/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/Date **`Date`** 是一个通用首部,其中包含了报文创建的日期和时间。 -| Header type | {{Glossary("General header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | yes | +| Header type | {{Glossary("General header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | yes | ## 语法 diff --git a/files/zh-cn/web/http/headers/device-memory/index.md b/files/zh-cn/web/http/headers/device-memory/index.md index 1d542116d1de5c..ec361f7003ec7e 100644 --- a/files/zh-cn/web/http/headers/device-memory/index.md +++ b/files/zh-cn/web/http/headers/device-memory/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/Device-Memory **`Device-Memory`** 是一个跟 [Device Memory API](/zh-CN/docs/Web/API/Device_Memory_API) 相关的请求头,它跟 [Client Hints](/zh-CN/docs/Glossary/Client_hints) 请求头的作用相似,用来表示客户端设备内存的近似大小。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | ? | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | ? | > **备注:** Client Hints are accessible only on secure origins (via TLS). Server has to opt in to receive `Device-Memory` header from the client by sending {{HTTPHeader("Accept-CH")}} and {{HTTPHeader("Accept-CH-Lifetime")}} response headers. diff --git a/files/zh-cn/web/http/headers/digest/index.md b/files/zh-cn/web/http/headers/digest/index.md index d72bc8bf1fee6a..229116fb94b9f2 100644 --- a/files/zh-cn/web/http/headers/digest/index.md +++ b/files/zh-cn/web/http/headers/digest/index.md @@ -15,9 +15,9 @@ slug: Web/HTTP/Headers/Digest - 完全不包含在消息体中中 (例如,在一个 [`HEAD`](/zh-CN/docs/Web/HTTP/Methods/HEAD) 请求的响应中) - 部分包含在消息体中 (例如,在一个 [range request](/zh-CN/docs/Web/HTTP/Range_requests) 的响应中)。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/dnt/index.md b/files/zh-cn/web/http/headers/dnt/index.md index 2f37aeeee1ee01..709c4b96a5c443 100644 --- a/files/zh-cn/web/http/headers/dnt/index.md +++ b/files/zh-cn/web/http/headers/dnt/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/DNT 请求首部 **`DNT`** (**D**o **N**ot **T**rack) 表明了用户对于网站追踪的偏好。它允许用户指定自己是否更注重个人隐私还是定制化内容。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | yes | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | yes | ## 语法 diff --git a/files/zh-cn/web/http/headers/dpr/index.md b/files/zh-cn/web/http/headers/dpr/index.md index bf85cf28ef1fee..87ba548558380c 100644 --- a/files/zh-cn/web/http/headers/dpr/index.md +++ b/files/zh-cn/web/http/headers/dpr/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/DPR **`DPR`**请求头是“ [客户端提示”](/zh-CN/docs/Glossary/Client_hints)消息头,它代表客户端设备的像素比 ({{Glossary("DPR")}}),该比例是与每个 CSS 像素相对应的物理设备像素的数量。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | ? | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | ? | > **备注:** Client Hints are accessible only on secure origins (via TLS). Server has to opt in to receive `DPR` header from the client by sending {{HTTPHeader("Accept-CH")}} and {{HTTPHeader("Accept-CH-Lifetime")}} response headers. diff --git a/files/zh-cn/web/http/headers/early-data/index.md b/files/zh-cn/web/http/headers/early-data/index.md index 9b2c0f9d61593b..022e2f476dca9b 100644 --- a/files/zh-cn/web/http/headers/early-data/index.md +++ b/files/zh-cn/web/http/headers/early-data/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/Early-Data **`Early-Data`** 头(header)由某个中间者设置来表示请求已在 TLS early data 中传送,且表示 某个中间者理解 {{HTTPStatus("425", "425 (Too Early)")}} 状态码。**`Early-Data`** 头(header)不由请求的发起者设置 (例如,浏览器)。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/etag/index.md b/files/zh-cn/web/http/headers/etag/index.md index 48d5a4712a60ea..8286df2faedd5a 100644 --- a/files/zh-cn/web/http/headers/etag/index.md +++ b/files/zh-cn/web/http/headers/etag/index.md @@ -9,9 +9,9 @@ slug: Web/HTTP/Headers/ETag 如果给定 URL 中的资源更改,则*一定*要生成新的 `ETag` 值。比较这些 `ETag` 能快速确定此资源是否变化。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/expect-ct/index.md b/files/zh-cn/web/http/headers/expect-ct/index.md index 1e731b0b99d813..1607bf62b40a49 100644 --- a/files/zh-cn/web/http/headers/expect-ct/index.md +++ b/files/zh-cn/web/http/headers/expect-ct/index.md @@ -43,14 +43,19 @@ Expect-CT: report-uri="", ## 指令 - `max-age` + - : 该指令指定接收到 `Expect-CT` 标头后的秒数,在此期间用户代理应将收到消息的主机视为已知的 `Expect-CT` 主机。 如果缓存接收到的值大于它可以表示的值,或者如果其随后的计算溢出,则缓存将认为该值为 2147483648(2 的 31 次幂)或其可以表示的最大正整数。 + - `report-uri=""` {{optional_inline}} + - : 该指令指定用户代理报告 `Expect-CT` 错误的 URI。 当和 `enforce` 指令共同存在时,这种配置被称为“强制执行和报告”配置,示意用户代理既应该强制遵守证书透明度政策,也应当报告违规行为。 + - `enforce` {{optional_inline}} + - : 该指令示意用户代理应强制遵守证书透明度政策(而不是只报告合规性),并且用户代理应拒绝违反证书透明度政策的之后连接。 当 `enforce` 指令和 `report-uri` 指令共同存在时,这种配置被称为“强制执行和报告”配置,示意用户代理既应该强制遵守证书透明度政策,也应当报告违规行为。 diff --git a/files/zh-cn/web/http/headers/expect/index.md b/files/zh-cn/web/http/headers/expect/index.md index a9d06d51d1b7f4..3730c100366c86 100644 --- a/files/zh-cn/web/http/headers/expect/index.md +++ b/files/zh-cn/web/http/headers/expect/index.md @@ -16,9 +16,9 @@ slug: Web/HTTP/Headers/Expect 常见的浏览器不会发送 `Expect` 消息头,但是其他类型的客户端如 cURL 默认会这么做。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/expires/index.md b/files/zh-cn/web/http/headers/expires/index.md index 6f53db7fed1d16..56a55fce4aca3f 100644 --- a/files/zh-cn/web/http/headers/expires/index.md +++ b/files/zh-cn/web/http/headers/expires/index.md @@ -9,10 +9,10 @@ slug: Web/HTTP/Headers/Expires 如果在{{HTTPHeader("Cache-Control")}}响应头设置了 "max-age" 或者 "s-max-age" 指令,那么 `Expires` 头会被忽略。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | -| {{Glossary("Simple response header", "CORS-safelisted response-header")}} | yes | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | +| {{Glossary("Simple response header", "CORS-safelisted response-header")}} | yes | ## 语法 diff --git a/files/zh-cn/web/http/headers/forwarded/index.md b/files/zh-cn/web/http/headers/forwarded/index.md index 79f94a7d15b3e9..faf48605d17e6b 100644 --- a/files/zh-cn/web/http/headers/forwarded/index.md +++ b/files/zh-cn/web/http/headers/forwarded/index.md @@ -11,9 +11,9 @@ slug: Web/HTTP/Headers/Forwarded 这个消息首部会被用来进行调试和统计,以及生成基于位置的定制化内容,按照设计的目的,它会暴露一定的隐私和敏感信息,比如客户端的 IP 地址。所以在应用此消息首部的时候,需要将用户的隐私问题考虑在内。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | no | ## 语法 @@ -24,11 +24,13 @@ Forwarded: by=; for=; host=; proto= ## 指令 - \ + - : 一个 identifier 显示了在使用代理的过程中被修改或者丢失的信息。它们可以是以下几种形式: - 一个 IP 地址(V4 或 V6,端口号可选,ipv6 地址需要包含在方括号里面,同时用引号括起来), - 语意不明的标识符(比如 "\_hidden" 或者 "\_secret"), - 或者是 "unknown",当当前信息实体不可知的时候(但是你依然想要说明请求被进行了转发)。 + - by=\ - : 该请求进入到代理服务器的接口。 - for=\ diff --git a/files/zh-cn/web/http/headers/from/index.md b/files/zh-cn/web/http/headers/from/index.md index 49eb64d7a38910..b280279794a0cb 100644 --- a/files/zh-cn/web/http/headers/from/index.md +++ b/files/zh-cn/web/http/headers/from/index.md @@ -11,9 +11,9 @@ slug: Web/HTTP/Headers/From > **警告:** 不可以将 From 首部用于访问控制或者身份验证。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/host/index.md b/files/zh-cn/web/http/headers/host/index.md index 0e2004794b8e80..c4a0beef7f5434 100644 --- a/files/zh-cn/web/http/headers/host/index.md +++ b/files/zh-cn/web/http/headers/host/index.md @@ -11,9 +11,9 @@ slug: Web/HTTP/Headers/Host 所有 HTTP/1.1 请求报文中必须包含一个`Host`头字段。对于缺少`Host`头或者含有超过一个`Host`头的 HTTP/1.1 请求,可能会收到{{HTTPStatus("400")}}(Bad Request)状态码。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | yes | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | yes | ## 语法 diff --git a/files/zh-cn/web/http/headers/if-match/index.md b/files/zh-cn/web/http/headers/if-match/index.md index 1eb1db4b5758b5..d438459db10c8d 100644 --- a/files/zh-cn/web/http/headers/if-match/index.md +++ b/files/zh-cn/web/http/headers/if-match/index.md @@ -14,9 +14,9 @@ slug: Web/HTTP/Headers/If-Match - 对于 {{HTTPMethod("GET")}} 和 {{HTTPMethod("HEAD")}} 方法,搭配 {{HTTPHeader("Range")}}首部使用,可以用来保证新请求的范围与之前请求的范围是对同一份资源的请求。如果 ETag 无法匹配,那么需要返回 {{HTTPStatus("416")}} (Range Not Satisfiable,范围请求无法满足) 响应。 - 对于其他方法来说,尤其是 {{HTTPMethod("PUT")}}, `If-Match` 首部可以用来避免[更新丢失问题](https://www.w3.org/1999/04/Editing/#3.1)。它可以用来检测用户想要上传的不会覆盖获取原始资源之后做出的更新。如果请求的条件不满足,那么需要返回 {{HTTPStatus("412")}} (Precondition Failed,先决条件失败) 响应。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/if-modified-since/index.md b/files/zh-cn/web/http/headers/if-modified-since/index.md index e1e81be5631f09..a8d0214ca1d7d9 100644 --- a/files/zh-cn/web/http/headers/if-modified-since/index.md +++ b/files/zh-cn/web/http/headers/if-modified-since/index.md @@ -11,9 +11,9 @@ slug: Web/HTTP/Headers/If-Modified-Since 最常见的应用场景是来更新没有特定 {{HTTPHeader("ETag")}} 标签的缓存实体。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/if-none-match/index.md b/files/zh-cn/web/http/headers/if-none-match/index.md index 65134495dd3e26..c6c844fb6c1e7a 100644 --- a/files/zh-cn/web/http/headers/if-none-match/index.md +++ b/files/zh-cn/web/http/headers/if-none-match/index.md @@ -18,9 +18,9 @@ slug: Web/HTTP/Headers/If-None-Match - 采用 {{HTTPMethod("GET")}} 或 {{HTTPMethod("HEAD")}} 方法,来更新拥有特定的{{HTTPHeader("ETag")}} 属性值的缓存。 - 采用其他方法,尤其是 {{HTTPMethod("PUT")}},将 `If-None-Match` used 的值设置为 \* ,用来生成事先并不知道是否存在的文件,可以确保先前并没有进行过类似的上传操作,防止之前操作数据的丢失。这个问题属于[更新丢失问题](https://www.w3.org/1999/04/Editing/#3.1)的一种。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/if-range/index.md b/files/zh-cn/web/http/headers/if-range/index.md index e4837aed46665b..0789c0f65c4ccc 100644 --- a/files/zh-cn/web/http/headers/if-range/index.md +++ b/files/zh-cn/web/http/headers/if-range/index.md @@ -11,9 +11,9 @@ slug: Web/HTTP/Headers/If-Range **`If-Range`** 头字段通常用于断点续传的下载过程中,用来自从上次中断后,确保下载的资源没有发生改变。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/if-unmodified-since/index.md b/files/zh-cn/web/http/headers/if-unmodified-since/index.md index 5a301211fdccf8..418225755ede59 100644 --- a/files/zh-cn/web/http/headers/if-unmodified-since/index.md +++ b/files/zh-cn/web/http/headers/if-unmodified-since/index.md @@ -12,9 +12,9 @@ HTTP 协议中的 **`If-Unmodified-Since`** 消息头用于请求之中,使得 - 与 non-{{Glossary("safe")}} 方法如 {{HTTPMethod("POST")}} 搭配使用,可以用来[优化并发控制](https://en.wikipedia.org/wiki/Optimistic_concurrency_control),例如在某些 wiki 应用中的做法:假如在原始副本获取之后,服务器上所存储的文档已经被修改,那么对其作出的编辑会被拒绝提交。 - 与含有 {{HTTPHeader("If-Range")}} 消息头的范围请求搭配使用,用来确保新的请求片段来自于未经修改的文档。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/keep-alive/index.md b/files/zh-cn/web/http/headers/keep-alive/index.md index b363ec95e806b0..c0d3464710a485 100644 --- a/files/zh-cn/web/http/headers/keep-alive/index.md +++ b/files/zh-cn/web/http/headers/keep-alive/index.md @@ -9,9 +9,9 @@ slug: Web/HTTP/Headers/Keep-Alive > **备注:** 需要将 The {{HTTPHeader("Connection")}} 首部的值设置为 "keep-alive" 这个首部才有意义。同时需要注意的是,在 HTTP/2 协议中, {{HTTPHeader("Connection")}} 和 {{HTTPHeader("Keep-Alive")}} 是被忽略的;在其中采用其他机制来进行连接管理。 -| Header type | {{Glossary("General header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("General header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | no | ## 语法 @@ -22,6 +22,7 @@ Keep-Alive: parameters ## 指令 - _parameters_ + - : 一系列用逗号隔开的参数,每一个参数由一个标识符和一个值构成,并使用等号 (`'='`) 隔开。下述标识符是可用的: - `timeout`:指定了一个空闲连接需要保持打开状态的最小时长(以秒为单位)。需要注意的是,如果没有在传输层设置 keep-alive TCP message 的话,大于 TCP 层面的超时设置会被忽略。 diff --git a/files/zh-cn/web/http/headers/large-allocation/index.md b/files/zh-cn/web/http/headers/large-allocation/index.md index da973984e4e184..2058f7af5ca20b 100644 --- a/files/zh-cn/web/http/headers/large-allocation/index.md +++ b/files/zh-cn/web/http/headers/large-allocation/index.md @@ -9,9 +9,9 @@ slug: Web/HTTP/Headers/Large-Allocation [WebAssembly](/zh-CN/docs/WebAssembly) 或者 asm.js 会使用比较大的连续内存空间。例如,对于一些复杂的游戏,其申请的空间将会非常大,甚至会达到 1GB。`Large-Allocation` 告诉浏览器其将要加载的页面可能需要申请一个大的连续内存空间,浏览器依据该头部可能会单独启动一个专有的进程用于处理该页面。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 @@ -43,11 +43,13 @@ Large-Allocation: 500 - `Large-Allocation` 报头由于非`non-GET 请求而直接忽略` - : 当一个 {{HTTPMethod("POST")}} 请求用语加载文档,that load cannot currently be redirected into a new process. This error is displayed when loading a document with a `Large-Allocation` header with a non-GET HTTP method. This could be caused due to the document being loaded by a form submission, for example. - A `Large-Allocation` header was ignored due to the presence of windows which have a reference to this browsing context through the frame hierarchy or {{domxref("window.opener")}}. + - : This error means that the document was not loaded at the top level of an user-opened or noopener-opened tab or window. It can occur in these situations: - The document with the `Large-Allocation` header was loaded in an {{HTMLElement("iframe")}}. Firefox cannot move an iframe into a new process currently, so the document must load in the current process. - The document with the `Large-Allocation` header was loaded in a window which was opened by {{domxref("window.open()")}}, `` or other similar methods without `rel="noopener"` or the `"noopener"` feature being set. These windows must remain in the same process as their opener, as they can communicate, meaning that we cannot allow them to switch processes. - The document with the `Large-Allocation header` has opened another window with {{domxref("window.open()")}}, `` or other similar methods without `rel="noopener"` or the `"noopener"` feature being set. This is for the same reason as above, namely that they can communicate and thus we cannot allow them to switch processes. + - `Large-Allocation` 报头由于 文档在加载过程没有被加载而直接忽略 - : Firefox has moved to a [multiprocess architecture](/zh-CN/docs/Mozilla/Firefox/Multiprocess_Firefox), and this architecture is required in order to support the `Large-Allocation` header. Some [legacy Addons](/zh-CN/docs/Mozilla/Add-ons/SDK) can prevent Firefox from using this new, faster, multiprocess architecture. If you have one of these Addons installed, then we will continue to use the old single process architecuture for compatibility, and cannot handle the `Large-Allocation` header. - 由于`Large-Allocation`头部,此页面应将被加载到新进程中,但是在非 Win32 平台上禁用此选项。 diff --git a/files/zh-cn/web/http/headers/last-modified/index.md b/files/zh-cn/web/http/headers/last-modified/index.md index a45a6946ba613b..009b6085fc6967 100644 --- a/files/zh-cn/web/http/headers/last-modified/index.md +++ b/files/zh-cn/web/http/headers/last-modified/index.md @@ -7,10 +7,10 @@ slug: Web/HTTP/Headers/Last-Modified **`Last-Modified`** 是一个响应首部,其中包含源头服务器认定的资源做出修改的日期及时间。它通常被用作一个验证器来判断接收到的或者存储的资源是否彼此一致。由于精确度比 {{HTTPHeader("ETag")}} 要低,所以这是一个备用机制。包含有 {{HTTPHeader("If-Modified-Since")}} 或 {{HTTPHeader("If-Unmodified-Since")}} 首部的条件请求会使用这个字段。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | -| {{Glossary("Simple response header", "CORS-safelisted response-header")}} | yes | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | +| {{Glossary("Simple response header", "CORS-safelisted response-header")}} | yes | ## 语法 diff --git a/files/zh-cn/web/http/headers/location/index.md b/files/zh-cn/web/http/headers/location/index.md index ad8a949d22d92b..c42dbca0cf0802 100644 --- a/files/zh-cn/web/http/headers/location/index.md +++ b/files/zh-cn/web/http/headers/location/index.md @@ -18,9 +18,9 @@ slug: Web/HTTP/Headers/Location [`Location`](/zh-CN/docs/Web/HTTP/Headers/Location) 与 `Content-Location`是不同的,前者([`Location`](/zh-CN/docs/Web/HTTP/Headers/Location) )指定的是一个重定向请求的目的地址(或者新创建的文件的 URL),而后者( `Content-Location`)指向的是经过内容协商后的资源的直接地址,不需要进行进一步的内容协商。Location 对应的是响应,而 Content-Location 对应的是要返回的实体。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/permissions-policy/autoplay/index.md b/files/zh-cn/web/http/headers/permissions-policy/autoplay/index.md index 679cab57477dd9..5460eeffb3a4f7 100644 --- a/files/zh-cn/web/http/headers/permissions-policy/autoplay/index.md +++ b/files/zh-cn/web/http/headers/permissions-policy/autoplay/index.md @@ -1,5 +1,5 @@ --- -title: 'Permissions-Policy: autoplay' +title: "Permissions-Policy: autoplay" slug: Web/HTTP/Headers/Permissions-Policy/autoplay --- diff --git a/files/zh-cn/web/http/headers/permissions-policy/camera/index.md b/files/zh-cn/web/http/headers/permissions-policy/camera/index.md index 51c3e854f1cc1e..ff522d774fdd8a 100644 --- a/files/zh-cn/web/http/headers/permissions-policy/camera/index.md +++ b/files/zh-cn/web/http/headers/permissions-policy/camera/index.md @@ -1,5 +1,5 @@ --- -title: 'Permissions-Policy: camera' +title: "Permissions-Policy: camera" slug: Web/HTTP/Headers/Permissions-Policy/camera original_slug: Web/HTTP/Headers/Feature-Policy/camera --- diff --git a/files/zh-cn/web/http/headers/permissions-policy/index.md b/files/zh-cn/web/http/headers/permissions-policy/index.md index fad4113b48c4be..b4ec73e22af696 100644 --- a/files/zh-cn/web/http/headers/permissions-policy/index.md +++ b/files/zh-cn/web/http/headers/permissions-policy/index.md @@ -9,9 +9,9 @@ slug: Web/HTTP/Headers/Permissions-Policy 更多的信息,请查看[Feature Policy](/zh-CN/docs/Web/HTTP/Feature_Policy) -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | yes | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | yes | ## 语法 diff --git a/files/zh-cn/web/http/headers/permissions-policy/picture-in-picture/index.md b/files/zh-cn/web/http/headers/permissions-policy/picture-in-picture/index.md index 9efab1ad03caaf..a817c3b937ecf0 100644 --- a/files/zh-cn/web/http/headers/permissions-policy/picture-in-picture/index.md +++ b/files/zh-cn/web/http/headers/permissions-policy/picture-in-picture/index.md @@ -1,5 +1,5 @@ --- -title: 'Permissions-Policy: picture-in-picture' +title: "Permissions-Policy: picture-in-picture" slug: Web/HTTP/Headers/Permissions-Policy/picture-in-picture --- diff --git a/files/zh-cn/web/http/headers/pragma/index.md b/files/zh-cn/web/http/headers/pragma/index.md index 6be982fa896dbb..d8c9d19d04f2f9 100644 --- a/files/zh-cn/web/http/headers/pragma/index.md +++ b/files/zh-cn/web/http/headers/pragma/index.md @@ -9,10 +9,10 @@ slug: Web/HTTP/Headers/Pragma > **备注:** 由于 Pragma 在 HTTP 响应中的行为没有确切规范,所以不能可靠替代 HTTP/1.1 中通用首部 Cache-Control,尽管在请求中,假如 Cache-Control 不存在的话,它的行为与 Cache-Control: no-cache 一致。建议只在需要兼容 HTTP/1.0 客户端的场合下应用 Pragma 首部。 -| Header type | {{Glossary("General header")}}, but response behavior is not specified and thus implementation-specific. | -| ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | -| {{Glossary("Forbidden header name")}} | no | -| {{Glossary("Simple response header", "CORS-safelisted response-header")}} | yes | +| Header type | {{Glossary("General header")}}, but response behavior is not specified and thus implementation-specific. | +| ------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | +| {{Glossary("Forbidden header name")}} | no | +| {{Glossary("Simple response header", "CORS-safelisted response-header")}} | yes | ## 语法 diff --git a/files/zh-cn/web/http/headers/proxy-authenticate/index.md b/files/zh-cn/web/http/headers/proxy-authenticate/index.md index d1371897e4bec4..fed042e25d0d94 100644 --- a/files/zh-cn/web/http/headers/proxy-authenticate/index.md +++ b/files/zh-cn/web/http/headers/proxy-authenticate/index.md @@ -9,9 +9,9 @@ The HTTP **`Proxy-Authenticate`** 是一个响应首部,指定了获取 {{Glos `Proxy-Authenticate` 首部需要与 {{HTTPStatus("407")}} `Proxy Authentication Required` 响应一起发送。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/proxy-authorization/index.md b/files/zh-cn/web/http/headers/proxy-authorization/index.md index 1e9a1eaaea0417..a35dba3bcb893c 100644 --- a/files/zh-cn/web/http/headers/proxy-authorization/index.md +++ b/files/zh-cn/web/http/headers/proxy-authorization/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/Proxy-Authorization **`Proxy-Authorization`** 是一个请求首部,其中包含了用户代理提供给代理服务器的用于身份验证的凭证。这个首部通常是在服务器返回了 {{HTTPStatus("407")}} `Proxy Authentication Required` 响应状态码及 {{HTTPHeader("Proxy-Authenticate")}} 首部后发送的。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | no | ## 语法 @@ -22,6 +22,7 @@ Proxy-Authorization: - \ - : [身份验证类型](/zh-CN/docs/Web/HTTP/Authentication#Authentication_schemes)。一个常见的类型是 ["基本验证"。](/zh-CN/docs/Web/HTTP/Authentication#Basic_authentication_scheme)IANA 机构维护了 [一系列的身份验证机制](http://www.iana.org/assignments/http-authschemes/http-authschemes.xhtml)。 - \ + - : 凭证的构成方式如下: - 将用户名和密码用冒号拼接(aladdin:opensesame)。 diff --git a/files/zh-cn/web/http/headers/range/index.md b/files/zh-cn/web/http/headers/range/index.md index 1c0dd6d7c5de8a..99ea24aff1ae34 100644 --- a/files/zh-cn/web/http/headers/range/index.md +++ b/files/zh-cn/web/http/headers/range/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/Range The **`Range`** 是一个请求首部,告知服务器返回文件的哪一部分。在一个 `Range` 首部中,可以一次性请求多个部分,服务器会以 multipart 文件的形式将其返回。如果服务器返回的是范围响应,需要使用 {{HTTPStatus("206")}} `Partial Content` 状态码。假如所请求的范围不合法,那么服务器会返回 {{HTTPStatus("416")}} `Range Not Satisfiable` 状态码,表示客户端错误。服务器允许忽略 `Range` 首部,从而返回整个文件,状态码用 {{HTTPStatus("200")}} 。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/referer/index.md b/files/zh-cn/web/http/headers/referer/index.md index 41f799becd1570..45645883c987f5 100644 --- a/files/zh-cn/web/http/headers/referer/index.md +++ b/files/zh-cn/web/http/headers/referer/index.md @@ -16,9 +16,9 @@ slug: Web/HTTP/Headers/Referer - 来源页面采用的协议为表示本地文件的 "file" 或者 "data" URI; - 当前请求页面采用的是非安全协议,而来源页面采用的是安全协议(HTTPS)。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | yes | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | yes | ## 语法 diff --git a/files/zh-cn/web/http/headers/referrer-policy/index.md b/files/zh-cn/web/http/headers/referrer-policy/index.md index 04ce4ae2aa2fa8..2d3135d3196e0c 100644 --- a/files/zh-cn/web/http/headers/referrer-policy/index.md +++ b/files/zh-cn/web/http/headers/referrer-policy/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/Referrer-Policy **`Referrer-Policy`** 首部用来监管哪些访问来源信息——会在 {{HTTPHeader("Referer")}} 中发送——应该被包含在生成的请求当中。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 @@ -43,6 +43,7 @@ Referrer-Policy: unsafe-url - strict-origin-when-cross-origin - : 对于同源的请求,会发送完整的 URL 作为引用地址;在同等安全级别的情况下,发送文件的源作为引用地址 (HTTPS->HTTPS);在降级的情况下不发送此首部 (HTTPS->HTTP)。 - unsafe-url + - : 无论是同源请求还是非同源请求,都发送完整的 URL(移除参数信息之后)作为引用地址。 > **备注:** 这项设置会将受 TLS 安全协议保护的资源的源和路径信息泄露给非安全的源服务器。进行此项设置的时候要慎重考虑。 @@ -76,25 +77,25 @@ CSS 可以从样式表获取引用的资源,这些资源也可以遵从 referr ## 示例 -| Policy | Document | Navigation to | Referrer | -| ------------------------------------- | -------------------------------- | ---------------------------------- | ----------------------------- | -| **`no-referrer`** | `https://example.com/page.html` | any domain or path | no referrer | -| **`no-referrer-when-downgrade`** | `https://example.com/page.html` | `https://example.com/otherpage.html` | `https://example.com/page.html` | -| **`no-referrer-when-downgrade`** | `https://example.com/page.html` | `https://mozilla.org` | `https://example.com/page.html` | -| **`no-referrer-when-downgrade`** | `https://example.com/page.html` | **http**://example.org | no referrer | -| **`origin`** | `https://example.com/page.html` | any domain or path | `https://example.com/` | -| **`origin-when-cross-origin`** | `https://example.com/page.html` | `https://example.com/otherpage.html` | `https://example.com/page.html` | -| **`origin-when-cross-origin`** | `https://example.com/page.html` | `https://mozilla.org` | `https://example.com/` | -| **`origin-when-cross-origin`** | `https://example.com/page.html` | **http**://example.com/page.html | `https://example.com/` | -| **`same-origin`** | `https://example.com/page.html` | `https://example.com/otherpage.html` | `https://example.com/page.html` | -| **`same-origin`** | `https://example.com/page.html` | `https://mozilla.org` | no referrer | -| **`strict-origin`** | `https://example.com/page.html` | `https://mozilla.org` | `https://example.com/` | -| **`strict-origin`** | `https://example.com/page.html` | **http**://example.org | no referrer | -| **`strict-origin`** | **http**://example.com/page.html | any domain or path | `http://example.com/` | -| **`strict-origin-when-cross-origin`** | `https://example.com/page.html` | `https://example.com/otherpage.html` | `https://example.com/page.html` | -| **`strict-origin-when-cross-origin`** | `https://example.com/page.html` | `https://mozilla.org` | `https://example.com/` | -| **`strict-origin-when-cross-origin`** | `https://example.com/page.html` | **http**://example.org | no referrer | -| **`unsafe-url`** | `https://example.com/page.html` | any domain or path | `https://example.com/page.html` | +| Policy | Document | Navigation to | Referrer | +| ------------------------------------- | -------------------------------- | ------------------------------------ | ------------------------------- | +| **`no-referrer`** | `https://example.com/page.html` | any domain or path | no referrer | +| **`no-referrer-when-downgrade`** | `https://example.com/page.html` | `https://example.com/otherpage.html` | `https://example.com/page.html` | +| **`no-referrer-when-downgrade`** | `https://example.com/page.html` | `https://mozilla.org` | `https://example.com/page.html` | +| **`no-referrer-when-downgrade`** | `https://example.com/page.html` | **http**://example.org | no referrer | +| **`origin`** | `https://example.com/page.html` | any domain or path | `https://example.com/` | +| **`origin-when-cross-origin`** | `https://example.com/page.html` | `https://example.com/otherpage.html` | `https://example.com/page.html` | +| **`origin-when-cross-origin`** | `https://example.com/page.html` | `https://mozilla.org` | `https://example.com/` | +| **`origin-when-cross-origin`** | `https://example.com/page.html` | **http**://example.com/page.html | `https://example.com/` | +| **`same-origin`** | `https://example.com/page.html` | `https://example.com/otherpage.html` | `https://example.com/page.html` | +| **`same-origin`** | `https://example.com/page.html` | `https://mozilla.org` | no referrer | +| **`strict-origin`** | `https://example.com/page.html` | `https://mozilla.org` | `https://example.com/` | +| **`strict-origin`** | `https://example.com/page.html` | **http**://example.org | no referrer | +| **`strict-origin`** | **http**://example.com/page.html | any domain or path | `http://example.com/` | +| **`strict-origin-when-cross-origin`** | `https://example.com/page.html` | `https://example.com/otherpage.html` | `https://example.com/page.html` | +| **`strict-origin-when-cross-origin`** | `https://example.com/page.html` | `https://mozilla.org` | `https://example.com/` | +| **`strict-origin-when-cross-origin`** | `https://example.com/page.html` | **http**://example.org | no referrer | +| **`unsafe-url`** | `https://example.com/page.html` | any domain or path | `https://example.com/page.html` | ### 指定后备策略 diff --git a/files/zh-cn/web/http/headers/retry-after/index.md b/files/zh-cn/web/http/headers/retry-after/index.md index 8020d20501620e..c9291ebd3fdb33 100644 --- a/files/zh-cn/web/http/headers/retry-after/index.md +++ b/files/zh-cn/web/http/headers/retry-after/index.md @@ -10,9 +10,9 @@ slug: Web/HTTP/Headers/Retry-After - 当与 {{HTTPStatus(503)}} (Service Unavailable,当前服务不存在) 响应一起发送的时候,表示服务下线的预期时长。 - 当与重定向响应一起发送的时候,比如 {{HTTPStatus(301)}} (Moved Permanently,永久迁移),表示用户代理在发送重定向请求之前需要等待的最短时间。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/sec-ch-ua-full-version-list/index.md b/files/zh-cn/web/http/headers/sec-ch-ua-full-version-list/index.md index 8cb126c55a06d1..cceb41bb237b92 100644 --- a/files/zh-cn/web/http/headers/sec-ch-ua-full-version-list/index.md +++ b/files/zh-cn/web/http/headers/sec-ch-ua-full-version-list/index.md @@ -44,7 +44,7 @@ Sec-CH-UA-Full-Version-List: "";v="", ... - `` - : 与用户代理相关的品牌,如“Chromium”和“Google Chrome”。 - 这可能是一个故意不正确的品牌,如 `" Not A;Brand"` 或 `"(Not(A:Brand"`(实际值是预期随时间变化且不可预测的)。 + 这可能是一个故意不正确的品牌,如 `" Not A;Brand"` 或 `"(Not(A:Brand"`(实际值是预期随时间变化且不可预测的)。 - `` - : 完整的版本号,例如 98.0.4750.0。 diff --git a/files/zh-cn/web/http/headers/sec-fetch-dest/index.md b/files/zh-cn/web/http/headers/sec-fetch-dest/index.md index 415de91180af21..f19f830e68b58f 100644 --- a/files/zh-cn/web/http/headers/sec-fetch-dest/index.md +++ b/files/zh-cn/web/http/headers/sec-fetch-dest/index.md @@ -30,7 +30,7 @@ slug: Web/HTTP/Headers/Sec-Fetch-Dest ## 语法 - ``` +``` Sec-Fetch-Dest: audio Sec-Fetch-Dest: audioworklet Sec-Fetch-Dest: document diff --git a/files/zh-cn/web/http/headers/sec-fetch-mode/index.md b/files/zh-cn/web/http/headers/sec-fetch-mode/index.md index 9bb60f61023db8..ceeadf29abaef4 100644 --- a/files/zh-cn/web/http/headers/sec-fetch-mode/index.md +++ b/files/zh-cn/web/http/headers/sec-fetch-mode/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/Sec-Fetch-Mode **`Sec-Fetch-Mode`** 获取元数据标头表明了一个请求的模式。 -| Header type | {{Glossary("Fetch Metadata Request Header")}} | -| ------------------------------------------------------------ | ---------------------------------------------------------------------------------------- | -| {{Glossary("Forbidden header name")}} | 只要包含前缀 `Sec-` 都属于应用程序禁止修改的 HTTP 消息头,用户代理保留全部对它们的控制权 | +| Header type | {{Glossary("Fetch Metadata Request Header")}} | +| ---------------------------------------------- | ---------------------------------------------------------------------------------------- | +| {{Glossary("Forbidden header name")}} | 只要包含前缀 `Sec-` 都属于应用程序禁止修改的 HTTP 消息头,用户代理保留全部对它们的控制权 | | {{Glossary("CORS-safelisted request header")}} | | ## 语法 diff --git a/files/zh-cn/web/http/headers/sec-fetch-site/index.md b/files/zh-cn/web/http/headers/sec-fetch-site/index.md index 0a738cf65a83f0..be04f4c3729b40 100644 --- a/files/zh-cn/web/http/headers/sec-fetch-site/index.md +++ b/files/zh-cn/web/http/headers/sec-fetch-site/index.md @@ -7,11 +7,11 @@ slug: Web/HTTP/Headers/Sec-Fetch-Site **`Sec-Fetch-Site`** 获取元数据标头表明了一个请求发起者的来源与目标资源来源之间的关系。 -| Header type | {{Glossary("Fetch Metadata Request Header")}} | -| ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | -| {{Glossary("Forbidden header name")}} | 只要包含前缀 `Sec-` 都属于应用程序禁止修改的 HTTP 消息头,用户代理保留全部对它们的控制权 | +| Header type | {{Glossary("Fetch Metadata Request Header")}} | +| ----------------------------------------------- | ---------------------------------------------------------------------------------------- | +| {{Glossary("Forbidden header name")}} | 只要包含前缀 `Sec-` 都属于应用程序禁止修改的 HTTP 消息头,用户代理保留全部对它们的控制权 | | {{Glossary("CORS-safelisted response header")}} | | -| {{Glossary("CORS-safelisted request header")}} | | +| {{Glossary("CORS-safelisted request header")}} | | ## 语法 diff --git a/files/zh-cn/web/http/headers/sec-fetch-user/index.md b/files/zh-cn/web/http/headers/sec-fetch-user/index.md index 7194ffda6df501..a441c827f13ecb 100644 --- a/files/zh-cn/web/http/headers/sec-fetch-user/index.md +++ b/files/zh-cn/web/http/headers/sec-fetch-user/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/Sec-Fetch-User **`Sec-Fetch-User`** 获取元数据标头表明了一个导航请求是否由用户激活触发。 -| Header type | {{Glossary("Fetch Metadata Request Header")}} | -| ------------------------------------------------------------ | ---------------------------------------------------------------------------------------- | -| {{Glossary("Forbidden header name")}} | 只要包含前缀 `Sec-` 都属于应用程序禁止修改的 HTTP 消息头,用户代理保留全部对它们的控制权 | +| Header type | {{Glossary("Fetch Metadata Request Header")}} | +| ---------------------------------------------- | ---------------------------------------------------------------------------------------- | +| {{Glossary("Forbidden header name")}} | 只要包含前缀 `Sec-` 都属于应用程序禁止修改的 HTTP 消息头,用户代理保留全部对它们的控制权 | | {{Glossary("CORS-safelisted request header")}} | | ## 语法 diff --git a/files/zh-cn/web/http/headers/server-timing/index.md b/files/zh-cn/web/http/headers/server-timing/index.md index 08b0bc6c571646..d5e33e1d4a8bd7 100644 --- a/files/zh-cn/web/http/headers/server-timing/index.md +++ b/files/zh-cn/web/http/headers/server-timing/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/Server-Timing **`Server-Timing`** 标头传达在一个给定请求 - 响应周期中的一个或多个参数和描述。它用于在用户浏览器的开发工具或 {{domxref("PerformanceServerTiming")}} 接口中显示任何后端服务器定时参数(例如,数据库读/写、CPU 时间、文件系统访问等)。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/server/index.md b/files/zh-cn/web/http/headers/server/index.md index 1661aa03f8ee14..fcb428977319ac 100644 --- a/files/zh-cn/web/http/headers/server/index.md +++ b/files/zh-cn/web/http/headers/server/index.md @@ -9,9 +9,9 @@ slug: Web/HTTP/Headers/Server 应该避免使用过长或者过于详细的描述作为 Server 的值,因为这有可能泄露服务器的内部实现细节,有利于攻击者找到或者探测已知的安全漏洞。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/set-cookie/index.md b/files/zh-cn/web/http/headers/set-cookie/index.md index 7ec7d94b1c9fa1..ec5b648b2356d1 100644 --- a/files/zh-cn/web/http/headers/set-cookie/index.md +++ b/files/zh-cn/web/http/headers/set-cookie/index.md @@ -65,6 +65,7 @@ Set-Cookie: =; Domain=; Secure; HttpOnl > **`__Host-` 前缀**:以 `__Host-` 为前缀的 cookie,必须与 `secure` 属性一同设置,必须应用于安全页面(即使用 HTTPS 访问的页面),也禁止设置 domain 属性(也就不会发送给子域),同时 path 属性的值必须为 `/`。 - `Expires=` {{optional_inline}} + - : cookie 的最长有效时间,形式为符合 HTTP-date 规范的时间戳。参见 {{HTTPHeader("Date")}} 可以获取详细信息。 如果没有设置这个属性,那么表示这是一个**会话期 cookie**。一个会话结束于客户端被关闭时,这意味着会话期 cookie 在彼时会被移除。 @@ -76,6 +77,7 @@ Set-Cookie: =; Domain=; Secure; HttpOnl - `Max-Age=` {{optional_inline}} - : 在 cookie 失效之前需要经过的秒数。秒数为 0 或 -1 将会使 cookie 直接过期。假如 `Expires` 和 `Max-Age` 属性均存在,那么 `Max-Age` 的优先级更高。 - `Domain=` {{optional_inline}} + - : 指定 cookie 可以送达的主机名。 假如没有指定,那么默认值为当前文档访问地址中的主机部分(但是不包含子域名)。 @@ -83,12 +85,16 @@ Set-Cookie: =; Domain=; Secure; HttpOnl 与之前的规范不同的是,域名(`.example.com`)之前的点号会被忽略。 多个主机/域名的值是*不*被允许的,但如果指定了一个域,则其子域也会被包含。 + - `Path=` {{optional_inline}} + - : 指定一个 URL 路径,这个路径*必须*出现在要请求的资源的路径中才可以发送 `Cookie` 标头。 字符 `/` 可以解释为文件目录分隔符,此目录的下级目录也满足匹配的条件(例如,如果 `path=/docs`,那么 + - `/docs`、`/docs/`、`/docs/Web/` 和 `/docs/Web/HTTP` 都满足匹配条件。 - `/`、`/docsets` 或者 `/fr/docs` 则不满足匹配条件。 + - `Secure` {{optional_inline}} - : 一个带有安全属性的 cookie 只有在请求使用 `https:` 协议(localhost 不受此限制)的时候才会被发送到服务器。以阻止[中间人](/zh-CN/docs/Glossary/MitM)攻击。 @@ -100,17 +106,21 @@ Set-Cookie: =; Domain=; Secure; HttpOnl - `HttpOnly` {{optional_inline}} - : 用于阻止 JavaScript 通过 {{domxref("Document.cookie")}} 属性访问 cookie。注意,设置了 `HttpOnly` 的 cookie 在 JavaScript 初始化的请求中仍然会被发送。例如,调用 {{domxref("XMLHttpRequest.send()")}} 或 {{domxref("fetch()")}}。其用于防范跨站脚本攻击({{Glossary("Cross-site_scripting", "XSS")}})。 - `SameSite=` {{optional_inline}} + - : 允许服务器设定一则 cookie 不随着跨站请求一起发送,这样可以在一定程度上防范跨站请求伪造攻击({{Glossary("CSRF")}})。 可选的属性值有: - `Strict` + - : 这意味浏览器仅对同一站点的请求发送 `cookie`,即请求来自设置 cookie 的站点。如果请求来自不同的域或协议(即使是相同域),则携带有 `SameSite=Strict` 属性的 cookie 将不会被发送。 - `Lax` + - : 这意味着 cookie 不会在跨站请求中被发送,如:加载图像或 frame 的请求。但 cookie 在用户从外部站点导航到源站时,cookie 也将被发送(例如,跟随一个链接)。这是 `SameSite` 属性未被设置时的默认行为。 - `None` + - : 这意味着浏览器会在跨站和同站请求中均发送 cookie。在设置这一属性值时,必须同时设置 `Secure` 属性,就像这样:`SameSite=None; Secure`。 > **备注:** 与 [SameSite Cookie](/zh-CN/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value) 相关的标准作了如下变动: diff --git a/files/zh-cn/web/http/headers/sourcemap/index.md b/files/zh-cn/web/http/headers/sourcemap/index.md index 9268e3c49a4a4f..fa6b98b7751d4f 100644 --- a/files/zh-cn/web/http/headers/sourcemap/index.md +++ b/files/zh-cn/web/http/headers/sourcemap/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/SourceMap **`SourceMap`** [HTTP](/zh-CN/docs/Web/HTTP) 响应头链接生成的代码到一个 [source map](/zh-CN/docs/Tools/Debugger/How_to/Use_a_source_map),使浏览器能够重建原始的资源然后显示在调试器里。 -| Header 类型 | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header 类型 | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/te/index.md b/files/zh-cn/web/http/headers/te/index.md index 45e8e19094a24c..9eb11cc880ae70 100644 --- a/files/zh-cn/web/http/headers/te/index.md +++ b/files/zh-cn/web/http/headers/te/index.md @@ -9,9 +9,9 @@ slug: Web/HTTP/Headers/TE 可以参考 {{HTTPHeader("Transfer-Encoding")}} 来获取更多关于传输编码的细节信息。值得注意的是,支持 HTTP/1.1 协议的接收方一定可以处理 `chunked` 传输编码请求,所以没有必要一定在 `TE` 首部指定“chunked”关键字。然而,如果客户端将要接收编码在 chunked 包体里面的"trailer"信息的时候,主动指定该头部将会非常有用。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | yes | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | yes | ## 语法 diff --git a/files/zh-cn/web/http/headers/timing-allow-origin/index.md b/files/zh-cn/web/http/headers/timing-allow-origin/index.md index b56a8dd81068ef..7431954bc0971c 100644 --- a/files/zh-cn/web/http/headers/timing-allow-origin/index.md +++ b/files/zh-cn/web/http/headers/timing-allow-origin/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/Timing-Allow-Origin 响应头 **`Timing-Allow-Origin`** 用于指定特定站点,以允许其访问[Resource Timing API](/zh-CN/docs/Web/API/Performance_API/Resource_timing)提供的相关信息,否则这些信息会由于跨源限制将被报告为零 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/tk/index.md b/files/zh-cn/web/http/headers/tk/index.md index 0650505dea0195..febfa61d4950b0 100644 --- a/files/zh-cn/web/http/headers/tk/index.md +++ b/files/zh-cn/web/http/headers/tk/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/Tk **`Tk`** 响应首部显示了对相应请求的跟踪情况。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/trailer/index.md b/files/zh-cn/web/http/headers/trailer/index.md index 152a0178f3c480..89c7193c8fe711 100644 --- a/files/zh-cn/web/http/headers/trailer/index.md +++ b/files/zh-cn/web/http/headers/trailer/index.md @@ -9,9 +9,9 @@ slug: Web/HTTP/Headers/Trailer > **备注:** 请求首部 {{HTTPHeader("TE")}} 需要设置 trailers 来允许挂载字段。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | yes | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | yes | ## 语法 @@ -22,6 +22,7 @@ Trailer: header-names ## 指令 - `header-names` + - : 出现在分块信息挂载部分的消息首部。以下首部字段**不允许**出现: - 用于信息分帧的首部 (例如{{HTTPHeader("Transfer-Encoding")}} 和 {{HTTPHeader("Content-Length")}}), diff --git a/files/zh-cn/web/http/headers/transfer-encoding/index.md b/files/zh-cn/web/http/headers/transfer-encoding/index.md index 90731583b98c64..9c430165139aec 100644 --- a/files/zh-cn/web/http/headers/transfer-encoding/index.md +++ b/files/zh-cn/web/http/headers/transfer-encoding/index.md @@ -11,9 +11,9 @@ slug: Web/HTTP/Headers/Transfer-Encoding 当这个消息首部出现在 {{HTTPMethod("HEAD")}} 请求的响应中,而这样的响应没有消息体,那么它其实指的是应用在相应的 {{HTTPMethod("GET")}} 请求的应答的值。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | yes | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | yes | ## 语法 diff --git a/files/zh-cn/web/http/headers/upgrade-insecure-requests/index.md b/files/zh-cn/web/http/headers/upgrade-insecure-requests/index.md index 73dad4658b55b6..e534471aa778fc 100644 --- a/files/zh-cn/web/http/headers/upgrade-insecure-requests/index.md +++ b/files/zh-cn/web/http/headers/upgrade-insecure-requests/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/Upgrade-Insecure-Requests **`Upgrade-Insecure-Requests`** 是一个请求首部,用来向服务器端发送信号,表示客户端优先选择加密及带有身份验证的响应,并且它可以成功处理 {{CSP("upgrade-insecure-requests")}} [CSP](/zh-CN/docs/Web/Security/CSP) 指令。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/user-agent/firefox/index.md b/files/zh-cn/web/http/headers/user-agent/firefox/index.md index a1d136998f712f..c45b8bf669f956 100644 --- a/files/zh-cn/web/http/headers/user-agent/firefox/index.md +++ b/files/zh-cn/web/http/headers/user-agent/firefox/index.md @@ -19,7 +19,7 @@ Firefox 的 User Agent(用户代理)值可被拆分为以下四个部分: - **_Gecko/geckotrail_** 标明浏览器基于 Gecko。 - 在桌面端,_**geckotrail**_ 的值恒为"20100101"。 - _**Firefox/firefoxversion**_ 标明浏览器是 Firefox,并提供了版本号(如"_17.0"_)。 -- 自从移动版 Firefox 10 开始,***geckotrail***与**_firefoxversion_**保持一致。 +- 自从移动版 Firefox 10 开始,**_geckotrail_**与**_firefoxversion_**保持一致。 > **备注:** (如果你必须检测浏览器引擎,而不是去做特征检测的话)推荐使用"_Gecko_"与"_rv:_"字符串来检测基于 Gecko 的浏览器。因为一些浏览器的 UA 中也包含有"_like Gecko_"字段。 diff --git a/files/zh-cn/web/http/headers/user-agent/index.md b/files/zh-cn/web/http/headers/user-agent/index.md index 2a089b51733146..fd0eeac0c8617e 100644 --- a/files/zh-cn/web/http/headers/user-agent/index.md +++ b/files/zh-cn/web/http/headers/user-agent/index.md @@ -9,9 +9,9 @@ slug: Web/HTTP/Headers/User-Agent > **备注:** 请阅读[使用用户代理字段进行浏览器检测](/zh-CN/docs/Web/HTTP/Browser_detection_using_the_user_agent)来了解为什么为不同的浏览器提供不同的页面或者服务通常不是一个好主意。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | no | ## 语法 @@ -40,8 +40,8 @@ User-Agent: Mozilla/ () ( [] ## 指令 - \ + - : 三位数字警告码。第一位数字表示 Warning 信息在验证之后是否需要从已存储的响应中删除。 - `1xx` 警告码描述了关于当前响应的新鲜度或者验证状态的警告信息,并且将会在验证之后被缓存服务器删除。 - `2xx` 警告码描述了验证之后不会被修复的某些展现内容方面的警告信息,并且在验证之后不会被缓存服务器删除。 + - \ - : 添加到 Warning 首部的服务器或者软件的名称或者伪名称(当代理不可知的时候可以用 "-" 代替)。 - \ @@ -37,15 +39,15 @@ Warning: [] [由 iana.org 维护的 HTTP 警告码登记表](http://www.iana.org/assignments/http-warn-codes/http-warn-codes.xhtml)规定了警告码的命名空间。 -| 码值 | 文字描述 | 详细说明 | -| ---- | ---------------------- | -------------------------------------------------------------------------------------------------- | -| 110 | Response is Stale | 由缓存服务器提供的响应已过期(设置的失效时间已过)。 | -| 111 | Revalidation Failed | 由于无法访问服务器,响应验证失败。 | -| 112 | Disconnected Operation | 缓存服务器断开连接。 | -| 113 | Heuristic Expiration | 如果缓存服务器采用启发式方法,将缓存的有效时间设定为 24 小时,而在该响应的年龄超过 24 小时时发送。 | -| 199 | Miscellaneous Warning | 任意的、未明确指定的警告信息。 | -| 214 | Transformation Applied | 由代理服务器添加,如果它对返回的展现内容进行了任何转换,比如改变了内容编码、媒体类型等。 | -| 299 | Miscellaneous Persistent Warning | 与 199 类似,只不过指代的是持久化警告。 | +| 码值 | 文字描述 | 详细说明 | +| ---- | -------------------------------- | -------------------------------------------------------------------------------------------------- | +| 110 | Response is Stale | 由缓存服务器提供的响应已过期(设置的失效时间已过)。 | +| 111 | Revalidation Failed | 由于无法访问服务器,响应验证失败。 | +| 112 | Disconnected Operation | 缓存服务器断开连接。 | +| 113 | Heuristic Expiration | 如果缓存服务器采用启发式方法,将缓存的有效时间设定为 24 小时,而在该响应的年龄超过 24 小时时发送。 | +| 199 | Miscellaneous Warning | 任意的、未明确指定的警告信息。 | +| 214 | Transformation Applied | 由代理服务器添加,如果它对返回的展现内容进行了任何转换,比如改变了内容编码、媒体类型等。 | +| 299 | Miscellaneous Persistent Warning | 与 199 类似,只不过指代的是持久化警告。 | ## 示例 diff --git a/files/zh-cn/web/http/headers/x-content-type-options/index.md b/files/zh-cn/web/http/headers/x-content-type-options/index.md index 311533088d3052..d65c79ee82f271 100644 --- a/files/zh-cn/web/http/headers/x-content-type-options/index.md +++ b/files/zh-cn/web/http/headers/x-content-type-options/index.md @@ -13,9 +13,9 @@ slug: Web/HTTP/Headers/X-Content-Type-Options 注意:`nosniff` 只应用于 "`script`" 和 "`style`" 两种类型。事实证明,将其应用于图片类型的文件会导致[与现有的站点冲突](https://github.com/whatwg/fetch/issues/395)。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 @@ -26,6 +26,7 @@ X-Content-Type-Options: nosniff ## 指令 - `nosniff` + - : 下面两种情况的请求将被阻止: - 请求类型是"`style`" 但是 MIME 类型不是 "`text/css`", diff --git a/files/zh-cn/web/http/headers/x-dns-prefetch-control/index.md b/files/zh-cn/web/http/headers/x-dns-prefetch-control/index.md index b73b0a86687017..fbc4b8d33815ec 100644 --- a/files/zh-cn/web/http/headers/x-dns-prefetch-control/index.md +++ b/files/zh-cn/web/http/headers/x-dns-prefetch-control/index.md @@ -10,9 +10,9 @@ original_slug: Controlling_DNS_prefetching 因为预读取会在后台执行,所以 {{glossary("DNS")}} 很可能在链接对应的东西出现之前就已经解析完毕。这能够减少用户点击链接时的延迟。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 @@ -59,7 +59,7 @@ DNS 请求需要的带宽非常小,但是延迟却有点高,这一点在手 你可以通过使用 [`rel`](/zh-CN/docs/Web/HTML/Element/link#rel) 属性值为 [link type](/zh-CN/docs/Web/HTML/Link_types) 中的 `dns-prefetch` 的 {{ HTMLElement("link") }} 标签来对特定域名进行预读取: ```html - + ``` 在这个例子中,Firefox 将预解析域名"[www.spreadfirefox.com](http://www.spreadfirefox.com)"。 @@ -67,7 +67,7 @@ DNS 请求需要的带宽非常小,但是延迟却有点高,这一点在手 而且,{{ HTMLElement("link") }} 元素也可以使用不完整的 URL 的主机名来标记预解析,但这些主机名前必需要有双斜线: ```html - + ``` 强制对域名进行预读取在一些情况下很有用,比如,在网站的主页上,强制在整个网站上频繁引用的域名的预解析,即使它们不在主页本身上使用。即使主页的性能可能不受影响,这将提高整体站点性能。 diff --git a/files/zh-cn/web/http/headers/x-forwarded-host/index.md b/files/zh-cn/web/http/headers/x-forwarded-host/index.md index df37d2107ef1f3..5914e0c6bbd9a1 100644 --- a/files/zh-cn/web/http/headers/x-forwarded-host/index.md +++ b/files/zh-cn/web/http/headers/x-forwarded-host/index.md @@ -13,9 +13,9 @@ The **`X-Forwarded-Host`** (XFH) 是一个事实上的标准首部,用来确 HTTP 协议中的 {{HTTPHeader("Forwarded")}} 是这个消息首部的标准化版本。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/x-forwarded-proto/index.md b/files/zh-cn/web/http/headers/x-forwarded-proto/index.md index d23717ae6fdeca..7cd54731c0e020 100644 --- a/files/zh-cn/web/http/headers/x-forwarded-proto/index.md +++ b/files/zh-cn/web/http/headers/x-forwarded-proto/index.md @@ -9,9 +9,9 @@ slug: Web/HTTP/Headers/X-Forwarded-Proto HTTP 协议中的 {{HTTPHeader("Forwarded")}} 是这个消息首部的标准化版本。 -| Header type | {{Glossary("Request header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Request header")}} | +| ------------------------------------- | ------------------------------ | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/headers/x-frame-options/index.md b/files/zh-cn/web/http/headers/x-frame-options/index.md index 5eb0ce69f09975..3164e72e1828b8 100644 --- a/files/zh-cn/web/http/headers/x-frame-options/index.md +++ b/files/zh-cn/web/http/headers/x-frame-options/index.md @@ -110,16 +110,16 @@ http-response set-header X-Frame-Options SAMEORIGIN 要配置 Express 以发送 `X-Frame-Options` 响应头,你可以使用借助了 [frameguard](https://helmetjs.github.io/docs/frameguard/) 的 [helmet](https://helmetjs.github.io/) 来设置首部。在你的服务器配置里面添加: ```js -const helmet = require('helmet'); +const helmet = require("helmet"); const app = express(); -app.use(helmet.frameguard({ action: 'SAMEORIGIN' })); +app.use(helmet.frameguard({ action: "SAMEORIGIN" })); ``` 或者,你也可以直接用 frameguard: ```js -const frameguard = require('frameguard') -app.use(frameguard({ action: 'SAMEORIGIN' })) +const frameguard = require("frameguard"); +app.use(frameguard({ action: "SAMEORIGIN" })); ``` ## 规范 diff --git a/files/zh-cn/web/http/headers/x-xss-protection/index.md b/files/zh-cn/web/http/headers/x-xss-protection/index.md index bf4691c658be79..25c4f58ff9595b 100644 --- a/files/zh-cn/web/http/headers/x-xss-protection/index.md +++ b/files/zh-cn/web/http/headers/x-xss-protection/index.md @@ -7,9 +7,9 @@ slug: Web/HTTP/Headers/X-XSS-Protection HTTP **`X-XSS-Protection`** 响应头是 Internet Explorer,Chrome 和 Safari 的一个特性,当检测到跨站脚本攻击 ({{Glossary("XSS")}}) 时,浏览器将停止加载页面。若网站设置了良好的 {{HTTPHeader("Content-Security-Policy")}} 来禁用内联 JavaScript (`'unsafe-inline'`),现代浏览器不太需要这些保护,但其仍然可以为尚不支持 {{Glossary("CSP")}} 的旧版浏览器的用户提供保护。 -| Header type | {{Glossary("Response header")}} | -| ------------------------------------------------ | ---------------------------------------- | -| {{Glossary("Forbidden header name")}} | no | +| Header type | {{Glossary("Response header")}} | +| ------------------------------------- | ------------------------------- | +| {{Glossary("Forbidden header name")}} | no | ## 语法 diff --git a/files/zh-cn/web/http/messages/index.md b/files/zh-cn/web/http/messages/index.md index 26be541682a0bf..b5d086b70e0ec5 100644 --- a/files/zh-cn/web/http/messages/index.md +++ b/files/zh-cn/web/http/messages/index.md @@ -5,7 +5,7 @@ slug: Web/HTTP/Messages {{HTTPSidebar}} -HTTP 消息是服务器和客户端之间交换数据的方式。有两种类型的消息:*请求*(request)——由客户端发送用来触发一个服务器上的动作;*响应*(response)——来自服务器的应答。 +HTTP 消息是服务器和客户端之间交换数据的方式。有两种类型的消息:_请求_(request)——由客户端发送用来触发一个服务器上的动作;_响应_(response)——来自服务器的应答。 HTTP 消息由采用 ASCII 编码的多行文本构成。在 HTTP/1.1 及早期版本中,这些消息通过连接公开地发送。在 HTTP/2 中,为了优化和性能方面的改进,曾经可人工阅读的消息被分到多个 HTTP 帧中。 @@ -30,21 +30,21 @@ HTTP 请求和响应具有相似的结构,由以下部分组成: ### 起始行 -HTTP 请求是由客户端发出的消息,用来使服务器执行动作。*起始行*(start-line)包含三个元素: +HTTP 请求是由客户端发出的消息,用来使服务器执行动作。_起始行_(start-line)包含三个元素: 1. 一个 _[HTTP 方法](/zh-CN/docs/Web/HTTP/Methods)_,一个动词(像 {{HTTPMethod("GET")}}、{{HTTPMethod("PUT")}} 或者 {{HTTPMethod("POST")}})或者一个名词(像 {{HTTPMethod("HEAD")}} 或者 {{HTTPMethod("OPTIONS")}}),描述要执行的动作。例如,`GET` 表示要获取资源,`POST` 表示向服务器推送数据(创建或修改资源,或者产生要返回的临时文件)。 -2. *请求目标*(request target),通常是一个 {{glossary("URL")}},或者是协议、端口和域名的绝对路径,通常以请求的环境为特征。请求的格式因不同的 HTTP 方法而异。它可以是: +2. _请求目标_(request target),通常是一个 {{glossary("URL")}},或者是协议、端口和域名的绝对路径,通常以请求的环境为特征。请求的格式因不同的 HTTP 方法而异。它可以是: - - 一个绝对路径,末尾跟上一个 `'?'` 和查询字符串。这是最常见的形式,称为*原始形式*(origin form),被 `GET`、`POST`、`HEAD` 和 `OPTIONS` 方法所使用。 - - `POST / HTTP/1.1` - - `GET /background.png HTTP/1.0` - - `HEAD /test.html?query=alibaba HTTP/1.1` - - `OPTIONS /anypage.html HTTP/1.0` - - 一个完整的 URL,被称为*绝对形式*(absolute form),主要在使用 `GET` 方法连接到代理时使用。`GET http://developer.mozilla.org/zh-CN/docs/Web/HTTP/Messages HTTP/1.1` - - 由域名和可选端口(以 `':'` 为前缀)组成的 URL 的 authority 部分,称为 _authority form_。仅在使用 `CONNECT` 建立 HTTP 隧道时才使用。`CONNECT developer.mozilla.org:80 HTTP/1.1` - - *星号形式*(asterisk form),一个简单的星号(`'*'`),配合 `OPTIONS` 方法使用,代表整个服务器。`OPTIONS * HTTP/1.1` + - 一个绝对路径,末尾跟上一个 `'?'` 和查询字符串。这是最常见的形式,称为*原始形式*(origin form),被 `GET`、`POST`、`HEAD` 和 `OPTIONS` 方法所使用。 + - `POST / HTTP/1.1` + - `GET /background.png HTTP/1.0` + - `HEAD /test.html?query=alibaba HTTP/1.1` + - `OPTIONS /anypage.html HTTP/1.0` + - 一个完整的 URL,被称为*绝对形式*(absolute form),主要在使用 `GET` 方法连接到代理时使用。`GET http://developer.mozilla.org/zh-CN/docs/Web/HTTP/Messages HTTP/1.1` + - 由域名和可选端口(以 `':'` 为前缀)组成的 URL 的 authority 部分,称为 _authority form_。仅在使用 `CONNECT` 建立 HTTP 隧道时才使用。`CONNECT developer.mozilla.org:80 HTTP/1.1` + - _星号形式_(asterisk form),一个简单的星号(`'*'`),配合 `OPTIONS` 方法使用,代表整个服务器。`OPTIONS * HTTP/1.1` -3. *HTTP 版本*(HTTP version),定义了剩余消息的结构,作为对期望的响应版本的指示符。 +3. _HTTP 版本_(HTTP version),定义了剩余消息的结构,作为对期望的响应版本的指示符。 ### 标头(Header) @@ -73,9 +73,9 @@ HTTP 请求是由客户端发出的消息,用来使服务器执行动作。* HTTP 响应的起始行被称作*状态行*(status line),包含以下信息: -1. *协议版本*,通常为 `HTTP/1.1`。 -2. *状态码*(status code),表明请求是成功或失败。常见的状态码是 {{HTTPStatus("200")}}、{{HTTPStatus("404")}} 或 {{HTTPStatus("302")}}。 -3. *状态文本*(status text)。一个简短的,纯粹的信息,通过状态码的文本描述,帮助人们理解该 HTTP 消息。 +1. _协议版本_,通常为 `HTTP/1.1`。 +2. _状态码_(status code),表明请求是成功或失败。常见的状态码是 {{HTTPStatus("200")}}、{{HTTPStatus("404")}} 或 {{HTTPStatus("302")}}。 +3. _状态文本_(status text)。一个简短的,纯粹的信息,通过状态码的文本描述,帮助人们理解该 HTTP 消息。 一个典型的状态行看起来像这样:`HTTP/1.1 404 Not Found`。 diff --git a/files/zh-cn/web/http/overview/index.md b/files/zh-cn/web/http/overview/index.md index ecc4cbf10eec22..a14e7428420595 100644 --- a/files/zh-cn/web/http/overview/index.md +++ b/files/zh-cn/web/http/overview/index.md @@ -95,26 +95,26 @@ HTTP 是无状态的:在同一个连接中,两个执行成功的请求之间 1. 打开一个 TCP 连接:TCP 连接被用来发送一条或多条请求,以及接受响应消息。客户端可能打开一条新的连接,或重用一个已经存在的连接,或者也可能开几个新的 TCP 连接连向服务端。 2. 发送一个 HTTP 报文:HTTP 报文(在 HTTP/2 之前)是语义可读的。在 HTTP/2 中,这些简单的消息被封装在了帧中,这使得报文不能被直接读取,但是原理仍是相同的。 - ```http - GET / HTTP/1.1 - Host: developer.mozilla.org - Accept-Language: zh - ``` + ```http + GET / HTTP/1.1 + Host: developer.mozilla.org + Accept-Language: zh + ``` 3. 读取服务端返回的报文信息: - ```http - HTTP/1.1 200 OK - Date: Sat, 09 Oct 2010 14:28:02 GMT - Server: Apache - Last-Modified: Tue, 01 Dec 2009 20:18:22 GMT - ETag: "51142bc1-7449-479b075b2891b" - Accept-Ranges: bytes - Content-Length: 29769 - Content-Type: text/html - - …(此处是所请求网页的 29769 字节) - ``` + ```http + HTTP/1.1 200 OK + Date: Sat, 09 Oct 2010 14:28:02 GMT + Server: Apache + Last-Modified: Tue, 01 Dec 2009 20:18:22 GMT + ETag: "51142bc1-7449-479b075b2891b" + Accept-Ranges: bytes + Content-Length: 29769 + Content-Type: text/html + + …(此处是所请求网页的 29769 字节) + ``` 4. 关闭连接或者为后续请求重用连接。 diff --git a/files/zh-cn/web/http/protocol_upgrade_mechanism/index.md b/files/zh-cn/web/http/protocol_upgrade_mechanism/index.md index 4f1c9e783bd004..720b2879f0e4c4 100644 --- a/files/zh-cn/web/http/protocol_upgrade_mechanism/index.md +++ b/files/zh-cn/web/http/protocol_upgrade_mechanism/index.md @@ -44,7 +44,7 @@ webSocket = new WebSocket("ws://destination.server.ext", "optionalProtocol"); {{domxref("WebSocket.WebSocket", "WebSocket()")}} 构造函数已经自动完成了发送初始 HTTP/1.1 连接的所有工作,然后为你处理握手及升级过程。 ->**备注:** 你也可以用 `"wss://"` URL 方式来打开安全的 WebSocket 连接。 +> **备注:** 你也可以用 `"wss://"` URL 方式来打开安全的 WebSocket 连接。 如果想要自己重头实现 WebSocket 连接,就必须要处理握手和升级过程。在创建初始 HTTP/1.1 会话之后,你需要发送另一个 HTTP 标准请求来请求升级,但在标头中要带上 {{HTTPHeader("Upgrade")}} 和 {{HTTPHeader("Connection")}},也就是: diff --git a/files/zh-cn/web/http/proxy_servers_and_tunneling/index.md b/files/zh-cn/web/http/proxy_servers_and_tunneling/index.md index cebf5c60559994..555aa3a0fd0814 100644 --- a/files/zh-cn/web/http/proxy_servers_and_tunneling/index.md +++ b/files/zh-cn/web/http/proxy_servers_and_tunneling/index.md @@ -74,10 +74,8 @@ The file consists of a function called `FindProxyForURL`. The example below will ```js function FindProxyForURL(url, host) { - if (isResolvable(host)) - return "DIRECT"; - else - return "PROXY proxy.mydomain.com:8080"; + if (isResolvable(host)) return "DIRECT"; + else return "PROXY proxy.mydomain.com:8080"; } ``` diff --git a/files/zh-cn/web/http/proxy_servers_and_tunneling/proxy_auto-configuration_pac_file/index.md b/files/zh-cn/web/http/proxy_servers_and_tunneling/proxy_auto-configuration_pac_file/index.md index 8c008601012b8e..19acb077e755af 100644 --- a/files/zh-cn/web/http/proxy_servers_and_tunneling/proxy_auto-configuration_pac_file/index.md +++ b/files/zh-cn/web/http/proxy_servers_and_tunneling/proxy_auto-configuration_pac_file/index.md @@ -155,8 +155,8 @@ isPlainHostName(host) #### 例子 ```js -isPlainHostName("www.mozilla.org") // false -isPlainHostName("www") // true +isPlainHostName("www.mozilla.org"); // false +isPlainHostName("www"); // true ``` ### dnsDomainIs() @@ -181,8 +181,8 @@ dnsDomainIs(host, domain) #### 例子 ```js -dnsDomainIs("www.mozilla.org", ".mozilla.org") // true -dnsDomainIs("www", ".mozilla.org") // false +dnsDomainIs("www.mozilla.org", ".mozilla.org"); // true +dnsDomainIs("www", ".mozilla.org"); // false ``` ### localHostOrDomainIs() @@ -207,10 +207,10 @@ localHostOrDomainIs(host, hostdom) #### 例子 ```js -localHostOrDomainIs("www.mozilla.org" , "www.mozilla.org") // true (exact match) -localHostOrDomainIs("www" , "www.mozilla.org") // true (hostname match, domain not specified) -localHostOrDomainIs("www.google.com" , "www.mozilla.org") // false (domain name mismatch) -localHostOrDomainIs("home.mozilla.org", "www.mozilla.org") // false (hostname mismatch) +localHostOrDomainIs("www.mozilla.org", "www.mozilla.org"); // true (exact match) +localHostOrDomainIs("www", "www.mozilla.org"); // true (hostname match, domain not specified) +localHostOrDomainIs("www.google.com", "www.mozilla.org"); // false (domain name mismatch) +localHostOrDomainIs("home.mozilla.org", "www.mozilla.org"); // false (hostname mismatch) ``` ### isResolvable() @@ -231,7 +231,7 @@ isResolvable(host) #### 例子: ```js -isResolvable("www.mozilla.org") // true +isResolvable("www.mozilla.org"); // true ``` ### isInNet() @@ -258,9 +258,11 @@ Pattern and mask specification is done the same way as for SOCKS configuration. #### 例子: ```js -function alert_eval(str) { alert(str + ' is ' + eval(str)) } +function alert_eval(str) { + alert(str + " is " + eval(str)); +} function FindProxyForURL(url, host) { - alert_eval('isInNet(host, "63.245.213.24", "255.255.255.255")') + alert_eval('isInNet(host, "63.245.213.24", "255.255.255.255")'); // "PAC-alert: isInNet(host, "63.245.213.24", "255.255.255.255") is true" } ``` @@ -324,7 +326,7 @@ myIpAddress() #### 例子 ```js -myIpAddress() //returns the string "127.0.1.1" if you were running Firefox on that localhost +myIpAddress(); //returns the string "127.0.1.1" if you were running Firefox on that localhost ``` ### dnsDomainLevels() @@ -345,8 +347,8 @@ dnsDomainLevels(host) #### 例子: ```js -dnsDomainLevels("www"); // 0 -dnsDomainLevels("mozilla.org"); // 1 +dnsDomainLevels("www"); // 0 +dnsDomainLevels("mozilla.org"); // 1 dnsDomainLevels("www.mozilla.org"); // 2 ``` @@ -372,7 +374,7 @@ shExpMatch(str, shexp) #### 例子 ```js -shExpMatch("http://home.netscape.com/people/ari/index.html" , "*/ari/*"); // returns true +shExpMatch("http://home.netscape.com/people/ari/index.html", "*/ari/*"); // returns true shExpMatch("http://home.netscape.com/people/montulli/index.html", "*/ari/*"); // returns false ``` @@ -389,6 +391,7 @@ weekdayRange(wd1, wd2, [gmt]) #### 参数 - wd1 和 wd2 + - : One of the ordered weekday strings: ```plain @@ -410,11 +413,11 @@ If both **wd1** and **wd1** are defined, the condition is true if the current we #### 例子 ```js -weekdayRange("MON", "FRI"); // returns true Monday through Friday (local timezone) +weekdayRange("MON", "FRI"); // returns true Monday through Friday (local timezone) weekdayRange("MON", "FRI", "GMT"); // returns true Monday through Friday (GMT timezone) -weekdayRange("SAT"); // returns true on Saturdays local time -weekdayRange("SAT", "GMT"); // returns true on Saturdays GMT time -weekdayRange("FRI", "MON"); // returns true Friday and Monday only (note, order does matter!) +weekdayRange("SAT"); // returns true on Saturdays local time +weekdayRange("SAT", "GMT"); // returns true on Saturdays GMT time +weekdayRange("FRI", "MON"); // returns true Friday and Monday only (note, order does matter!) ``` ### dateRange() @@ -461,10 +464,10 @@ If only a single value is specified (from each category: day, month, year), the #### 例子 ```js -dateRange(1); // returns true on the first day of each month, local timezone -dateRange(1, "GMT") // returns true on the first day of each month, GMT timezone -dateRange(1, 15); // returns true on the first half of each month -dateRange(24, "DEC"); // returns true on 24th of December each year +dateRange(1); // returns true on the first day of each month, local timezone +dateRange(1, "GMT"); // returns true on the first day of each month, GMT timezone +dateRange(1, 15); // returns true on the first half of each month +dateRange(24, "DEC"); // returns true on 24th of December each year dateRange("JAN", "MAR"); // returns true on the first quarter of the year dateRange(1, "JUN", 15, "AUG"); @@ -514,11 +517,11 @@ If only a single value is specified (from each category: hour, minute, second), #### 例子 ```js -timerange(12); // returns true from noon to 1pm -timerange(12, 13); // returns true from noon to 1pm -timerange(12, "GMT"); // returns true from noon to 1pm, in GMT timezone -timerange(9, 17); // returns true from 9am to 5pm -timerange(8, 30, 17, 00); // returns true from 8:30am to 5:00pm +timerange(12); // returns true from noon to 1pm +timerange(12, 13); // returns true from noon to 1pm +timerange(12, "GMT"); // returns true from noon to 1pm, in GMT timezone +timerange(9, 17); // returns true from 9am to 5pm +timerange(8, 30, 17, 00); // returns true from 8:30am to 5:00pm timerange(0, 0, 0, 0, 0, 30); // returns true between midnight and 30 seconds past midnight ``` @@ -555,7 +558,7 @@ function FindProxyForURL(url, host) { !localHostOrDomainIs(host, "www.mozilla.org") && !localHostOrDoaminIs(host, "merchant.mozilla.org") ) { - return "DIRECT"; + return "DIRECT"; } else { return "PROXY w3proxy.mozilla.org:8080; DIRECT"; } @@ -574,10 +577,8 @@ function FindProxyForURL(url, host) { ```js function FindProxyForURL(url, host) { - if (isResolvable(host)) - return "DIRECT"; - else - return "PROXY proxy.mydomain.com:8080"; + if (isResolvable(host)) return "DIRECT"; + else return "PROXY proxy.mydomain.com:8080"; } ``` @@ -605,10 +606,8 @@ function FindProxyForURL(url, host) { ```js function FindProxyForURL(url, host) { - if (isInNet(host, "198.95.0.0", "255.255.0.0")) - return "DIRECT"; - else - return "PROXY proxy.mydomain.com:8080"; + if (isInNet(host, "198.95.0.0", "255.255.0.0")) return "DIRECT"; + else return "PROXY proxy.mydomain.com:8080"; } ``` @@ -645,21 +644,20 @@ All local accesses are desired to be direct. All proxy servers run on the port 8 ```js function FindProxyForURL(url, host) { - if (isPlainHostName(host) || dnsDomainIs(host, ".mydomain.com")) return "DIRECT"; - else if (shExpMatch(host, "*.com")) - return "PROXY proxy1.mydomain.com:8080; " + - "PROXY proxy4.mydomain.com:8080"; - + return ( + "PROXY proxy1.mydomain.com:8080; " + "PROXY proxy4.mydomain.com:8080" + ); else if (shExpMatch(host, "*.edu")) - return "PROXY proxy2.mydomain.com:8080; " + - "PROXY proxy4.mydomain.com:8080"; - + return ( + "PROXY proxy2.mydomain.com:8080; " + "PROXY proxy4.mydomain.com:8080" + ); else - return "PROXY proxy3.mydomain.com:8080; " + - "PROXY proxy4.mydomain.com:8080"; + return ( + "PROXY proxy3.mydomain.com:8080; " + "PROXY proxy4.mydomain.com:8080" + ); } ``` @@ -694,11 +692,10 @@ function FindProxyForURL(url, host) { > > ```js > // ... -> if (shExpMatch(url, "http:\*")) { -> return "PROXY http-proxy.mydomain.com:8080"; +> if (shExpMatch(url, "http:*")) { +> return "PROXY http-proxy.mydomain.com:8080"; > } > // ... -> > ``` > **备注:** 自动配置脚本也可以在服务端动态生成。这在某些情况下比较有用,例如根据客户端地址指定不同的代理服务器。`isInNet()`, `isResolvable()` 和 `dnsResolve()` 应该谨慎使用,这些函数会进行 DNS 查询。其他函数则大都是字符处理函数,不需要 DNS。如果通过代理连接,代理本身也会进行一次 DNS 查询,这产生了额外的 DNS 请求。并且绝大多数情况下,不需要这些函数来实现特定的功能。 diff --git a/files/zh-cn/web/http/redirections/index.md b/files/zh-cn/web/http/redirections/index.md index c9265f16689557..b4aac20acf41c9 100644 --- a/files/zh-cn/web/http/redirections/index.md +++ b/files/zh-cn/web/http/redirections/index.md @@ -5,7 +5,7 @@ slug: Web/HTTP/Redirections {{HTTPSidebar}} -**URL 重定向**(也称为 *URL 转发*)是一种为页面、表单或者整个 Web 站点/应用提供多个 URL 地址的技术。HTTP 对此操作有一种特殊类型的响应,称为 ***HTTP 重定向***(HTTP redirect)。 +**URL 重定向**(也称为 _URL 转发_)是一种为页面、表单或者整个 Web 站点/应用提供多个 URL 地址的技术。HTTP 对此操作有一种特殊类型的响应,称为 **_HTTP 重定向_**(HTTP redirect)。 重定向可实现许多目标: diff --git a/files/zh-cn/web/http/resources_and_specifications/index.md b/files/zh-cn/web/http/resources_and_specifications/index.md index 8cb482bbb17ce5..3eec52d0455bea 100644 --- a/files/zh-cn/web/http/resources_and_specifications/index.md +++ b/files/zh-cn/web/http/resources_and_specifications/index.md @@ -7,52 +7,52 @@ slug: Web/HTTP/Resources_and_specifications HTTP 协议于 20 世纪 90 年代初期被规范化。得益于其扩展性,该规范至今又添加了大量的补充内容。这些增补规范文档散落在网络的不同位置。本文列出了与 HTTP 协议相关的规范文档。 -| 规范 | 标题 | 状态 | -| ------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | -| {{rfc(7230)}} | 超文本传输协议(HTTP/1.1):报文格式与路由 | 建议标准 | -| {{rfc(7231)}} | 超文本传输协议(HTTP/1.1):语义与内容 | 建议标准 | -| {{rfc(7232)}} | 超文本传输协议(HTTP/1.1):条件请求 | 建议标准 | -| {{rfc(7233)}} | 超文本传输协议(HTTP/1.1):范围请求 | 建议标准 | -| {{rfc(7234)}} | 超文本传输协议(HTTP/1.1):缓存 | 建议标准 | -| {{rfc(5861)}} | 针对陈旧内容的 HTTP 缓存控制扩展 | 信息参考 | -| {{rfc(8246)}} | 不可变的 HTTP 响应 | 建议标准 | -| {{rfc(7235)}} | 超文本传输协议(HTTP/1.1):认证 | 建议标准 | -| {{rfc(6265)}} | HTTP 状态控制机制:定义 Cookies | 建议标准 | -| [Draft spec](https://tools.ietf.org/html/draft-ietf-httpbis-cookie-prefixes-00) | Cookie 前缀 | IETF 草案 | -| [Draft spec](https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00) | 同源 Cookies | IETF 草案 | -| [Draft spec](https://tools.ietf.org/html/draft-ietf-httpbis-cookie-alone-01) | 反对非安全的源站对安全 cookies 进行修改 | IETF 草案 | -| {{rfc(2145)}} | HTTP 版本号的使用与解释 | 信息参考 | -| {{rfc(6585)}} | 扩展的 HTTP 状态码 | 建议标准 | -| {{rfc(7538)}} | 超文本传输协议的 308 状态码(永久重定向) | 建议标准 | -| {{rfc(7725)}} | 用于报告法律限制的 HTTP 状态码 | 即将成为标准 | -| {{rfc(2397)}} | URL 的“data“方案 | 建议标准 | -| {{rfc(3986)}} | 统一资源定位符(URI):通用语法 | 因特网标准 | -| {{rfc(5988)}} | 网络链接 _定义了 {{HTTPHeader("Link")}} 首部字段_ | 建议标准 | -| [Experimental spec](https://tools.ietf.org/id/draft-thomson-hybi-http-timeout-01.html) | 超文本传输协议(HTTP))的 Keep-Alive 首部字段 | 信息参考(已过期) | -| [Draft spec](http://httpwg.org/http-extensions/client-hints.html) | HTTP 客户端提示 | IETF 草案 | -| {{rfc(7578)}} | 从表单中返回数据:multipart/form-data | 建议标准 | -| {{rfc(6266)}} | 在超文本传输协议(HTTP)中使用 Content-Disposition 首部字段 | 建议标准 | -| {{rfc(2183)}} | Communicating Presentation Information in Internet Messages: The Content-Disposition Header Field _Only a subset of syntax of the {{HTTPHeader("Content-Disposition")}} header can be used in the context of HTTP messages._ | 建议标准 | -| {{rfc(7239)}} | 前向 HTTP 扩展 | 建议标准 | -| {{rfc(6455)}} | WebSocket 协议 | 建议标准 | -| {{rfc(5246)}} | 安全传输层(TLS)协议 1.2 版本 _该规范已经被后续 RFC 文档进行了修改,不过这些修改不会对 HTTP 协议本身产生效力。_ | 建议标准 | -| [Draft spec]() | 安全传输层(TLS)协议 1.3 版本 _该版本就绪之后,将取代之前的 1.2 版本_ | IETF 草案 | -| {{rfc(2817)}} | 在 HTTP/1.1 中进行 TLS 升级 | 建议标准 | -| {{rfc(7540)}} | 超文本传输协议版本 2(HTTP/2) | 建议标准 | -| {{rfc(7541)}} | HPACK:对 HTTP/2 的首部进行压缩 | 即将成为标准 | -| {{rfc(7838)}} | HTTP 替代服务 | 即将成为标准 | -| {{rfc(7301)}} | 对安全传输层(TLS)的应用层协议的协商的扩展 _用于在传输 HTTP/2 报文时进行协商,以减少一对额外的请求/响应_ | 建议标准 | -| {{rfc(6454)}} | 网络源站的概念 | 建议标准 | -| [Fetch](https://fetch.spec.whatwg.org/#cors-protocol) | 跨源资源共享 | 实时标准 | -| {{rfc(7034)}} | HTTP 首部字段 X-Frame-Options | 信息参考 | -| {{rfc(6797)}} | HTTP 严格安全传输(HSTS) | 建议标准 | -| [Upgrade Insecure Requests](https://w3c.github.io/webappsec-upgrade-insecure-requests/) | 对不安全的请求进行升级 | 推荐候选 | -| [Content Security Policy 1.0](https://www.w3.org/TR/CSP1/) | 内容安全策略 1.0 版本。_CSP 1.1 与 CSP 3.0 并未扩展 HTTP 协议标准_ | 已废弃 | -| [Microsoft document]() | _指定传统文档模式定义 X-UA-Compatible 规范_ | 注记 | -| {{rfc(5689)}} | HTTP 拓展之 Web 分布式创作与版本控制 (WebDAV) _这些 Web 上的拓展,与 CardDAV 和 CalDAV 一起超出了 Web 上的 HTTP 的范围。当下应用的现代 API 使用了 RESTful 的接口。_ | 建议标准 | -| {{rfc(2324)}} | 超文本咖啡壶控制协议(HTCPCP/1.0) | 愚人节玩笑 | -| {{rfc(7168)}} | 超文本咖啡壶控制协议的茶壶扩展(HTCPCP-TEA) | 愚人节玩笑 | -| [HTML Living Standard](https://html.spec.whatwg.org/multipage/) | HTML。_针对服务端发送的事件定义了 HTTP 扩展_ | 实时标准 | -| [Tracking Preference Expression](https://www.w3.org/2011/tracking-protection/drafts/tracking-dnt.html) | DNT 首部字段 | 编辑草案/推荐候选 | -| [Reporting API](http://wicg.github.io/reporting/) | `Report-To` 首部字段 | 草案 | -| [Draft spec](https://tools.ietf.org/html/draft-ietf-httpbis-expect-ct-01) | Expect-CT 拓展于 HTTP | IETF 草案 | +| 规范 | 标题 | 状态 | +| ------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | +| {{rfc(7230)}} | 超文本传输协议(HTTP/1.1):报文格式与路由 | 建议标准 | +| {{rfc(7231)}} | 超文本传输协议(HTTP/1.1):语义与内容 | 建议标准 | +| {{rfc(7232)}} | 超文本传输协议(HTTP/1.1):条件请求 | 建议标准 | +| {{rfc(7233)}} | 超文本传输协议(HTTP/1.1):范围请求 | 建议标准 | +| {{rfc(7234)}} | 超文本传输协议(HTTP/1.1):缓存 | 建议标准 | +| {{rfc(5861)}} | 针对陈旧内容的 HTTP 缓存控制扩展 | 信息参考 | +| {{rfc(8246)}} | 不可变的 HTTP 响应 | 建议标准 | +| {{rfc(7235)}} | 超文本传输协议(HTTP/1.1):认证 | 建议标准 | +| {{rfc(6265)}} | HTTP 状态控制机制:定义 Cookies | 建议标准 | +| [Draft spec](https://tools.ietf.org/html/draft-ietf-httpbis-cookie-prefixes-00) | Cookie 前缀 | IETF 草案 | +| [Draft spec](https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00) | 同源 Cookies | IETF 草案 | +| [Draft spec](https://tools.ietf.org/html/draft-ietf-httpbis-cookie-alone-01) | 反对非安全的源站对安全 cookies 进行修改 | IETF 草案 | +| {{rfc(2145)}} | HTTP 版本号的使用与解释 | 信息参考 | +| {{rfc(6585)}} | 扩展的 HTTP 状态码 | 建议标准 | +| {{rfc(7538)}} | 超文本传输协议的 308 状态码(永久重定向) | 建议标准 | +| {{rfc(7725)}} | 用于报告法律限制的 HTTP 状态码 | 即将成为标准 | +| {{rfc(2397)}} | URL 的“data“方案 | 建议标准 | +| {{rfc(3986)}} | 统一资源定位符(URI):通用语法 | 因特网标准 | +| {{rfc(5988)}} | 网络链接 _定义了 {{HTTPHeader("Link")}} 首部字段_ | 建议标准 | +| [Experimental spec](https://tools.ietf.org/id/draft-thomson-hybi-http-timeout-01.html) | 超文本传输协议(HTTP))的 Keep-Alive 首部字段 | 信息参考(已过期) | +| [Draft spec](http://httpwg.org/http-extensions/client-hints.html) | HTTP 客户端提示 | IETF 草案 | +| {{rfc(7578)}} | 从表单中返回数据:multipart/form-data | 建议标准 | +| {{rfc(6266)}} | 在超文本传输协议(HTTP)中使用 Content-Disposition 首部字段 | 建议标准 | +| {{rfc(2183)}} | Communicating Presentation Information in Internet Messages: The Content-Disposition Header Field _Only a subset of syntax of the {{HTTPHeader("Content-Disposition")}} header can be used in the context of HTTP messages._ | 建议标准 | +| {{rfc(7239)}} | 前向 HTTP 扩展 | 建议标准 | +| {{rfc(6455)}} | WebSocket 协议 | 建议标准 | +| {{rfc(5246)}} | 安全传输层(TLS)协议 1.2 版本 _该规范已经被后续 RFC 文档进行了修改,不过这些修改不会对 HTTP 协议本身产生效力。_ | 建议标准 | +| [Draft spec]() | 安全传输层(TLS)协议 1.3 版本 _该版本就绪之后,将取代之前的 1.2 版本_ | IETF 草案 | +| {{rfc(2817)}} | 在 HTTP/1.1 中进行 TLS 升级 | 建议标准 | +| {{rfc(7540)}} | 超文本传输协议版本 2(HTTP/2) | 建议标准 | +| {{rfc(7541)}} | HPACK:对 HTTP/2 的首部进行压缩 | 即将成为标准 | +| {{rfc(7838)}} | HTTP 替代服务 | 即将成为标准 | +| {{rfc(7301)}} | 对安全传输层(TLS)的应用层协议的协商的扩展 _用于在传输 HTTP/2 报文时进行协商,以减少一对额外的请求/响应_ | 建议标准 | +| {{rfc(6454)}} | 网络源站的概念 | 建议标准 | +| [Fetch](https://fetch.spec.whatwg.org/#cors-protocol) | 跨源资源共享 | 实时标准 | +| {{rfc(7034)}} | HTTP 首部字段 X-Frame-Options | 信息参考 | +| {{rfc(6797)}} | HTTP 严格安全传输(HSTS) | 建议标准 | +| [Upgrade Insecure Requests](https://w3c.github.io/webappsec-upgrade-insecure-requests/) | 对不安全的请求进行升级 | 推荐候选 | +| [Content Security Policy 1.0](https://www.w3.org/TR/CSP1/) | 内容安全策略 1.0 版本。_CSP 1.1 与 CSP 3.0 并未扩展 HTTP 协议标准_ | 已废弃 | +| [Microsoft document]() | _指定传统文档模式定义 X-UA-Compatible 规范_ | 注记 | +| {{rfc(5689)}} | HTTP 拓展之 Web 分布式创作与版本控制 (WebDAV) _这些 Web 上的拓展,与 CardDAV 和 CalDAV 一起超出了 Web 上的 HTTP 的范围。当下应用的现代 API 使用了 RESTful 的接口。_ | 建议标准 | +| {{rfc(2324)}} | 超文本咖啡壶控制协议(HTCPCP/1.0) | 愚人节玩笑 | +| {{rfc(7168)}} | 超文本咖啡壶控制协议的茶壶扩展(HTCPCP-TEA) | 愚人节玩笑 | +| [HTML Living Standard](https://html.spec.whatwg.org/multipage/) | HTML。_针对服务端发送的事件定义了 HTTP 扩展_ | 实时标准 | +| [Tracking Preference Expression](https://www.w3.org/2011/tracking-protection/drafts/tracking-dnt.html) | DNT 首部字段 | 编辑草案/推荐候选 | +| [Reporting API](http://wicg.github.io/reporting/) | `Report-To` 首部字段 | 草案 | +| [Draft spec](https://tools.ietf.org/html/draft-ietf-httpbis-expect-ct-01) | Expect-CT 拓展于 HTTP | IETF 草案 | diff --git a/files/zh-cn/web/http/session/index.md b/files/zh-cn/web/http/session/index.md index 79240459471007..53a8e2be090cfb 100644 --- a/files/zh-cn/web/http/session/index.md +++ b/files/zh-cn/web/http/session/index.md @@ -27,8 +27,8 @@ slug: Web/HTTP/Session 1. 第一行包括请求方法及请求参数: - - 文档路径,不包括协议和域名的绝对路径 URL - - 使用的 HTTP 协议版本 + - 文档路径,不包括协议和域名的绝对路径 URL + - 使用的 HTTP 协议版本 2. 接下来的行每一行都表示一个 HTTP 标头,为服务器提供关于所需数据的信息(例如语言,或 MIME 类型),或是一些改变请求行为的数据(例如当数据已经被缓存,就不再应答)。这些 HTTP 标头形成一个以空行结尾的块。 3. 最后一块是可选数据块,包含更多数据,主要被 POST 方法所使用。 diff --git a/files/zh-cn/web/http/status/408/index.md b/files/zh-cn/web/http/status/408/index.md index 2987520f79912e..095da5b5f4a7cb 100644 --- a/files/zh-cn/web/http/status/408/index.md +++ b/files/zh-cn/web/http/status/408/index.md @@ -5,7 +5,7 @@ slug: Web/HTTP/Status/408 {{HTTPSidebar}} -响应状态码 **`408 Request Timeout`** 表示服务器想要将没有在使用的连接关闭。一些服务器会在空闲连接上发送此信息,**即便是在客户端没有发送任何请求的情况下。 +响应状态码 **`408 Request Timeout`** 表示服务器想要将没有在使用的连接关闭。一些服务器会在空闲连接上发送此信息,即便是在客户端没有发送任何请求的情况下。 服务器应该在此类响应中将 {{HTTPHeader("Connection")}} 首部的值设置为 "close",因为 `408` 意味着服务器已经决定将连接关闭,而不是继续等待。 From 09c0ef42bb053e8367a04ee802e9f7f83dc062fd Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 02:11:53 -0700 Subject: [PATCH 17/30] fr: Format /web/javascript using Prettier (part 11) (#14671) --- .prettierignore | 4 +--- .../equality_comparisons_and_sameness/index.md | 2 +- .../guide/expressions_and_operators/index.md | 2 +- .../web/javascript/guide/grammar_and_types/index.md | 2 +- .../reference/global_objects/error/stack/index.md | 2 +- .../reference/global_objects/string/repeat/index.md | 11 +++-------- .../reference/operators/exponentiation/index.md | 2 +- .../javascript/reference/operators/grouping/index.md | 2 +- .../reference/operators/logical_and/index.md | 2 +- .../reference/operators/logical_or/index.md | 2 +- .../reference/operators/unary_plus/index.md | 10 ++++++---- .../fr/web/javascript/reference/strict_mode/index.md | 3 ++- 12 files changed, 20 insertions(+), 24 deletions(-) diff --git a/.prettierignore b/.prettierignore index 1eb334753678fc..707554e6dcef7d 100644 --- a/.prettierignore +++ b/.prettierignore @@ -25,6 +25,7 @@ build/ /files/fr/web/css/place-items/index.md /files/fr/web/css/place-self/index.md /files/fr/web/javascript/reference/global_objects/array/includes/index.md +/files/fr/web/javascript/reference/global_objects/intl/displaynames/of/index.md /files/pt-br/learn/server-side/django/forms/index.md /files/ru/learn/server-side/django/forms/index.md /files/ru/learn/server-side/django/introduction/index.md @@ -39,9 +40,6 @@ build/ /files/es/web/css/**/*.md /files/es/web/javascript/reference/**/*.md -# fr -/files/fr/web/javascript/**/*.md - # ja /files/ja/learn/javascript/**/*.md /files/ja/mozilla/**/*.md diff --git a/files/fr/web/javascript/equality_comparisons_and_sameness/index.md b/files/fr/web/javascript/equality_comparisons_and_sameness/index.md index 9d0f16c1d69d43..fef349c4913c5d 100644 --- a/files/fr/web/javascript/equality_comparisons_and_sameness/index.md +++ b/files/fr/web/javascript/equality_comparisons_and_sameness/index.md @@ -247,7 +247,7 @@ Voici une liste (non exhaustive) d'opérateurs et de méthodes natives qui peuve - : Si on prend l'opposé de `0`, on aura, bien entendu, `-0`. Cependant, avec les expressions, cela peut faire que la valeur `-0` se glisse dans les variables sans qu'on s'en rende compte. Par exemple : ```js - let forceArrêt = obj.masse * -obj.vitesse + let forceArrêt = obj.masse * -obj.vitesse; ``` Si `obj.vitesse` vaut `0` (ou est évalué à `0`), un `-0` sera introduit, ce qui fera que `forceArrêt` pourra être négative. diff --git a/files/fr/web/javascript/guide/expressions_and_operators/index.md b/files/fr/web/javascript/guide/expressions_and_operators/index.md index 5208f32cd4e5cd..b31b6173647c48 100644 --- a/files/fr/web/javascript/guide/expressions_and_operators/index.md +++ b/files/fr/web/javascript/guide/expressions_and_operators/index.md @@ -955,7 +955,7 @@ On peut appeler `valider()` pour un élément de formulaire sur le gestionnaire L'opérateur de groupement, `( )`, contrôle la précédence de l'évaluation dans une expression. On peut ainsi prioriser certaines opérations par rapport à d'autres et passer outre la précédence par défaut. Dans l'exemple qui suit, on utilise les parenthèses pour que l'addition ait lieu avant la multiplication. -```js +```js-nolint const a = 1; const b = 2; const c = 3; diff --git a/files/fr/web/javascript/guide/grammar_and_types/index.md b/files/fr/web/javascript/guide/grammar_and_types/index.md index 593e8793b2f806..b54e1d2a54acd4 100644 --- a/files/fr/web/javascript/guide/grammar_and_types/index.md +++ b/files/fr/web/javascript/guide/grammar_and_types/index.md @@ -565,7 +565,7 @@ Avec ECMAScript 2015, on peut également utiliser des littéraux sous forme de _ ```js // Littéral simple pour une chaîne -`Un saut de ligne '\n' en JavaScript.`// On peut écrire une chaîne sur plusieurs +`Un saut de ligne '\n' en JavaScript.` // On peut écrire une chaîne sur plusieurs // lignes `Dans les gabarits, on peut écrire sur plusieurs lignes. `; diff --git a/files/fr/web/javascript/reference/global_objects/error/stack/index.md b/files/fr/web/javascript/reference/global_objects/error/stack/index.md index ce510ba35ea3a9..fec66330fe2192 100644 --- a/files/fr/web/javascript/reference/global_objects/error/stack/index.md +++ b/files/fr/web/javascript/reference/global_objects/error/stack/index.md @@ -23,7 +23,7 @@ Les différents navigateurs définissent cette valeur à différents instants. P Le code HTML suivant démontre l'utilisation de la propriété `stack`. ```html - + Exemple de Trace de Pile diff --git a/files/fr/web/javascript/reference/global_objects/string/repeat/index.md b/files/fr/web/javascript/reference/global_objects/string/repeat/index.md index 4e14cee9564dad..0692f50367f364 100644 --- a/files/fr/web/javascript/reference/global_objects/string/repeat/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/repeat/index.md @@ -43,14 +43,9 @@ Une nouvelle chaîne de caractères composée du nombre indiqué de copies de la "abc".repeat(1); // "abc" "abc".repeat(2); // "abcabc" "abc".repeat(3.5); // "abcabcabc" (le compteur est converti en un nombre entier) -"abc" - .repeat(1 / 0) - ( - // RangeError - - { toString: () => "abc", repeat: String.prototype.repeat }, - ) - .repeat(2); +"abc".repeat(1 / 0); // RangeError + +({ toString: () => "abc", repeat: String.prototype.repeat }).repeat(2); // "abcabc" (repeat() est une méthode générique) ``` diff --git a/files/fr/web/javascript/reference/operators/exponentiation/index.md b/files/fr/web/javascript/reference/operators/exponentiation/index.md index 1313f3b18f5005..422342f6e62116 100644 --- a/files/fr/web/javascript/reference/operators/exponentiation/index.md +++ b/files/fr/web/javascript/reference/operators/exponentiation/index.md @@ -48,7 +48,7 @@ NaN ** 2; // NaN ### Associativité -```js +```js-nolint 2 ** 3 ** 2; // 512 2 ** (3 ** 2); // 512 (2 ** 3) ** 2; // 64 diff --git a/files/fr/web/javascript/reference/operators/grouping/index.md b/files/fr/web/javascript/reference/operators/grouping/index.md index d7685fc0523658..80ccafc841ce68 100644 --- a/files/fr/web/javascript/reference/operators/grouping/index.md +++ b/files/fr/web/javascript/reference/operators/grouping/index.md @@ -24,7 +24,7 @@ L'opérateur de groupement consiste en une paire de parenthèses encadrant une e Normalement, la multiplication et la division sont prises en compte avant l'addition et la soustraction. On peut changer ce comportement avec l'opérateur de groupement. -```js +```js-nolint var a = 1; var b = 2; var c = 3; diff --git a/files/fr/web/javascript/reference/operators/logical_and/index.md b/files/fr/web/javascript/reference/operators/logical_and/index.md index fbe29329d2d7cf..4529ec19bb9a7f 100644 --- a/files/fr/web/javascript/reference/operators/logical_and/index.md +++ b/files/fr/web/javascript/reference/operators/logical_and/index.md @@ -60,7 +60,7 @@ console.log(A() && B()); Les expressions suivantes peuvent sembler équivalentes mais ne le sont pas. En effet, l'opérateur `&&` est exécuté avant l'opérateur `||` (voir [l'article sur la précédence des opérateurs](/fr/docs/Web/JavaScript/Reference/Operators/Operator_Precedence)). -```js +```js-nolint true || false && false; // renvoie true, car && est exécuté en premier (true || false) && false; // renvoie false, car la précédence par défaut ne s'applique pas avec les parenthèses ``` diff --git a/files/fr/web/javascript/reference/operators/logical_or/index.md b/files/fr/web/javascript/reference/operators/logical_or/index.md index 4c49f840e6b7bf..cae02f7a53c0c3 100644 --- a/files/fr/web/javascript/reference/operators/logical_or/index.md +++ b/files/fr/web/javascript/reference/operators/logical_or/index.md @@ -60,7 +60,7 @@ console.log(B() || A()); Les expressions suivantes peuvent sembler équivalentes mais ne le sont pas. En effet, l'opérateur `&&` est exécuté avant l'opérateur `||` (voir [l'article sur la précédence des opérateurs](/fr/docs/Web/JavaScript/Reference/Operators/Operator_Precedence)). -```js +```js-nolint true || false && false; // renvoie true, car && est exécuté en premier (true || false) && false; // renvoie false, car la précédence par défaut ne s'applique pas avec les parenthèses ``` diff --git a/files/fr/web/javascript/reference/operators/unary_plus/index.md b/files/fr/web/javascript/reference/operators/unary_plus/index.md index a919dedd5cf421..e65fe4aff2452a 100644 --- a/files/fr/web/javascript/reference/operators/unary_plus/index.md +++ b/files/fr/web/javascript/reference/operators/unary_plus/index.md @@ -37,11 +37,13 @@ console.log(+y); ### Avec des valeurs non-numériques ```js -+true; // 1 ++true; // 1 +false; // 0 -+null; // 0 -+function(val) { return val }; // NaN -+1n; // throws TypeError: Cannot convert BigInt value to number ++null; // 0 ++function (val) { + return val; +}; // NaN ++1n; // throws TypeError: Cannot convert BigInt value to number ``` ## Spécifications diff --git a/files/fr/web/javascript/reference/strict_mode/index.md b/files/fr/web/javascript/reference/strict_mode/index.md index 20b7f2dd11d77d..b30050821263d7 100644 --- a/files/fr/web/javascript/reference/strict_mode/index.md +++ b/files/fr/web/javascript/reference/strict_mode/index.md @@ -172,7 +172,8 @@ Premièrement, le mode strict interdit l'utilisation de `with`. Le problème ave ```js "use strict"; var x = 17; -with (obj) { // !!! erreur de syntaxe +with (obj) { + // !!! erreur de syntaxe // Si on n'était pas en mode strict, serait-ce var x, // ou serait-ce plutôt obj.x? Il est impossible en général // de le dire sans faire tourner le code, donc From 32583616be82151dbba2b4b761a64cb39086a7a2 Mon Sep 17 00:00:00 2001 From: Jason Lam Date: Fri, 28 Jul 2023 18:41:08 +0800 Subject: [PATCH 18/30] [zh-cn]: Update translation of String.padStart() (#14634) Co-authored-by: Jason Ren <40999116+jasonren0403@users.noreply.github.com> --- .../global_objects/string/padstart/index.md | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/padstart/index.md b/files/zh-cn/web/javascript/reference/global_objects/string/padstart/index.md index 77b0a60ddd119e..f33b93dc6540c6 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/padstart/index.md +++ b/files/zh-cn/web/javascript/reference/global_objects/string/padstart/index.md @@ -5,13 +5,13 @@ slug: Web/JavaScript/Reference/Global_Objects/String/padStart {{JSRef}} -**`padStart()`** 方法用另一个字符串填充当前字符串(如果需要的话,会重复多次),以便产生的字符串达到给定的长度。从当前字符串的左侧开始填充。 +**`padStart()`** 方法用另一个字符串填充当前字符串(如果需要会重复填充),直到达到给定的长度。填充是从当前字符串的开头开始的。 {{EmbedInteractiveExample("pages/js/string-padstart.html")}} ## 语法 -```js +```js-nolint padStart(targetLength) padStart(targetLength, padString) ``` @@ -19,38 +19,37 @@ padStart(targetLength, padString) ### 参数 - `targetLength` - - : 当前字符串需要填充到的目标长度。如果这个数值小于当前字符串的长度,则返回当前字符串本身。 + - : 当前 `str` 填充后的长度。如果该值小于或等于 `str.length`,则会直接返回当前 `str`。 - `padString` {{optional_inline}} - - : 填充字符串。如果字符串太长,使填充后的字符串长度超过了目标长度,则只保留最左侧的部分,其他部分会被截断。此参数的默认值为 " "(U+0020)。 + - : 用于填充当前 `str` 的字符串。如果 `padString` 太长,无法适应 `targetLength`,则会从末尾被截断。默认值为 Unicode“空格”字符(U+0020)。 ### 返回值 -在原字符串开头填充指定的填充字符串直到目标长度所形成的新字符串。 +在开头填充 `padString` 直到达到给定的 `targetLength` 所形成的 {{jsxref("String")}}。 ## 示例 ### 简单示例 ```js -'abc'.padStart(10); // " abc" -'abc'.padStart(10, "foo"); // "foofoofabc" -'abc'.padStart(6,"123465"); // "123abc" -'abc'.padStart(8, "0"); // "00000abc" -'abc'.padStart(1); // "abc" +"abc".padStart(10); // " abc" +"abc".padStart(10, "foo"); // "foofoofabc" +"abc".padStart(6, "123465"); // "123abc" +"abc".padStart(8, "0"); // "00000abc" +"abc".padStart(1); // "abc" ``` ### 将数字转换为固定长度的字符串 ```js // JavaScript version of: (unsigned) -// printf "%0*d" width num +// printf "%0*d" width num function leftFillNum(num, targetLength) { - return num.toString().padStart(targetLength, 0); + return num.toString().padStart(targetLength, "0"); } const num = 123; -console.log(leftFillNum(num, 5)); -// 预期输出:"00123" +console.log(leftFillNum(num, 5)); // "00123" ``` ## 规范 @@ -63,6 +62,5 @@ console.log(leftFillNum(num, 5)); ## 参见 -- [Polyfill of `String.prototype.padStart` in `core-js`](https://github.com/zloirock/core-js#ecmascript-string-and-regexp) +- [`core-js` 中 `String.prototype.padStart` 的 polyfill](https://github.com/zloirock/core-js#ecmascript-string-and-regexp) - {{jsxref("String.prototype.padEnd()")}} -- [A polyfill](https://github.com/behnammodi/polyfill/blob/master/string.polyfill.js) From 58cf75f884999b3475b595c6cd3fbf098f34516c Mon Sep 17 00:00:00 2001 From: Jason Lam Date: Fri, 28 Jul 2023 18:41:24 +0800 Subject: [PATCH 19/30] [zh-cn]: Update translation of String.padEnd() (#14633) Co-authored-by: Jason Ren <40999116+jasonren0403@users.noreply.github.com> --- .../global_objects/string/padend/index.md | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/padend/index.md b/files/zh-cn/web/javascript/reference/global_objects/string/padend/index.md index e45a5ffaafd327..f2e216d6a13172 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/padend/index.md +++ b/files/zh-cn/web/javascript/reference/global_objects/string/padend/index.md @@ -5,13 +5,13 @@ slug: Web/JavaScript/Reference/Global_Objects/String/padEnd {{JSRef}} -**`padEnd()`** 方法会用一个字符串填充当前字符串(如果需要的话则重复填充),返回填充后达到指定长度的字符串。从当前字符串的末尾(右侧)开始填充。 +**`padEnd()`** 方法会将当前字符串从末尾开始填充给定的字符串(如果需要会重复填充),直到达到给定的长度。填充是从当前字符串的末尾开始的。 {{EmbedInteractiveExample("pages/js/string-padend.html")}} ## 语法 -```js +```js-nolint padEnd(targetLength) padEnd(targetLength, padString) ``` @@ -19,21 +19,23 @@ padEnd(targetLength, padString) ### 参数 - `targetLength` - - : 当前字符串需要填充到的目标长度。如果这个数值小于当前字符串的长度,则返回当前字符串本身。 + - : 当前 `str` 填充后的长度。如果该值小于或等于 `str.length`,则会直接返回当前 `str`。 - `padString` {{optional_inline}} - - : 填充字符串。如果字符串太长,使填充后的字符串长度超过了目标长度,则只保留最左侧的部分,其他部分会被截断。此参数的缺省值为 " "(U+0020)。 + - : 用于填充当前 `str` 的字符串。如果 `padString` 太长,无法适应 `targetLength`,则会被截断:对于从左到右的语言,左侧的部分将会被保留;对于从右到左的语言,右侧的部分将会被保留。默认值为“ ” (`U+0020`)。 ### 返回值 -在原字符串末尾填充指定的填充字符串直到目标长度所形成的新字符串。 +在当前 `str` 末尾填充 `padString` 直到达到给定的 `targetLength` 所形成的 {{jsxref("String")}}。 ## 示例 +### 使用 padEnd + ```js -'abc'.padEnd(10); // "abc " -'abc'.padEnd(10, "foo"); // "abcfoofoof" -'abc'.padEnd(6, "123456"); // "abc123" -'abc'.padEnd(1); // "abc" +"abc".padEnd(10); // "abc " +"abc".padEnd(10, "foo"); // "abcfoofoof" +"abc".padEnd(6, "123456"); // "abc123" +"abc".padEnd(1); // "abc" ``` ## 规范 @@ -46,6 +48,5 @@ padEnd(targetLength, padString) ## 参见 -- [Polyfill of `String.prototype.padEnd` in `core-js`](https://github.com/zloirock/core-js#ecmascript-string-and-regexp) +- [`core-js` 中 `String.prototype.padEnd` 的 polyfill](https://github.com/zloirock/core-js#ecmascript-string-and-regexp) - {{jsxref("String.prototype.padStart()")}} -- [A polyfill](https://github.com/behnammodi/polyfill/blob/master/string.polyfill.js) From ebe0b0ee27b9270ff1b61645a1b41346e0149afa Mon Sep 17 00:00:00 2001 From: Jason Ren <40999116+jasonren0403@users.noreply.github.com> Date: Fri, 28 Jul 2023 18:43:10 +0800 Subject: [PATCH 20/30] Update 'css FAQ' and fix prettier (#14548) Co-authored-by: A1lo --- .prettierignore | 1 - files/zh-cn/learn/css/howto/css_faq/index.md | 81 ++++++++++---------- 2 files changed, 39 insertions(+), 43 deletions(-) diff --git a/.prettierignore b/.prettierignore index 707554e6dcef7d..4c0ab9d179b0d5 100644 --- a/.prettierignore +++ b/.prettierignore @@ -30,7 +30,6 @@ build/ /files/ru/learn/server-side/django/forms/index.md /files/ru/learn/server-side/django/introduction/index.md /files/ru/learn/html/introduction_to_html/the_head_metadata_in_html/index.md -/files/zh-cn/learn/css/howto/css_faq/index.md /files/zh-cn/learn/server-side/django/forms/index.md # A full pass on all Markdown files is being performed. diff --git a/files/zh-cn/learn/css/howto/css_faq/index.md b/files/zh-cn/learn/css/howto/css_faq/index.md index 8c2655bc5b7a4c..86579c388400ea 100644 --- a/files/zh-cn/learn/css/howto/css_faq/index.md +++ b/files/zh-cn/learn/css/howto/css_faq/index.md @@ -1,27 +1,31 @@ --- title: CSS 常见问题 slug: Learn/CSS/Howto/CSS_FAQ -original_slug: Web/CSS/Common_CSS_Questions --- +{{LearnSidebar}} + +在本篇文章中,你会发现一些有关 CSS 的常见问题,这些问题及其解答可能会有助于你成为一名网站开发人员。 + ## 为什么有效的 CSS 没有正确的渲染? -浏览器使用 DOCTYPE 声明来选择是否使用更符合 Web 标准或兼容旧浏览器的 bug 的模式。在你的 HTML 的开始使用一个正确的和现代的 DOCTYPE 声明将改善浏览器标准执行。 +浏览器使用 `DOCTYPE` 声明来选择是否使用更符合 Web 标准或兼容旧浏览器缺陷的模式。在你的 HTML 的开始使用一个正确的和现代的 `DOCTYPE` 声明将改善浏览器标准执行。 现代浏览器主要有两种渲染模式: -- _怪异模式_:又称向后兼容模式,允许将传统网页渲染为作者意图。旧浏览器使用的非标准渲染规则。不完整的、不正确的、缺少 DOCTYPE 声明或已知的 DOCTYPE 声明中普遍使用 2001 年以前的文件将在怪异模式中呈现。 -- _标准模式_:浏览器试图严格遵守 W3C 标准。新 HTML 网页有望被设计为符合标准的浏览器,这样做的结果就是,用现代 DOCTYPE 声明的页面将被用标准模式呈现。 +- _怪异模式_:又称向后兼容模式,允许按照旧版浏览器使用的非标准渲染规则,按作者的意图呈现旧版网页。如果文档中存在不完整、不正确或缺失的 `DOCTYPE` 声明,或已知的 2001 年以前常用的 `DOCTYPE` 声明,则会以怪异模式渲染。 +- _标准模式_:浏览器试图严格遵守 W3C 标准。新的 HTML 页面预计是为符合标准的浏览器设计的,因此,带有现代 `DOCTYPE` 声明的页面将使用标准模式渲染。 -基于 Gecko 的浏览器,有三分之一 _[Almost Standards Mode](/zh-CN/docs/Gecko's_%22Almost_Standards%22_Mode)_,只有一些小怪癖。 +有三分之一的基于 Gecko 的浏览器处于[接近标准模式](https://zh.wikipedia.org/wiki/怪异模式#接近标准模式),只是有一些怪异行为。 -这是最常用的触发标准模式或准标准模式的 DOCTYPE 声明列表: +这是最常用的触发标准模式的 `DOCTYPE` 声明: ```html - /* 这一行是 HTML5 的 doctype 声明。使用该声明会使现代浏览器使用 -HTML5 解析器处理页面,这是推荐的 doctype 声明。*/ + ``` +你应该尽可能使用上述 doctype 声明。还有其他有效的传统 doctype 说明,它们会触发标准模式或接近标准模式: + ```html ``` @@ -38,33 +42,27 @@ HTML5 解析器处理页面,这是推荐的 doctype 声明。*/ ``` -请尽可能地使用 HTML 5 DOCTYPE。 - ## 为什么有效的 CSS 完全没有被渲染? 可能的原因如下: - 引入的 CSS 文件路径写错了。 - -- 为了使浏览器渲染样式文件,CSS 样式表必须用 `text/css` 的 MIME。如果 Web 服务器没有使用这种类型处理文件,则 CSS 也不会被应用。 +- 为了使浏览器渲染样式文件,CSS 样式表必须用 `text/css` 的 MIME 类型。如果 Web 服务器没有使用这种类型处理文件,则 CSS 也不会被应用。 ## `id` 和 `class` 有什么不同? -HTML 元素可以拥有一个 `id`/或 `class` 属性。 `id` 属性为元素指定应用一个有效名称,只能有一个具有该名称的元素。`class` 属性指定一个类名的元素,而这个名称可以被页面内的许多元素被使用。CSS 允许你可以对特定的 `id` 和/或类名的元素应用样式。 - -- 当你想要将样式规则应用于多个块和元素时,你应该使用 class 选择符。 +HTML 元素可以拥有一个 `id` 和(或)`class` 属性。`id` 属性为元素指定应用一个有效名称,只能有一个具有该名称的元素。`class` 属性指定一个类名的元素,而这个名称可以被页面内的许多元素被使用。CSS 允许你可以对特定的 `id` 和/或类名的元素应用样式。 -- 当你想给一个特定元素或块应用样式规则时就使用 ID 选择符。此样式将只用于与该特定 id 匹配的元素。 +- 当你想要将样式规则应用于多个块和元素时,你应该使用特定于类的样式。 +- 当你想给一个特定元素或块应用样式规则时就使用特定于 id 的样式。此样式将只用于与该特定 id 匹配的元素。 -较少样式的样式表通常性能更高。因此建议尽可能多地使用类,保留 id 作为特定用途(比如链接 label 标签和 form 元素或者为语义上唯一的元素应用样式): +一般建议尽量使用类,只有在特定用途(如连接标签和表单元素或用于必须在语义上唯一的样式元素)绝对必要时才使用 id: - 使用类名可以让样式具有可扩展性——即使目前只有一个元素使用这个规则集来定义样式,未来可能会添加更多。 - - 类名可以让你同时为多个元素赋予样式,减少样式表的大小,避免了为每一个 id 选择器撰写同样的样式信息。越小的样式表带来的性能体验也就越好。 - - 类名选择器比 id 选择器的[优先级](/zh-CN/docs/Learn/CSS/Building_blocks/Cascade_and_inheritance#优先级)更低,所以可以很方便地覆盖它们。 -> **备注:** 在这篇文档中更深入层次的了解 [CSS 选择器](/zh-CN/docs/Learn/CSS/Building_blocks/Selectors)。 +> **备注:** 参见 [CSS 选择器](/zh-CN/docs/Learn/CSS/Building_blocks/Selectors),以了解详情。 ## 我如何还原属性的默认值? @@ -80,7 +78,7 @@ h1 { } ``` -从 CSS2 开始,情况就不一样了。关键字 [initial](/zh-CN/docs/Web/CSS/initial) 现在是一个有效的 CSS 属性。它将给定的 CSS 属性值重置为默认值。 +从 CSS2 开始,情况就不一样了。关键字 [initial](/zh-CN/docs/Web/CSS/initial) 现在是一个有效的 CSS 属性值。它将给定的 CSS 属性值重置为默认值。 ```css /* 标题元素的默认颜色为黑色 */ @@ -94,14 +92,14 @@ h1 { ## 我如何才可以从一个样式中衍生出另一种样式? -CSS 不允许这样做(请查阅 [Eric Meyer's note about the Working Group's stance](http://archivist.incutio.com/viewlist/css-discuss/2685))。但是,将多个类分配给单个元素,可以提供相同的效果。[CSS 变量](/zh-CN/docs/Web/CSS/Using_CSS_custom_properties) 也提供了一种方法来定义在多处复用的样式信息。 +CSS 并不完全允许用一种样式来定义另一种样式。但是,将多个类分配给单个元素,可以提供相同的效果。[CSS 变量](/zh-CN/docs/Web/CSS/Using_CSS_custom_properties)也提供了一种方法来定义在多处复用的样式信息。 ## 我该如何给一个元素分配多个类? HTML 元素可以通过列出的类属性,用空格分开它们。 ```html - -
... content of today's news ...
+
这是今天的新闻内容。
``` -如果相同的属性中声明的规则,解决冲突首先通过特异性,然后根据 CSS 声明的顺序。在 `class` 属性类的顺序是不相关的。 +如果两个规则中都声明了相同的属性,则首先通过特异性解决冲突,然后根据 CSS 声明的顺序解决冲突。`class` 属性中类的顺序与此无关。 ## 为什么我的样式规则不能正确地工作? -在语法上正确的样式规则可能在某些情况下不适用。你可以使用调试工具 CSS 面板的[规则视图](https://firefox-source-docs.mozilla.org/devtools-user/page_inspector/how_to/examine_and_edit_css/index.html)来调试这类问题。下面列出了最常见的忽略样式规则的实例: +在语法上正确的样式规则可能在某些情况下不适用。你可以使用调试工具 *CSS 面板*的[规则视图](https://firefox-source-docs.mozilla.org/devtools-user/page_inspector/how_to/examine_and_edit_css/index.html)来调试这类问题。下面列出了最常见的忽略样式规则的实例: ### HTML 元素层次结构 @@ -146,7 +144,7 @@ CSS 应用于 HTML 元素依靠于元素的层次结构。在任何 CSS 特异 ### 显式重定义样式规则 -在 CSS 样式表中,顺序 **非常** 重要。如果先定义了一个规则,然后又重新定义了同样的规则,会使用最后一个定义。 +在 CSS 样式表中,顺序**非常**重要。如果先定义了一个规则,然后又重新定义了同样的规则,会使用最后一个定义。 ```css #stockTicker { @@ -170,9 +168,9 @@ CSS 应用于 HTML 元素依靠于元素的层次结构。在任何 CSS 特异 为了避免此类错误,请对特定选择器仅定义一次规则,将属于那个选择器的规则归类于此组。 -### 使用便捷属性 +### 使用简写属性 -使用便捷属性的好处是语法更加紧凑。仅使用一部分便捷属性完全没有问题,但要注意,没有声明的属性将自动重置为默认状态,这意味着单个属性较靠前的规则可能会被隐式覆盖。 +使用简写属性的好处是语法更加紧凑。仅使用一部分简写属性完全没有问题,但要注意,没有声明的属性将自动重置为默认状态,这意味着单个属性较靠前的规则可能会被隐式覆盖。 ```css #stockTicker { @@ -190,12 +188,12 @@ CSS 应用于 HTML 元素依靠于元素的层次结构。在任何 CSS 特异
NYS: GE +1.0 ...
``` -在前一个示例中,问题发生在不同元素的规则中;但在同一个元素中问题也可能出现,因为顺序是 **重要** 的。 +在前一个示例中,问题发生在不同元素的规则中;但在同一个元素中问题也可能出现,因为顺序是**重要**的。 ```css #stockTicker { font-weight: bold; - font: 12px Verdana; /* font-weight is now normal */ + font: 12px Verdana; /* font-weight 现在为 normal */ } ``` @@ -230,7 +228,7 @@ body * { ### CSS 中的优先级 -当某个元素应用了多个规则时,规则的选择依赖于样式的 [优先级](/zh-CN/docs/Web/CSS/Specificity)。内联样式(HTML 的 `style` 属性)最高,ID 选择器次之,再其次是类选择器,最后是元素名称选择器。 +当某个元素应用了多个规则时,规则的选择依赖于样式的[优先级](/zh-CN/docs/Learn/CSS/Building_blocks/Cascade_and_inheritance#优先级)。内联样式(HTML 的 `style` 属性)最高,ID 选择器次之,再其次是类选择器,最后是元素名称选择器。{{htmlelement("div")}} 的文本颜色将是红色的。 ```css div { @@ -245,35 +243,34 @@ div { ``` ```html -
This is red
+
我是红的
``` -当选择器具有多个部分时,规则会更加复杂。有关优先级计算的更多信息,请参阅 [CSS 2.1 Specification 6.4.3 章节](https://www.w3.org/TR/CSS21/cascade.html#specificity)。 +当选择器具有多个部分时,规则会更加复杂。有关优先级计算的更多信息,请参阅 [CSS 优先级文档](/zh-CN/docs/Web/CSS/Specificity)。 ## -moz-\*, -ms-\*, -webkit-\*, -o-\* 以及 -khtml-\* 属性有什么用? 这些被称为*前缀属性*的属性是 CSS 标准的扩展。这些是出于测试目的的使用,不至于污染标准命名空间,防止标准扩展时产生兼容性问题。 -不推荐在生产环境网站中使用这些属性,它们已经产生了巨大的网页兼容性混乱。例如,很多开发者只使用了 `-webkit-` 前缀版本的属性,但非前缀的版本已经在所有浏览器中得到支持,没有基于 Webkit 的浏览器很有可能会在今后丢失显示效果。这个问题过于严重,以至于其他浏览器也开始实现 `-webkit-` 前缀属性的别名以提升网站兼容性,即 [Compatibility Living Standard](https://compat.spec.whatwg.org/)。 +不推荐在生产环境网站中使用这些属性,它们已经产生了巨大的网页兼容性混乱。例如,很多开发者只使用了 `-webkit-` 前缀版本的属性,但非前缀的版本已经在所有浏览器中得到支持,没有基于 Webkit 的浏览器很有可能会在今后丢失显示效果。这个问题过于严重,以至于其他浏览器也开始实现 `-webkit-` 前缀属性的别名以提升网站兼容性,即[兼容性动态标准](https://compat.spec.whatwg.org/)。 实际上,大部分浏览器在实现实验性功能时都不使用 CSS 前缀,或者仅在 Nightly 浏览器版本或相似机制上实现它们。 如果需要使用前缀,建议先写带前缀的属性,然后再写不带前缀的标准版本。这样就可以在标准版本支持的时候覆盖掉前缀版本。例如: ```css --ms-transform: rotate(90deg); --webkit-transform: rotate(90deg); -transform: rotate(90deg); +-webkit-text-stroke: 4px navy; +text-stroke: 4px navy; ``` -> **备注:** 为更深层次了解处理前缀属性,请参阅 [跨浏览器测试](/zh-CN/docs/Learn/Tools_and_testing/Cross_browser_testing) 模块的 [处理常见的 HTML 和 CSS 问题](/zh-CN/docs/Learn/Tools_and_testing/Cross_browser_testing/HTML_and_CSS)。 +> **备注:** 为更深层次了解处理前缀属性,请参阅[跨浏览器测试](/zh-CN/docs/Learn/Tools_and_testing/Cross_browser_testing)模块的[处理常见的 HTML 和 CSS 问题——处理 CSS 前缀](/zh-CN/docs/Learn/Tools_and_testing/Cross_browser_testing/HTML_and_CSS#处理_css_前缀)。 -> **备注:** 为了解 Mozilla 前缀属性 CSS 的更多信息,请参阅 [Mozilla CSS 扩展](/zh-CN/docs/Web/CSS/Mozilla_Extensions)。 +> **备注:** 请参阅 [Mozilla CSS 扩展](/zh-CN/docs/Web/CSS/Mozilla_Extensions)和 [WebKit CSS 扩展](/zh-CN/docs/Web/CSS/WebKit_Extensions),以了解浏览器前缀 CSS 属性的列表。 ## z-index 属性与定位有什么关系? z-index 属性指定了元素的栈序。 -有较高 z-index/栈序的元素总是在有着较低 z-index/栈序的元素之前。z-index 只会在有着指定 position(`position:absolute`、`position:relative` 或 `position:fixed`)的元素上工作。 +具有较高 z-index/栈序的元素总是渲染于具有较低 z-index/栈序的元素之前。z-index 只会在有着指定 position(`position:absolute`、`position:relative` 或 `position:fixed`)的元素上工作。 -> **备注:** 请参阅 [定位](/zh-CN/docs/Learn/CSS/CSS_layout/Positioning) 文章,特别是 [介绍 z-index](/zh-CN/docs/Learn/CSS/CSS_layout/Positioning#介绍_z-index) 部分来深入学习。 +> **备注:** 请参阅[定位](/zh-CN/docs/Learn/CSS/CSS_layout/Positioning)文章,特别是[介绍 z-index](/zh-CN/docs/Learn/CSS/CSS_layout/Positioning#介绍_z-index) 部分来深入学习。 From e0f73ae86e34e36631d4594dc5f04453a6f4a422 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 04:14:52 -0700 Subject: [PATCH 21/30] zh-cn: Format /web/svg using Prettier (#14672) --- .prettierignore | 1 - .../index.md | 131 ++++++---- .../web/svg/attribute/attributename/index.md | 2 +- .../web/svg/attribute/baseline-shift/index.md | 8 +- .../web/svg/attribute/baseprofile/index.md | 10 +- files/zh-cn/web/svg/attribute/begin/index.md | 2 +- .../web/svg/attribute/clip-path/index.md | 48 +++- files/zh-cn/web/svg/attribute/clip/index.md | 18 +- files/zh-cn/web/svg/attribute/color/index.md | 10 +- files/zh-cn/web/svg/attribute/cx/index.md | 70 +++-- files/zh-cn/web/svg/attribute/cy/index.md | 70 +++-- files/zh-cn/web/svg/attribute/d/index.md | 194 +++++++++----- .../zh-cn/web/svg/attribute/display/index.md | 18 +- files/zh-cn/web/svg/attribute/dur/index.md | 2 +- files/zh-cn/web/svg/attribute/dx/index.md | 8 +- files/zh-cn/web/svg/attribute/end/index.md | 2 +- .../web/svg/attribute/fill-opacity/index.md | 2 +- .../web/svg/attribute/fill-rule/index.md | 74 ++++-- files/zh-cn/web/svg/attribute/fill/index.md | 2 +- files/zh-cn/web/svg/attribute/filter/index.md | 2 +- .../web/svg/attribute/font-family/index.md | 8 +- files/zh-cn/web/svg/attribute/fr/index.md | 54 ++-- files/zh-cn/web/svg/attribute/from/index.md | 2 +- files/zh-cn/web/svg/attribute/fx/index.md | 47 ++-- files/zh-cn/web/svg/attribute/height/index.md | 11 +- files/zh-cn/web/svg/attribute/id/index.md | 9 +- files/zh-cn/web/svg/attribute/in/index.md | 74 ++++-- .../web/svg/attribute/kernelmatrix/index.md | 6 +- .../zh-cn/web/svg/attribute/keytimes/index.md | 46 ++-- .../web/svg/attribute/letter-spacing/index.md | 10 +- .../web/svg/attribute/marker-end/index.md | 27 +- .../web/svg/attribute/marker-start/index.md | 27 +- files/zh-cn/web/svg/attribute/mask/index.md | 6 +- files/zh-cn/web/svg/attribute/max/index.md | 22 +- files/zh-cn/web/svg/attribute/media/index.md | 12 +- .../zh-cn/web/svg/attribute/opacity/index.md | 6 +- files/zh-cn/web/svg/attribute/order/index.md | 6 +- .../web/svg/attribute/pathlength/index.md | 70 ++--- .../web/svg/attribute/patternunits/index.md | 30 ++- .../web/svg/attribute/pointer-events/index.md | 22 +- files/zh-cn/web/svg/attribute/points/index.md | 6 +- .../attribute/preserveaspectratio/index.md | 9 +- files/zh-cn/web/svg/attribute/r/index.md | 32 ++- files/zh-cn/web/svg/attribute/radius/index.md | 6 +- files/zh-cn/web/svg/attribute/result/index.md | 6 +- files/zh-cn/web/svg/attribute/rx/index.md | 26 +- files/zh-cn/web/svg/attribute/scale/index.md | 6 +- files/zh-cn/web/svg/attribute/seed/index.md | 6 +- .../svg/attribute/stroke-dasharray/index.md | 55 ++-- .../svg/attribute/stroke-dashoffset/index.md | 8 +- .../web/svg/attribute/stroke-linecap/index.md | 52 ++-- .../svg/attribute/stroke-linejoin/index.md | 177 +++++++++---- .../svg/attribute/stroke-miterlimit/index.md | 8 +- .../web/svg/attribute/stroke-opacity/index.md | 18 +- .../web/svg/attribute/stroke-width/index.md | 6 +- files/zh-cn/web/svg/attribute/stroke/index.md | 12 +- files/zh-cn/web/svg/attribute/style/index.md | 8 +- files/zh-cn/web/svg/attribute/target/index.md | 26 +- .../web/svg/attribute/text-anchor/index.md | 57 +++-- .../web/svg/attribute/transform/index.md | 127 ++++++--- files/zh-cn/web/svg/attribute/type/index.md | 2 +- files/zh-cn/web/svg/attribute/values/index.md | 1 + .../web/svg/attribute/vector-effect/index.md | 23 +- .../zh-cn/web/svg/attribute/version/index.md | 6 +- files/zh-cn/web/svg/attribute/y/index.md | 2 +- files/zh-cn/web/svg/content_type/index.md | 22 +- files/zh-cn/web/svg/element/a/index.md | 18 +- files/zh-cn/web/svg/element/animate/index.md | 14 +- .../web/svg/element/animatemotion/index.md | 9 +- .../web/svg/element/animatetransform/index.md | 30 ++- files/zh-cn/web/svg/element/circle/index.md | 8 +- files/zh-cn/web/svg/element/clippath/index.md | 19 +- files/zh-cn/web/svg/element/feblend/index.md | 29 ++- .../web/svg/element/fecolormatrix/index.md | 42 ++- .../svg/element/fecomponenttransfer/index.md | 36 ++- .../svg/element/fediffuselighting/index.md | 43 +++- .../web/svg/element/fedropshadow/index.md | 34 +-- .../web/svg/element/fegaussianblur/index.md | 30 +-- files/zh-cn/web/svg/element/feimage/index.md | 11 +- files/zh-cn/web/svg/element/filter/index.md | 11 +- .../web/svg/element/foreignobject/index.md | 19 +- files/zh-cn/web/svg/element/g/index.md | 7 +- files/zh-cn/web/svg/element/image/index.md | 16 +- .../web/svg/element/lineargradient/index.md | 14 +- files/zh-cn/web/svg/element/marker/index.md | 16 +- files/zh-cn/web/svg/element/mpath/index.md | 45 ++-- files/zh-cn/web/svg/element/path/index.md | 6 +- .../web/svg/element/radialgradient/index.md | 22 +- files/zh-cn/web/svg/element/rect/index.md | 6 +- files/zh-cn/web/svg/element/script/index.md | 16 +- files/zh-cn/web/svg/element/stop/index.md | 21 +- files/zh-cn/web/svg/element/style/index.md | 7 +- files/zh-cn/web/svg/element/svg/index.md | 28 +- files/zh-cn/web/svg/element/symbol/index.md | 29 ++- files/zh-cn/web/svg/element/textpath/index.md | 26 +- files/zh-cn/web/svg/element/tspan/index.md | 4 +- files/zh-cn/web/svg/linking/index.md | 2 +- .../web/svg/svg_animation_with_smil/index.md | 50 ++-- .../tutorial/clipping_and_masking/index.md | 28 +- .../svg/tutorial/fills_and_strokes/index.md | 8 +- .../web/svg/tutorial/filter_effects/index.md | 98 ++++--- .../web/svg/tutorial/getting_started/index.md | 6 +- .../zh-cn/web/svg/tutorial/gradients/index.md | 241 ++++++++++++------ .../zh-cn/web/svg/tutorial/patterns/index.md | 28 +- .../web/svg/tutorial/svg_and_css/index.md | 198 +++++++------- 105 files changed, 2026 insertions(+), 1125 deletions(-) diff --git a/.prettierignore b/.prettierignore index 4c0ab9d179b0d5..93ef1c28e73f10 100644 --- a/.prettierignore +++ b/.prettierignore @@ -93,4 +93,3 @@ build/ /files/zh-cn/web/css/**/*.md /files/zh-cn/web/html/**/*.md /files/zh-cn/web/javascript/reference/**/*.md -/files/zh-cn/web/svg/**/*.md diff --git a/files/zh-cn/web/svg/applying_svg_effects_to_html_content/index.md b/files/zh-cn/web/svg/applying_svg_effects_to_html_content/index.md index 85dfae74cc4811..716e02f2234db6 100644 --- a/files/zh-cn/web/svg/applying_svg_effects_to_html_content/index.md +++ b/files/zh-cn/web/svg/applying_svg_effects_to_html_content/index.md @@ -16,7 +16,11 @@ slug: Web/SVG/Applying_SVG_effects_to_HTML_content 要想在 CSS 样式中应用 SVG 效果,首先需要创建一个引用 SVG 的 CSS 样式。 ```html - + ``` 在上面的例子中,所有段落会被 [ID](/zh-CN/docs/Web/HTML/Global_attributes/id) 为 `my-mask` 的 [SVG ``](/zh-CN/docs/Web/SVG/Element/mask) 遮罩。 @@ -29,11 +33,11 @@ slug: Web/SVG/Applying_SVG_effects_to_HTML_content - - + + - - + + ``` @@ -55,14 +59,15 @@ p { ```html

- Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt - ut labore et dolore magna aliqua. Ut enim ad minim veniam. + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.

- Lorem ipsum dolor sit amet, consectetur adipisicing - elit, sed do eiusmod tempor incididunt - ut labore et dolore magna aliqua. - Ut enim ad minim veniam. + Lorem ipsum dolor sit amet, consectetur adipisicing + elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + Ut enim ad minim veniam.

``` @@ -76,22 +81,23 @@ p { ```html

- Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt - ut labore et dolore magna aliqua. Ut enim ad minim veniam. + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.

- Lorem ipsum dolor sit amet, consectetur adipisicing - elit, sed do eiusmod tempor incididunt - ut labore et dolore magna aliqua. - Ut enim ad minim veniam. + Lorem ipsum dolor sit amet, consectetur adipisicing + elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + Ut enim ad minim veniam.

- - + + ``` @@ -114,7 +120,7 @@ p { ```js function toggleRadius() { var circle = document.getElementById("circle"); - circle.r.baseVal.value = 0.40 - circle.r.baseVal.value; + circle.r.baseVal.value = 0.4 - circle.r.baseVal.value; } ``` @@ -126,15 +132,16 @@ function toggleRadius() { ```html

- Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt - ut labore et dolore magna aliqua. Ut enim ad minim veniam. + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.

lorem

- Lorem ipsum dolor sit amet, consectetur adipisicing - elit, sed do eiusmod tempor incididunt - ut labore et dolore magna aliqua. - Ut enim ad minim veniam. + Lorem ipsum dolor sit amet, consectetur adipisicing + elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + Ut enim ad minim veniam.

``` @@ -143,7 +150,7 @@ function toggleRadius() { ```html - + ``` @@ -153,10 +160,11 @@ function toggleRadius() { ```html - + ``` @@ -166,20 +174,29 @@ function toggleRadius() { ```html - + - - + + - + ``` @@ -187,12 +204,24 @@ function toggleRadius() { 使用以下 CSS 应用五个过滤器: ```css -p.target { filter:url(#f3); } -p.target:hover { filter:url(#f5); } -b.target { filter:url(#f1); } -b.target:hover { filter:url(#f4); } -pre.target { filter:url(#f2); } -pre.target:hover { filter:url(#f3); } +p.target { + filter: url(#f3); +} +p.target:hover { + filter: url(#f5); +} +b.target { + filter: url(#f1); +} +b.target:hover { + filter: url(#f4); +} +pre.target { + filter: url(#f2); +} +pre.target:hover { + filter: url(#f3); +} ``` {{EmbedLiveSample('示例:Filtering', 650, 200)}} @@ -206,7 +235,7 @@ pre.target:hover { filter:url(#f3); } - + @@ -215,7 +244,9 @@ pre.target:hover { filter:url(#f3); } 你可以在同一个 class 中使用 SVG 和 CSS 过滤器: ```css -.blur { filter: url(#wherearemyglasses); } +.blur { + filter: url(#wherearemyglasses); +} ``` {{ EmbedLiveSample('示例:Blurred Text', 300, 100) }} @@ -241,7 +272,9 @@ SVG 还可以用于添加比纯 HTML 文本更动态、更灵活的文本添加 例如,CSS 规则在一个名为 default.css 的文件中,如下这样: ```css -.target { clip-path: url(resources.svg#c1); } +.target { + clip-path: url(resources.svg#c1); +} ``` 这个 SVG 就可以从一个名为 resources.svg 的文件中导入,clip 路径为 ID c1。 diff --git a/files/zh-cn/web/svg/attribute/attributename/index.md b/files/zh-cn/web/svg/attribute/attributename/index.md index f6f2119fb0ea14..d3a627960647f6 100644 --- a/files/zh-cn/web/svg/attribute/attributename/index.md +++ b/files/zh-cn/web/svg/attribute/attributename/index.md @@ -11,7 +11,7 @@ slug: Web/SVG/Attribute/attributeName | 类别 | 动画属性目标属性 | | -------- | ------------------------------------------------------------------------------------- | -| 值 | \ | +| 值 | \ | | 可变性 | No | | 规范文档 | [SVG 1.1 (2nd Edition)](http://www.w3.org/TR/SVG/animate.html#AttributeNameAttribute) | diff --git a/files/zh-cn/web/svg/attribute/baseline-shift/index.md b/files/zh-cn/web/svg/attribute/baseline-shift/index.md index fc01b4121995cc..1f6e7becfee3f1 100644 --- a/files/zh-cn/web/svg/attribute/baseline-shift/index.md +++ b/files/zh-cn/web/svg/attribute/baseline-shift/index.md @@ -11,11 +11,11 @@ slug: Web/SVG/Attribute/baseline-shift ## 用法 -| 类别 | 外观属性 | -| -------- | ---------------------------------------------------------------------------------------------------------- | +| 类别 | 外观属性 | +| -------- | --------------------------------------------------------------------------------------------------------------- | | 值 | **auto** \| baseline \| super \| sub \| \ \| [\](/zh-CN/SVG/Content_type#Length) \| inherit | -| 可变性 | Yes | -| 规范文档 | [SVG 1.1 (2nd Edition)](http://www.w3.org/TR/SVG11/text.html#BaselineShiftProperty) | +| 可变性 | Yes | +| 规范文档 | [SVG 1.1 (2nd Edition)](http://www.w3.org/TR/SVG11/text.html#BaselineShiftProperty) | - baseline - : 没有基线切换,`dominant-baseline`依然在原来的位置。 diff --git a/files/zh-cn/web/svg/attribute/baseprofile/index.md b/files/zh-cn/web/svg/attribute/baseprofile/index.md index b3996c2ce3dedd..0e943cd263b72c 100644 --- a/files/zh-cn/web/svg/attribute/baseprofile/index.md +++ b/files/zh-cn/web/svg/attribute/baseprofile/index.md @@ -29,11 +29,13 @@ slug: Web/SVG/Attribute/baseProfile ## 例子 ```html - - + ... - ``` diff --git a/files/zh-cn/web/svg/attribute/begin/index.md b/files/zh-cn/web/svg/attribute/begin/index.md index 9c0a462b85c2e8..a26c27b78f5a12 100644 --- a/files/zh-cn/web/svg/attribute/begin/index.md +++ b/files/zh-cn/web/svg/attribute/begin/index.md @@ -13,7 +13,7 @@ slug: Web/SVG/Attribute/begin | 类别 | 动画定时属性 | | -------- | ----------------------------------------------------------------------------- | -| 值 | \ | +| 值 | \ | | 可变性 | No | | 规范文档 | [SVG 1.1 (2nd Edition)](http://www.w3.org/TR/SVG/animate.html#BeginAttribute) | diff --git a/files/zh-cn/web/svg/attribute/clip-path/index.md b/files/zh-cn/web/svg/attribute/clip-path/index.md index 8b673cd1749a72..6862efef2167d2 100644 --- a/files/zh-cn/web/svg/attribute/clip-path/index.md +++ b/files/zh-cn/web/svg/attribute/clip-path/index.md @@ -14,7 +14,11 @@ slug: Web/SVG/Attribute/clip-path ## 示例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html @@ -24,24 +28,44 @@ html,body,svg { height:100% } - + - + - + - + ``` @@ -50,9 +74,9 @@ html,body,svg { height:100% } ## Usage notes | 值 | {{cssxref('url')}} \| [ {{cssxref('basic-shape')}} \|\| `` ] \| `none` | -| ---------- | ---------------------------------------------------------------------------------------------------- | -| 默认值 | `none` | -| Animatable | 是 | +| ---------- | ------------------------------------------------------------------------------------ | +| 默认值 | `none` | +| Animatable | 是 | - \ - : geometry-box 是应用 {{cssxref('basic-shape')}} 的额外信息,用于区分 CSS 基本形状如何应用于元素上:`fill-box` 表示将对象的包围框作为参照框;`stroke-box` 表示将对象的包围框加上描边的范围作为参照框;`view-box` 表示使用最近的 SVG 视窗作为参照框。 diff --git a/files/zh-cn/web/svg/attribute/clip/index.md b/files/zh-cn/web/svg/attribute/clip/index.md index f16e95e83cc2c6..e1e21428c9803e 100644 --- a/files/zh-cn/web/svg/attribute/clip/index.md +++ b/files/zh-cn/web/svg/attribute/clip/index.md @@ -14,20 +14,22 @@ As a presentation attribute, it can be applied to any element but it has effect ## 示例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - + - + @@ -40,9 +42,9 @@ html,body,svg { height:100% } **Warning:** This property is deprecated. Use {{cssxref("clip-path")}} instead. | 可用值 | **auto** \| \ \| inherit | -| ---------- | ------------------------------ | -| 默认值 | Yes | -| Animatable | Yes | +| ---------- | ------------------------------- | +| 默认值 | Yes | +| Animatable | Yes | The value `auto` defines a clipping path along the bounds of the viewport created by the given element. diff --git a/files/zh-cn/web/svg/attribute/color/index.md b/files/zh-cn/web/svg/attribute/color/index.md index b16d41d55cb5f9..3c399ea1ca22c2 100644 --- a/files/zh-cn/web/svg/attribute/color/index.md +++ b/files/zh-cn/web/svg/attribute/color/index.md @@ -13,7 +13,7 @@ slug: Web/SVG/Attribute/color | 类别 | 外观属性 | | -------- | ---------------------------------------------------------------------------- | -| 值 | [\](/zh-CN/SVG/Content_type#Color) \| inherit | +| 值 | [\](/zh-CN/SVG/Content_type#Color) \| inherit | | 规范文档 | [SVG 1.1 (2nd Edition)](http://www.w3.org/TR/SVG11/color.html#ColorProperty) | ## 示例 @@ -22,7 +22,13 @@ slug: Web/SVG/Attribute/color - + ``` diff --git a/files/zh-cn/web/svg/attribute/cx/index.md b/files/zh-cn/web/svg/attribute/cx/index.md index 822497752f405b..16ef1c180c1bc3 100644 --- a/files/zh-cn/web/svg/attribute/cx/index.md +++ b/files/zh-cn/web/svg/attribute/cx/index.md @@ -12,17 +12,21 @@ slug: Web/SVG/Attribute/cx ## 示例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - + - + @@ -35,9 +39,9 @@ html,body,svg { height:100% } 对于 {{SVGElement('circle')}},`cx` 用来定义图形中心的 x 轴坐标。 | 值 | **[\](/zh-CN/docs/Web/SVG/Content_type#Length)** \| **[\](/zh-CN/docs/Web/SVG/Content_type#Percentage)** | -| ------ | -------------------------------------------------------------------------------------------------------------- | -| 默认值 | `0` | -| 可变性 | Yes | +| ------ | ---------------------------------------------------------------------------------------------------------------------------- | +| 默认值 | `0` | +| 可变性 | Yes | 注:起始于 SVG2 `cx`,是一个几何属性,意味着该属性也可以用作圆的 CSS 属性。 @@ -46,9 +50,9 @@ html,body,svg { height:100% } 对于 {{SVGElement('ellipse')}},`cx` 用来定义图形中心的 x 轴坐标。 | 值 | **[\](/zh-CN/docs/Web/SVG/Content_type#Length)** \| **[\](/zh-CN/docs/Web/SVG/Content_type#Percentage)** | -| ------ | -------------------------------------------------------------------------------------------------------------- | -| 默认值 | `0` | -| 可变性 | Yes | +| ------ | ---------------------------------------------------------------------------------------------------------------------------- | +| 默认值 | `0` | +| 可变性 | Yes | **注:** 起始于 SVG2 `cx`,是一个几何属性,意味着该属性也可以用作椭圆的 CSS 属性。 @@ -57,41 +61,63 @@ html,body,svg { height:100% } 对于 {{SVGElement('radialGradient')}}, `cx` 用来定义径向渐变终止圆的 x 轴坐标。 | 值 | **[\](/zh-CN/docs/Web/SVG/Content_type#Length)** | -| ------ | ------------------------------------------------- | -| 默认值 | `50%` | -| 可变性 | Yes | +| ------ | -------------------------------------------------------- | +| 默认值 | `50%` | +| 可变性 | Yes | #### 示例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - - + + - - + + - - + + - - - + + + ``` diff --git a/files/zh-cn/web/svg/attribute/cy/index.md b/files/zh-cn/web/svg/attribute/cy/index.md index c70e6687e682e2..55c89b1a5a292c 100644 --- a/files/zh-cn/web/svg/attribute/cy/index.md +++ b/files/zh-cn/web/svg/attribute/cy/index.md @@ -12,17 +12,21 @@ slug: Web/SVG/Attribute/cy ## 示例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - + - + @@ -35,9 +39,9 @@ html,body,svg { height:100% } 对于 {{SVGElement('circle')}},`cy` 用来定义图形中心的 y 轴坐标。 | 值 | **[\](/zh-CN/docs/Web/SVG/Content_type#Length)** \| **[\](/zh-CN/docs/Web/SVG/Content_type#Percentage)** | -| ------ | -------------------------------------------------------------------------------------------------------------- | -| 默认值 | `0` | -| 可变性 | Yes | +| ------ | ---------------------------------------------------------------------------------------------------------------------------- | +| 默认值 | `0` | +| 可变性 | Yes | **注:**起始于 SVG2,`cy` 是一个几何属性,意味着该属性也可以用作圆的 CSS 属性。 @@ -46,9 +50,9 @@ html,body,svg { height:100% } 对于 {{SVGElement('ellipse')}},`cy` 用来定义图形中心的 y 轴坐标。 | 值 | **[\](/zh-CN/docs/Web/SVG/Content_type#Length)** \| **[\](/zh-CN/docs/Web/SVG/Content_type#Percentage)** | -| ------ | -------------------------------------------------------------------------------------------------------------- | -| 默认值 | `0` | -| 可变性 | Yes | +| ------ | ---------------------------------------------------------------------------------------------------------------------------- | +| 默认值 | `0` | +| 可变性 | Yes | **注:**起始于 SVG2,`cy` 是一个几何属性,意味着该属性也可以用作椭圆的 CSS 属性。 @@ -57,41 +61,63 @@ html,body,svg { height:100% } 对于 {{SVGElement('radialGradient')}},`cy` 用来定义径向渐变终止圆的 y 轴坐标。 | 值 | **[\](/zh-CN/docs/Web/SVG/Content_type#Length)** | -| ------ | ------------------------------------------------- | -| 默认值 | `50%` | -| 可变性 | Yes | +| ------ | -------------------------------------------------------- | +| 默认值 | `50%` | +| 可变性 | Yes | #### 示例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - - + + - - + + - - + + - - - + + + ``` diff --git a/files/zh-cn/web/svg/attribute/d/index.md b/files/zh-cn/web/svg/attribute/d/index.md index 08b84e366c6f4c..a923be4486e0d5 100644 --- a/files/zh-cn/web/svg/attribute/d/index.md +++ b/files/zh-cn/web/svg/attribute/d/index.md @@ -16,12 +16,18 @@ slug: Web/SVG/Attribute/d ## 示例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - - - @@ -397,21 +417,29 @@ _Lineto_ 指令将绘制一条直线段。这个直线段从*当前位置*(_P< #### 示例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - - @@ -433,7 +461,7 @@ html,body,svg { height:100% } - 终点控制点 - : (_Pce_ = {_xce_, _yce_})(控制在终点附近的曲线的曲率) -绘制后,*终点*(_Pn_)将成为下一个命令中的*当前位置*(_Po′_)。 +绘制后,_终点_(_Pn_)将成为下一个命令中的*当前位置*(_Po′_)。 @@ -569,45 +597,60 @@ html,body,svg { height:100% } #### 示例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - - + - - - - + - + - - + + - - - + + + @@ -617,7 +660,7 @@ html,body,svg { height:100% } ### 二次贝塞尔曲线 -*二次*[*贝塞尔曲线*](/zh-CN/docs/Glossary/Bezier_curve)是使用三个点定义的平滑曲线: +*二次[贝塞尔曲线](/zh-CN/docs/Glossary/Bezier_curve)*是使用三个点定义的平滑曲线: - 起始点(当前位置) - : _Po_ = {_xo_, _yo_} @@ -626,7 +669,7 @@ html,body,svg { height:100% } - 控制点 - : _Pc_ = {_xc_, _yc_}(控制曲率) -绘制后,*终点*(_Pn_)将成为下一个命令中的*当前位置*(_Po′_)。 +绘制后,_终点_(_Pn_)将成为下一个命令中的*当前位置*(_Po′_)。
@@ -760,15 +803,23 @@ html,body,svg { height:100% } #### 示例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - - + - @@ -778,23 +829,31 @@ html,body,svg { height:100% } - - + + - + - + - + @@ -907,27 +966,38 @@ html,body,svg { height:100% } #### 示例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - - - - - ``` @@ -960,34 +1030,40 @@ _ClosePath_ 命令将从*当前位置*绘制一条直线到路径中的第一个 #### 示例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - - - - diff --git a/files/zh-cn/web/svg/attribute/display/index.md b/files/zh-cn/web/svg/attribute/display/index.md index 34c339e4fc85c2..c894aadb5827fd 100644 --- a/files/zh-cn/web/svg/attribute/display/index.md +++ b/files/zh-cn/web/svg/attribute/display/index.md @@ -28,7 +28,9 @@ As a presentation attribute, it can be applied to any element. ## 示例 ```css hidden -html, body, svg { +html, +body, +svg { height: 100%; } ``` @@ -41,7 +43,13 @@ html, body, svg { - + ``` @@ -49,10 +57,10 @@ html, body, svg { ## 使用说明 -| Default value | `inline` | -| ------------- | -------------------------------- | +| Default value | `inline` | +| ------------- | ------------------------ | | Value | {{csssyntax("display")}} | -| Animatable | Yes | +| Animatable | Yes | For a description of the values, please refer to the {{cssxref("display", "CSS display")}} property. diff --git a/files/zh-cn/web/svg/attribute/dur/index.md b/files/zh-cn/web/svg/attribute/dur/index.md index b921cd35a0524a..a3c05fe4ae8f3e 100644 --- a/files/zh-cn/web/svg/attribute/dur/index.md +++ b/files/zh-cn/web/svg/attribute/dur/index.md @@ -11,7 +11,7 @@ slug: Web/SVG/Attribute/dur | 类别 | 动画定时属性 | | -------- | --------------------------------------------------------------------------- | -| 值 | [\](/zh-CN/SVG/Content_type#Clock-value) \| **indefinite** | +| 值 | [\](/zh-CN/SVG/Content_type#Clock-value) \| **indefinite** | | 可变性 | No | | 规范文档 | [SVG 1.1 (2nd Edition)](http://www.w3.org/TR/SVG/animate.html#DurAttribute) | diff --git a/files/zh-cn/web/svg/attribute/dx/index.md b/files/zh-cn/web/svg/attribute/dx/index.md index c6d059c6e78c76..f1a83c66fd22f2 100644 --- a/files/zh-cn/web/svg/attribute/dx/index.md +++ b/files/zh-cn/web/svg/attribute/dx/index.md @@ -24,10 +24,10 @@ slug: Web/SVG/Attribute/dx ## 用法上下文 -| 分类 | 无 | -| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| 数值类型 | [\](/zh-CN/SVG/Content_type#Number) \| [T<.2Fvar>s">\](/zh-CN/SVG/Content_type#List-of-T<.2Fvar>s) | -| 可变 | 是 | +| 分类 | 无 | +| -------- | ------------------------------------------------------------------------------------------------------------------------------- | +| 数值类型 | [\](/zh-CN/SVG/Content_type#Number) \| [T<.2Fvar>s">\](/zh-CN/SVG/Content_type#List-of-T<.2Fvar>s) | +| 可变 | 是 | ## 元素 diff --git a/files/zh-cn/web/svg/attribute/end/index.md b/files/zh-cn/web/svg/attribute/end/index.md index 21c6d6b0719b38..39973c740f9ddc 100644 --- a/files/zh-cn/web/svg/attribute/end/index.md +++ b/files/zh-cn/web/svg/attribute/end/index.md @@ -13,7 +13,7 @@ slug: Web/SVG/Attribute/end | 类别 | 动画定时属性 | | -------- | --------------------------------------------------------------------------- | -| 值 | \ | +| 值 | \ | | 可变性 | No | | 规范文档 | [SVG 1.1 (2nd Edition)](http://www.w3.org/TR/SVG/animate.html#EndAttribute) | diff --git a/files/zh-cn/web/svg/attribute/fill-opacity/index.md b/files/zh-cn/web/svg/attribute/fill-opacity/index.md index 42dfc5ea6d3a58..bdec1372375654 100644 --- a/files/zh-cn/web/svg/attribute/fill-opacity/index.md +++ b/files/zh-cn/web/svg/attribute/fill-opacity/index.md @@ -11,7 +11,7 @@ slug: Web/SVG/Attribute/fill-opacity | 类别 | 外观属性 | | -------- | ----------------------------------------------------------------------------------- | -| 值 | [\](/zh-CN/SVG/Content_type#Opacity_value) \| inherit | +| 值 | [\](/zh-CN/SVG/Content_type#Opacity_value) \| inherit | | 初始值 | 1 | | 可变性 | Yes | | 规范文档 | [SVG 1.1 (2nd Edition)](http://www.w3.org/TR/SVG/painting.html#FillOpacityProperty) | diff --git a/files/zh-cn/web/svg/attribute/fill-rule/index.md b/files/zh-cn/web/svg/attribute/fill-rule/index.md index 814e1acb803e38..84facdac874844 100644 --- a/files/zh-cn/web/svg/attribute/fill-rule/index.md +++ b/files/zh-cn/web/svg/attribute/fill-rule/index.md @@ -24,21 +24,29 @@ slug: Web/SVG/Attribute/fill-rule ## 示例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - + - + ``` @@ -62,30 +70,40 @@ html,body,svg { height:100% } #### Example ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - + - + - + ``` @@ -98,30 +116,40 @@ html,body,svg { height:100% } #### Example ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - + - + - + ``` diff --git a/files/zh-cn/web/svg/attribute/fill/index.md b/files/zh-cn/web/svg/attribute/fill/index.md index e17ff051a2865d..47be234349f038 100644 --- a/files/zh-cn/web/svg/attribute/fill/index.md +++ b/files/zh-cn/web/svg/attribute/fill/index.md @@ -30,7 +30,7 @@ slug: Web/SVG/Attribute/fill | 类别 | 外观属性 | | -------- | ---------------------------------------------------------------------------- | -| 值 | [\](/zh-CN/SVG/Content_type#Paint) | +| 值 | [\](/zh-CN/SVG/Content_type#Paint) | | 可变性 | Yes | | 规范文档 | [SVG 1.1 (2nd Edition)](http://www.w3.org/TR/SVG/painting.html#FillProperty) | diff --git a/files/zh-cn/web/svg/attribute/filter/index.md b/files/zh-cn/web/svg/attribute/filter/index.md index fd5d559505c7d5..b169e3d9c89f2b 100644 --- a/files/zh-cn/web/svg/attribute/filter/index.md +++ b/files/zh-cn/web/svg/attribute/filter/index.md @@ -13,7 +13,7 @@ slug: Web/SVG/Attribute/filter | 类别 | 外观属性 | | -------- | ------------------------------------------------------------------------------- | -| 值 | [\](/zh-CN/SVG/Content_type#FuncIRI) \| **none** \| inherit | +| 值 | [\](/zh-CN/SVG/Content_type#FuncIRI) \| **none** \| inherit | | 可变性 | Yes | | 规范文档 | [SVG 1.1 (2nd Edition)](http://www.w3.org/TR/SVG11/filters.html#FilterProperty) | diff --git a/files/zh-cn/web/svg/attribute/font-family/index.md b/files/zh-cn/web/svg/attribute/font-family/index.md index 300167ae5c9111..d27187379ad98b 100644 --- a/files/zh-cn/web/svg/attribute/font-family/index.md +++ b/files/zh-cn/web/svg/attribute/font-family/index.md @@ -11,11 +11,11 @@ slug: Web/SVG/Attribute/font-family ## 使用上下文 -| 分类 | Presentation attribute | -| ----------------- | --------------------------------------------------------------------------------------- | +| 分类 | Presentation attribute | +| ----------------- | ------------------------------------------------------------------------------------------- | | 值 | [[\ \| \],]\* [\ \| \] \| inherit | -| 可动画 Animatable | Yes | -| 规范文档 | [SVG 1.1 (2nd Edition)](http://www.w3.org/TR/SVG11/text.html#FontFamilyProperty) | +| 可动画 Animatable | Yes | +| 规范文档 | [SVG 1.1 (2nd Edition)](http://www.w3.org/TR/SVG11/text.html#FontFamilyProperty) | ## 例子 diff --git a/files/zh-cn/web/svg/attribute/fr/index.md b/files/zh-cn/web/svg/attribute/fr/index.md index 932bae870f3499..41320d70c03f9e 100644 --- a/files/zh-cn/web/svg/attribute/fr/index.md +++ b/files/zh-cn/web/svg/attribute/fr/index.md @@ -11,7 +11,7 @@ slug: Web/SVG/Attribute/fr | 类别 | 无 | | -------- | ---------------------------------------------------------------------------------------------------------------------------- | -| 值 | [\](/zh-CN/docs/Web/SVG/Content_type#Length) | +| 值 | [\](/zh-CN/docs/Web/SVG/Content_type#Length) | | 可变性 | 非 | | 规范文档 | [SVG 1.1 (2nd Edition): The radialGradient element](http://www.w3.org/TR/SVG/pservers.html#RadialGradientElementCXAttribute) | @@ -20,25 +20,47 @@ slug: Web/SVG/Attribute/fr ```html - + - - - - + + + + - - - - - - (fx,fy) - (cx,cy) + + + + + + (fx,fy) + + + (cx,cy) + ``` diff --git a/files/zh-cn/web/svg/attribute/from/index.md b/files/zh-cn/web/svg/attribute/from/index.md index 4ec9a825bcb0cf..3398295bc5568a 100644 --- a/files/zh-cn/web/svg/attribute/from/index.md +++ b/files/zh-cn/web/svg/attribute/from/index.md @@ -11,7 +11,7 @@ slug: Web/SVG/Attribute/From | 类别 | 动画属性值 | | ---------- | ---------------------------------------------------------------------------- | -| 值 | \ | +| 值 | \ | | 动画特征 | No | | 标准化文档 | [SVG 1.1 (2nd Edition)](http://www.w3.org/TR/SVG/animate.html#FromAttribute) | diff --git a/files/zh-cn/web/svg/attribute/fx/index.md b/files/zh-cn/web/svg/attribute/fx/index.md index 22399314975224..8fc004cd8e8521 100644 --- a/files/zh-cn/web/svg/attribute/fx/index.md +++ b/files/zh-cn/web/svg/attribute/fx/index.md @@ -11,7 +11,7 @@ slug: Web/SVG/Attribute/fx | 类别 | 无 | | -------- | ---------------------------------------------------------------------------------------------------------------------------- | -| 值 | [\](/zh-CN/SVG/Content_type#Coordinate) | +| 值 | [\](/zh-CN/SVG/Content_type#Coordinate) | | 可变性 | 非 | | 规范文档 | [SVG 1.1 (2nd Edition): The radialGradient element](http://www.w3.org/TR/SVG/pservers.html#RadialGradientElementCXAttribute) | @@ -20,25 +20,40 @@ slug: Web/SVG/Attribute/fx ```html - + - - - - + + + + - - - - - - (fx,fy) - (cx,cy) + + + + + + (fx,fy) + + + (cx,cy) + ``` diff --git a/files/zh-cn/web/svg/attribute/height/index.md b/files/zh-cn/web/svg/attribute/height/index.md index 269ef49ebf2e11..49549cd5fe5c14 100644 --- a/files/zh-cn/web/svg/attribute/height/index.md +++ b/files/zh-cn/web/svg/attribute/height/index.md @@ -13,11 +13,12 @@ slug: Web/SVG/Attribute/height ```html - - - + + ``` diff --git a/files/zh-cn/web/svg/attribute/id/index.md b/files/zh-cn/web/svg/attribute/id/index.md index 49fd1fb5b9c1c6..b3a2155cc3da01 100644 --- a/files/zh-cn/web/svg/attribute/id/index.md +++ b/files/zh-cn/web/svg/attribute/id/index.md @@ -12,7 +12,11 @@ slug: Web/SVG/Attribute/id ## 示例 ```html - + + + + + + + + + + + + + + ``` diff --git a/files/zh-cn/web/svg/attribute/stroke-dashoffset/index.md b/files/zh-cn/web/svg/attribute/stroke-dashoffset/index.md index 48844f30a52436..adff6abb91af9c 100644 --- a/files/zh-cn/web/svg/attribute/stroke-dashoffset/index.md +++ b/files/zh-cn/web/svg/attribute/stroke-dashoffset/index.md @@ -13,11 +13,11 @@ slug: Web/SVG/Attribute/stroke-dashoffset ## 使用环境 -| 类别 | 显示属性 | -| ------ | ----------------------------------------------------------------------------------------------------- | +| 类别 | 显示属性 | +| ------ | ------------------------------------------------------------------------------------------------------------- | | 值 | [\](/zh-CN/SVG/Content_type#Percentage) \| [\](/zh-CN/SVG/Content_type#Length) \| inherit | -| 初始值 | 1 | -| 可动画 | Yes | +| 初始值 | 1 | +| 可动画 | Yes | ## 示例 diff --git a/files/zh-cn/web/svg/attribute/stroke-linecap/index.md b/files/zh-cn/web/svg/attribute/stroke-linecap/index.md index 974592ccf4a431..5953085e517bf1 100644 --- a/files/zh-cn/web/svg/attribute/stroke-linecap/index.md +++ b/files/zh-cn/web/svg/attribute/stroke-linecap/index.md @@ -20,24 +20,40 @@ slug: Web/SVG/Attribute/stroke-linecap ```html - - - - - - - - - + + + + + + + + ``` diff --git a/files/zh-cn/web/svg/attribute/stroke-linejoin/index.md b/files/zh-cn/web/svg/attribute/stroke-linejoin/index.md index c0b0ea7e691a15..1865bd1f3be5e0 100644 --- a/files/zh-cn/web/svg/attribute/stroke-linejoin/index.md +++ b/files/zh-cn/web/svg/attribute/stroke-linejoin/index.md @@ -23,7 +23,11 @@ slug: Web/SVG/Attribute/stroke-linejoin ## 示例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html @@ -32,49 +36,66 @@ html,body,svg { height:100% } Upper left path: Effect of the "miter" value --> - + - + - + - + - - + - - - + + + @@ -102,22 +123,32 @@ html,body,svg { height:100% } #### 示例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - + - + @@ -134,22 +165,28 @@ The `bevel` 用斜角连接路径段。 #### 示例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - + - + @@ -168,23 +205,37 @@ The `miter` 用尖角连接路径段。通过在路径段的切线处延伸笔 #### 示例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - + - + - + @@ -193,10 +244,14 @@ html,body,svg { height:100% } - - + + - + ``` @@ -214,22 +269,36 @@ The `miter-clip` 用尖角连接路径段。通过在路径段的切线处延伸 #### 示例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - + - + - + @@ -238,10 +307,14 @@ html,body,svg { height:100% } - - + + - + ``` @@ -255,22 +328,28 @@ html,body,svg { height:100% } #### 示例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - + - + diff --git a/files/zh-cn/web/svg/attribute/stroke-miterlimit/index.md b/files/zh-cn/web/svg/attribute/stroke-miterlimit/index.md index d6c33c713773a3..14121463e4c459 100644 --- a/files/zh-cn/web/svg/attribute/stroke-miterlimit/index.md +++ b/files/zh-cn/web/svg/attribute/stroke-miterlimit/index.md @@ -17,11 +17,11 @@ miterLength / stroke-width = 1 / sin ( theta / 2 ) ## 用法 -| 类别 | 外观属性 | -| ------ | ----------------------- | +| 类别 | 外观属性 | +| ------ | ------------------------ | | 值 | \ \| inherit | -| 初始值 | 4 | -| 可动性 | Yes | +| 初始值 | 4 | +| 可动性 | Yes | - \ - : 对斜角长度与{{ SVGAttr("stroke-width") }}的比率的限制。\的值必须是一个大于或等于 1 的[\](/zh-CN/SVG/Content_type#Number)。 diff --git a/files/zh-cn/web/svg/attribute/stroke-opacity/index.md b/files/zh-cn/web/svg/attribute/stroke-opacity/index.md index b52a535b40703a..55e6f220d240df 100644 --- a/files/zh-cn/web/svg/attribute/stroke-opacity/index.md +++ b/files/zh-cn/web/svg/attribute/stroke-opacity/index.md @@ -11,10 +11,10 @@ slug: Web/SVG/Attribute/stroke-opacity ## 用法 -| 类别 | 外观属性 | -| ------ | -------------------------- | +| 类别 | 外观属性 | +| ------ | --------------------------- | | 值 | \ \| inherit | -| 可变性 | Yes | +| 可变性 | Yes | - \ - : 在当前对象的轮廓上用该涂色操作的不透明度。任何超出 0.0 到 1.0 范围的值都会被压回这个范围(0.0 表示完全透明,1.0 表示完全不透明)。 @@ -25,18 +25,18 @@ slug: Web/SVG/Attribute/stroke-opacity ```html - + ``` ### CSS ```css -rect{ - fill:#b4da55; - stroke:#000; - stroke-width:10px; - stroke-opacity:0.3; +rect { + fill: #b4da55; + stroke: #000; + stroke-width: 10px; + stroke-opacity: 0.3; } ``` diff --git a/files/zh-cn/web/svg/attribute/stroke-width/index.md b/files/zh-cn/web/svg/attribute/stroke-width/index.md index dc4e26c5e9b08d..81999bc29fa8f8 100644 --- a/files/zh-cn/web/svg/attribute/stroke-width/index.md +++ b/files/zh-cn/web/svg/attribute/stroke-width/index.md @@ -11,10 +11,10 @@ slug: Web/SVG/Attribute/stroke-width ## 用法 -| 类别 | 外观属性 | -| ------ | ----------------------------------------------------------------------------------------------------- | +| 类别 | 外观属性 | +| ------ | ------------------------------------------------------------------------------------------------------------- | | 值 | [\](/zh-CN/SVG/Content_type#Length) \| [\](/zh-CN/SVG/Content_type#Percentage) \| inherit | -| 可变性 | Yes | +| 可变性 | Yes | ## 示例 diff --git a/files/zh-cn/web/svg/attribute/stroke/index.md b/files/zh-cn/web/svg/attribute/stroke/index.md index b693f429dbef9e..8631dfa7157902 100644 --- a/files/zh-cn/web/svg/attribute/stroke/index.md +++ b/files/zh-cn/web/svg/attribute/stroke/index.md @@ -9,10 +9,10 @@ slug: Web/SVG/Attribute/stroke ## 用法 -| 类别 | 外观属性 | -| ------ | ------------------------------------- | +| 类别 | 外观属性 | +| ------ | ----------------------------------------- | | 值 | [\](/zh-CN/SVG/Content_type#Paint) | -| 可变性 | 是 | +| 可变性 | 是 | ## 示例 @@ -21,8 +21,8 @@ slug: Web/SVG/Attribute/stroke ### 示例 1:用 stroke 属性画一条绿色的直线。 ```html - - + + ``` @@ -30,7 +30,7 @@ slug: Web/SVG/Attribute/stroke ```html - + ``` diff --git a/files/zh-cn/web/svg/attribute/style/index.md b/files/zh-cn/web/svg/attribute/style/index.md index 7683eb7c6343c6..a79e7a90558f97 100644 --- a/files/zh-cn/web/svg/attribute/style/index.md +++ b/files/zh-cn/web/svg/attribute/style/index.md @@ -23,8 +23,12 @@ slug: Web/SVG/Attribute/style ```html - + ``` diff --git a/files/zh-cn/web/svg/attribute/target/index.md b/files/zh-cn/web/svg/attribute/target/index.md index be375a38d545c8..4ceb4f8665dba6 100644 --- a/files/zh-cn/web/svg/attribute/target/index.md +++ b/files/zh-cn/web/svg/attribute/target/index.md @@ -12,14 +12,19 @@ slug: Web/SVG/Attribute/target ## 示例 ```css hidden -html, body, svg { - height: 100%; +html, +body, +svg { + height: 100%; } text { - font: 20px Arial, Helvetica, sans-serif; - fill: blue; - text-decoration: underline; + font: + 20px Arial, + Helvetica, + sans-serif; + fill: blue; + text-decoration: underline; } ``` @@ -27,13 +32,13 @@ text { 在 iframe 中打开链接 - + 在新标签页或窗口中打开链接 - + 在此标签或窗口中打开链接 - + ``` @@ -47,6 +52,7 @@ text { | 可动画的 | 是 | - `_replace` {{deprecated_inline}} + - : 当前 SVG 图像被与当前 SVG 图像在同一帧中相同矩形区域中的链接内容替换。 > **备注:** 这个值是从来没有很好的执行,之间的区别 `_replace`,并 `_self` 已通过在浏览上下文的 HTML 定义的变化变得多余。使用 `_self` 以取代目前的 SVG 文件。 @@ -58,9 +64,9 @@ text { - `_top` - : 完整活动窗口或选项卡的内容将由链接的内容替换(如果存在),并且可以从此文档中安全地访问 - `_blank` - - : 如果此文档可以安全地显示,则需要一个新的未命名窗口或标签来显示链接的内容。如果用户代理不支持多个窗口/选项卡,则结果与_top 相同。 + - : 如果此文档可以安全地显示,则需要一个新的未命名窗口或标签来显示链接的内容。如果用户代理不支持多个窗口/选项卡,则结果与\_top 相同。 - `` - - : 指定用于显示链接内容的浏览上下文的名称(选项卡,内联框架,对象等)。如果具有该名称的上下文已经存在,并且可以从此文档中安全地访问,则可以重新使用该上下文,替换现有内容。如果不存在,则创建它(与'_blank'相同,但现在有了一个名称)。该名称必须是有效的 XML 名称 \[XML11],并且不能以下划线(U + 005F LOW LINE 字符)开头,以满足来自 HTML 的有效浏览上下文名称的要求。 + - : 指定用于显示链接内容的浏览上下文的名称(选项卡,内联框架,对象等)。如果具有该名称的上下文已经存在,并且可以从此文档中安全地访问,则可以重新使用该上下文,替换现有内容。如果不存在,则创建它(与'\_blank'相同,但现在有了一个名称)。该名称必须是有效的 XML 名称 \[XML11],并且不能以下划线(U + 005F LOW LINE 字符)开头,以满足来自 HTML 的有效浏览上下文名称的要求。 ## 规范 diff --git a/files/zh-cn/web/svg/attribute/text-anchor/index.md b/files/zh-cn/web/svg/attribute/text-anchor/index.md index 0466f5d0dca633..ab244bcd9cf8ce 100644 --- a/files/zh-cn/web/svg/attribute/text-anchor/index.md +++ b/files/zh-cn/web/svg/attribute/text-anchor/index.md @@ -29,33 +29,36 @@ slug: Web/SVG/Attribute/text-anchor ```html - - - - - - - - A - - A - - A - - - - - - - + + + + + + A + + A + + A + + + + + + + ``` diff --git a/files/zh-cn/web/svg/attribute/transform/index.md b/files/zh-cn/web/svg/attribute/transform/index.md index f1e63831a28f50..9fac2a8efcaeb7 100644 --- a/files/zh-cn/web/svg/attribute/transform/index.md +++ b/files/zh-cn/web/svg/attribute/transform/index.md @@ -10,20 +10,30 @@ slug: Web/SVG/Attribute/transform ## 示例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - - + - + - + ``` @@ -36,9 +46,9 @@ html,body,svg { height:100% } 另外,作为 SVG 1.1 的遗留物,{{SVGElement('linearGradient')}}和{{SVGElement('radialGradient')}}支持 `gradientTransform` 属性,而{{SVGElement('pattern')}}支持 `patternTransform` 属性,两者的行为完全相同于 `transform` 属性 | Value | **[\](/zh-CN/docs/Web/SVG/Content_type#Transform-list)** | -| ------------- | ----------------------------------------------------------------- | -| Default value | _none_ | -| Animatable | Yes | +| ------------- | ------------------------------------------------------------------------ | +| Default value | _none_ | +| Animatable | Yes | ## Transform functions @@ -53,7 +63,11 @@ html,body,svg { height:100% } #### 举例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html @@ -84,8 +98,13 @@ html,body,svg { height:100% } newX = a * oldX + c * oldY + e = 3 * 40 - 1 * 30 + 30 = 120 newY = b * oldX + d * oldY + f = 1 * 40 + 3 * 30 + 40 = 170 --> - + ``` @@ -98,7 +117,11 @@ html,body,svg { height:100% } #### 举例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html @@ -107,16 +130,31 @@ html,body,svg { height:100% } - + - + - + ``` @@ -129,22 +167,23 @@ html,body,svg { height:100% } #### 举例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - + - + - + @@ -160,7 +199,11 @@ html,body,svg { height:100% } #### 举例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html @@ -168,12 +211,16 @@ html,body,svg { height:100% } - + - + ``` @@ -186,15 +233,18 @@ html,body,svg { height:100% } #### 举例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - + ``` @@ -207,15 +257,18 @@ html,body,svg { height:100% } #### 举例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - + ``` diff --git a/files/zh-cn/web/svg/attribute/type/index.md b/files/zh-cn/web/svg/attribute/type/index.md index 153051db94350e..7d6a4f1022e884 100644 --- a/files/zh-cn/web/svg/attribute/type/index.md +++ b/files/zh-cn/web/svg/attribute/type/index.md @@ -51,7 +51,7 @@ type 属性是一个类属性,他在不同的使用语境下有不同的意思 | Categories | _None_ | | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| Value | \ | +| Value | \ | | Animatable | No | | Normative document | [SVG 1.1 (2nd Edition) : script](http://www.w3.org/TR/SVG11/script.html#ScriptElementTypeAttribute) [SVG 1.1 (2nd Edition) : style](http://www.w3.org/TR/SVG11/styling.html#StyleElementTypeAttribute) | diff --git a/files/zh-cn/web/svg/attribute/values/index.md b/files/zh-cn/web/svg/attribute/values/index.md index 9020e9cf9c868c..81ad40c3779aac 100644 --- a/files/zh-cn/web/svg/attribute/values/index.md +++ b/files/zh-cn/web/svg/attribute/values/index.md @@ -31,6 +31,7 @@ values 属性具有不同的含义,具体取决于使用的上下文,它可 | Animatable | Yes | - `` + - : 该值是一个数字列表,根据 type 属性的值来定义不同解释: - `type="matrix"`,`values` 是 20 个矩阵值(a00 a01 a02 a03 a04 a10 a11 ... a34)的列表,以空格和/或逗号分隔。 diff --git a/files/zh-cn/web/svg/attribute/vector-effect/index.md b/files/zh-cn/web/svg/attribute/vector-effect/index.md index 5a4055d436234a..9b54b9a34c8fad 100644 --- a/files/zh-cn/web/svg/attribute/vector-effect/index.md +++ b/files/zh-cn/web/svg/attribute/vector-effect/index.md @@ -36,15 +36,28 @@ slug: Web/SVG/Attribute/vector-effect ```html - + - + - + ``` diff --git a/files/zh-cn/web/svg/attribute/version/index.md b/files/zh-cn/web/svg/attribute/version/index.md index 017c00add646d1..f6e63aa7f045cf 100644 --- a/files/zh-cn/web/svg/attribute/version/index.md +++ b/files/zh-cn/web/svg/attribute/version/index.md @@ -11,10 +11,10 @@ slug: Web/SVG/Attribute/version ## Usage context -| 类别 | None | -| -------- | --------------------------------------- | +| 类别 | None | +| -------- | ------------------------------------------- | | 值 | [\](/zh-CN/SVG/Content_type#Number) | -| 动画属性 | No | +| 动画属性 | No | ## 规范 diff --git a/files/zh-cn/web/svg/attribute/y/index.md b/files/zh-cn/web/svg/attribute/y/index.md index be029cbc51124d..46de0be3f04c39 100644 --- a/files/zh-cn/web/svg/attribute/y/index.md +++ b/files/zh-cn/web/svg/attribute/y/index.md @@ -1,5 +1,5 @@ --- -title: 'y' +title: "y" slug: Web/SVG/Attribute/y --- diff --git a/files/zh-cn/web/svg/content_type/index.md b/files/zh-cn/web/svg/content_type/index.md index e426f4d4a76d5e..d3f7ff486f04ea 100644 --- a/files/zh-cn/web/svg/content_type/index.md +++ b/files/zh-cn/web/svg/content_type/index.md @@ -10,6 +10,7 @@ SVG 中使用了许多数据类型。本文列出了这些数据类型以及它 ## 角度 - \ + - : 可以用两种办法指定角度。如果用在样式表的属性的值中,`` 可以用如下方法定义:`plain angle ::= number (~"deg" | ~"grad" | ~"rad")?` 在这里 deg 标识了度数,grad 标识了斜率,rad 标识了弧度。对于定义在 CSS2 中的属性,必须提供一个角度单位标识符。对于在 SVG 特有的属性和它们对应的外观属性中的角度值,角度单位标识符是可选的。如果没有提供,角度值会被潜在分配一个度数单位。在所有元素的外观属性中,无论是在 SVG1.1 中定义的,还是在 CSS2 中定义的,如果指定了角度标识符,角度标识符必须是小写的。如果角度用在一个 SVG 属性中,``可以用以下方式定义: ```plain @@ -21,6 +22,7 @@ SVG 中使用了许多数据类型。本文列出了这些数据类型以及它 ## 任意值 - \ + - : 基本类型 \ 是一个零字符或多字符的序列。具体如下: ```plain @@ -32,6 +34,7 @@ SVG 中使用了许多数据类型。本文列出了这些数据类型以及它 ## 时钟值 - \ + - : 时钟值的句法与 [SMIL Animation](https://www.w3.org/TR/2001/REC-smil-animation-20010904/) 规范中写的句法相同。在这里重放一下时钟值的语法: ``` @@ -52,14 +55,17 @@ SVG 中使用了许多数据类型。本文列出了这些数据类型以及它 对于 `Timecount` 值,默认的公制前缀是“s”(秒)。在时钟值中不能嵌入空白,而且前导和末尾的空白字符会被忽略掉。下面是合法的时钟值的示例: - 完整时钟值: + - `02:30:03` >= 2 小时 30 分钟又 3 秒 - `50:00:10.25` = 50 小时 10 秒又 250 毫秒 - 部分时钟值: + - `02:33` >= 2 分钟又 33 秒 - `00:10.5` = 10.5 秒 = 10 秒又 500 毫秒 - Timecount 值: + - `3.2h` >= 3.2 小时 = 3 小时 12 分钟 - `45min` >= 45 分钟 - `30s` >= 30 秒 @@ -73,6 +79,7 @@ SVG 中使用了许多数据类型。本文列出了这些数据类型以及它 ## 颜色 - \ + - : 基本类型\是一个 CSS2 兼容的规范,针对 sRGB 颜色空间的颜色。\ 应用在 SVG 的属性 {{SVGAttr("color")}} 上,也是属性{{SVGAttr("fill")}}、属性{{SVGAttr("stroke")}}、属性{{SVGAttr("stop-color")}}、属性 {{SVGAttr("flood-color")}}和属性{{SVGAttr("lighting-color")}}的定义的组成部分,\ 还提供了可选的基于 ICC 的颜色规范。 SVG 支持所有的定义在[CSS2 句法和基本数据类型](http://www.w3.org/TR/2008/REC-CSS2-20080411/syndata.html#value-def-color)中的 \ 供选择的句法,而且还支持[CSS Color Module Level 3](http://www.w3.org/TR/css3-color/)中的 \ 句法(取决于编译器)。 @@ -99,6 +106,7 @@ SVG 中使用了许多数据类型。本文列出了这些数据类型以及它 ## 频率 - \ + - : 频率值用在可听到的属性上。就如 CSS2 中所定义的,一个频率值是一个 [\](/zh-CN/docs/SVG/Content_type#Number) 后面跟着一个频率单位标识符。频率单位标识符可以是: - `Hz`:赫兹 @@ -114,6 +122,7 @@ SVG 中使用了许多数据类型。本文列出了这些数据类型以及它 ## ICC 颜色 - \ + - : \ 一份 ICC 颜色规范。在 SVG 1.1,一份 ICC 颜色规范,顾名思义,是一个参考了一个{{SVGElement("color-profile")}} 元素,以及一个或更多颜色成分值。语法如下所示: ```plain @@ -125,6 +134,7 @@ SVG 中使用了许多数据类型。本文列出了这些数据类型以及它 ## 整型数 - \ + - : 用一个可选的正负符号(“+”或“-”)后面跟着一个或多个 0 到 9 的数字可以指定一个\: ```plain @@ -136,6 +146,7 @@ SVG 中使用了许多数据类型。本文列出了这些数据类型以及它 ## IRI - \ + - : 一个国际化资源标识符。在因特网上,资源是用 _IRI_(一个国际化资源标识符)标识的。举个例子,一个 SVG 文档调用了位于 `http://example.com` 上的 `someDrawing.svg`,可以使用下面的 _IRI_: ``` @@ -159,7 +170,7 @@ SVG 中使用了许多数据类型。本文列出了这些数据类型以及它 然后你再引用这个线性渐变,作为矩形的属性 {{SVGAttr("fill")}} 的值,如下: ```html - + ``` SVG 支持两种类型的 _IRI_ 引用: @@ -172,6 +183,7 @@ SVG 中使用了许多数据类型。本文列出了这些数据类型以及它 ## 长度 - \ + - : 一个长度是一个可度量的距离,给定一个数字以及一个单位。长度可以用两种方法指定。如果在样式表中使用它,可以如下定义\: ``` @@ -200,17 +212,19 @@ SVG 中使用了许多数据类型。本文列出了这些数据类型以及它 ## T 值数列 - \ + - : (在这里*T* 某些类型。)由一系列分开的值构成的数列。除非另有说明,SVG 的 XML 属性内的数列既可以是逗号分隔的,也可以是空格分隔的。用逗号作分隔符,逗号前面或后面可有带空格。数列中的空白被定义为一个或多个下列连续字符:“空格”(U+0020)、“制表符”(U+0009)、 “换行符”(U+000A)、 “回车符”(U+000D)以及“换页符”(U+000C)。下面是一个 EBNF 语法的模板,用来描述\句法: ```plain list-of-Ts ::= T | T, list-of-Ts ``` - 在 SVG DOM 内部,\类型的值可以用一个限特定类型 _T_ 的接口来表达。举个例子,SVG DOM 中的\使用一个 {{domxref("SVGLengthList")}} 对象或者 {{domxref("SVGAnimatedLengthList")}} 对象来表达。 + 在 SVG DOM 内部,\类型的值可以用一个限特定类型 \_T_ 的接口来表达。举个例子,SVG DOM 中的\使用一个 {{domxref("SVGLengthList")}} 对象或者 {{domxref("SVGAnimatedLengthList")}} 对象来表达。 ## 命名 - \ + - : 一个命名,是一个字符串,是不符合句法意义的少量的字符。 ```plain @@ -220,6 +234,7 @@ SVG 中使用了许多数据类型。本文列出了这些数据类型以及它 ## 数字 - \ + - : 真实数字可以用两种方法指定。如果用在样式表中,一个 \ 可以如下定义:`plain number ::= integer | [+-]? [0-9]* "." [0-9]+` 该句法与 CSS(CSS2 第 4.3.1 章节)中的定义一样。如果用在一个 SVG 属性中,一个 \ 可以用别的方法定义,允许一个数字后面跟着大数指数,以指定得更精确: ```plain @@ -231,6 +246,7 @@ SVG 中使用了许多数据类型。本文列出了这些数据类型以及它 ## 带可取舍的后缀数字的数字 - \ + - : 一对\,其中第二个 \ 是可视情况取舍的。 ```plain @@ -252,6 +268,7 @@ SVG 中使用了许多数据类型。本文列出了这些数据类型以及它 ## 百分数 - \ + - : 一个数字后面跟着一个百分号“%”就可以指定一个百分数。 ```plain @@ -263,6 +280,7 @@ SVG 中使用了许多数据类型。本文列出了这些数据类型以及它 ## 时间 - \
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. - Sed mollis mollis mi ut ultricies. Nullam magna ipsum, - porta vel dui convallis, rutrum imperdiet eros. Aliquam - erat volutpat. + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed mollis mollis + mi ut ultricies. Nullam magna ipsum, porta vel dui convallis, rutrum + imperdiet eros. Aliquam erat volutpat.
diff --git a/files/zh-cn/web/svg/element/g/index.md b/files/zh-cn/web/svg/element/g/index.md index 204ee36855a92e..00550aa633711d 100644 --- a/files/zh-cn/web/svg/element/g/index.md +++ b/files/zh-cn/web/svg/element/g/index.md @@ -14,8 +14,11 @@ slug: Web/SVG/Element/g ## 示例 ```html - + diff --git a/files/zh-cn/web/svg/element/image/index.md b/files/zh-cn/web/svg/element/image/index.md index e261ff6380da9f..c563a26b2ab7b4 100644 --- a/files/zh-cn/web/svg/element/image/index.md +++ b/files/zh-cn/web/svg/element/image/index.md @@ -49,10 +49,18 @@ SVG 文件是这样的一种图像:不被当做外部资源加载,不可以 在 SVG 对象中基本呈现 PNG 图像: ```html - - + + ``` diff --git a/files/zh-cn/web/svg/element/lineargradient/index.md b/files/zh-cn/web/svg/element/lineargradient/index.md index 714f1c51f9dd19..d3aa3ac847e406 100644 --- a/files/zh-cn/web/svg/element/lineargradient/index.md +++ b/files/zh-cn/web/svg/element/lineargradient/index.md @@ -14,15 +14,21 @@ slug: Web/SVG/Element/linearGradient ## 示例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html - + - + diff --git a/files/zh-cn/web/svg/element/marker/index.md b/files/zh-cn/web/svg/element/marker/index.md index c16295c227d74a..8ca23f80e804e7 100644 --- a/files/zh-cn/web/svg/element/marker/index.md +++ b/files/zh-cn/web/svg/element/marker/index.md @@ -164,24 +164,24 @@ svg { ## 属性 - {{SVGAttr("markerHeight")}} - - : 该属性定义了 marker 视口的高度。*值的类型*:**[\](/zh-CN/docs/Web/SVG/Content_type#长度)**;*默认值*:`3`;*动画性*:**有** + - : 该属性定义了 marker 视口的高度。_值的类型_:**[\](/zh-CN/docs/Web/SVG/Content_type#长度)**;_默认值_:`3`;_动画性_:**有** - {{SVGAttr("markerUnits")}} - - : 该属性为 `markerWidth`、`markerHeight` 和 `` 的内容定义了坐标系。*值的类型*:`userSpaceOnUse`|`strokeWidth` ;*默认值*:`strokeWidth`;*动画性*:**有** + - : 该属性为 `markerWidth`、`markerHeight` 和 `` 的内容定义了坐标系。_值的类型_:`userSpaceOnUse`|`strokeWidth` ;_默认值_:`strokeWidth`;_动画性_:**有** - {{SVGAttr("markerWidth")}} - - : 该属性定义了 marker 视图的宽度。*值的类型*:**[\](/zh-CN/docs/Web/SVG/Content_type#长度)** ;*默认值*:`3`;*动画性*:**有** + - : 该属性定义了 marker 视图的宽度。_值的类型_:**[\](/zh-CN/docs/Web/SVG/Content_type#长度)** ;_默认值_:`3`;_动画性_:**有** - {{SVGAttr("orient")}} - - : 该属性定义了 marker 相对于它所附着到形状的方向。*值的类型*:`auto`|`auto-start-reverse`|**[\](/zh-CN/docs/Web/SVG/Content_type#角度)** ;*默认值*:`0`;*动画性*:**有** + - : 该属性定义了 marker 相对于它所附着到形状的方向。_值的类型_:`auto`|`auto-start-reverse`|**[\](/zh-CN/docs/Web/SVG/Content_type#角度)** ;_默认值_:`0`;_动画性_:**有** - {{SVGAttr("preserveAspectRatio")}} - - : 该属性定义了 svg 片段在嵌入具有不同宽高比例的容器中应该如何变形。*值的类型*:(`none`| `xMinYMin`| `xMidYMin`| `xMaxYMin`| `xMinYMid`| `xMidYMid`| `xMaxYMid`| `xMinYMax`| `xMidYMax`| `xMaxYMax`) (`meet`|`slice`)? ;*默认值*:`xMidYMid meet`;*动画性*:**有** + - : 该属性定义了 svg 片段在嵌入具有不同宽高比例的容器中应该如何变形。_值的类型_:(`none`| `xMinYMin`| `xMidYMin`| `xMaxYMin`| `xMinYMid`| `xMidYMid`| `xMaxYMid`| `xMinYMax`| `xMidYMax`| `xMaxYMax`) (`meet`|`slice`)? ;_默认值_:`xMidYMid meet`;_动画性_:**有** - {{SVGAttr("refX")}} - : 该属性定义了标记参考点的 x 的坐标。 - *值的类型*:`left`|`center`|`right`|**[\](/zh-CN/docs/Web/SVG/Content_type#坐标)** ;*默认值*:`0`;*动画性*:**有** + _值的类型_:`left`|`center`|`right`|**[\](/zh-CN/docs/Web/SVG/Content_type#坐标)** ;_默认值_:`0`;_动画性_:**有** - {{SVGAttr("refY")}} - : 该属性定义了标记参考点的 y 的坐标。 - *值的类型*:`top`|`center`|`bottom`|**[\](/zh-CN/docs/Web/SVG/Content_type#坐标)** ;*默认值*:`0`;*动画性*:**有** + _值的类型_:`top`|`center`|`bottom`|**[\](/zh-CN/docs/Web/SVG/Content_type#坐标)** ;_默认值_:`0`;_动画性_:**有** - {{SVGAttr("viewBox")}} - : 该属性定义了当前 SVG 片段的 SVG 视口边界。 - *值的类型*:**[\](/zh-CN/docs/Web/SVG/Content_type#t值数列)** ;*默认值*:none;*动画性*:**有** + _值的类型_:**[\](/zh-CN/docs/Web/SVG/Content_type#t值数列)** ;_默认值_:none;_动画性_:**有** ### 全局属性 diff --git a/files/zh-cn/web/svg/element/mpath/index.md b/files/zh-cn/web/svg/element/mpath/index.md index 373c6d2dd93b30..12a784c2d8edb7 100644 --- a/files/zh-cn/web/svg/element/mpath/index.md +++ b/files/zh-cn/web/svg/element/mpath/index.md @@ -14,29 +14,44 @@ slug: Web/SVG/Element/mpath ## 示例 ```html - - - + + - - - - + + + + - + - - + + diff --git a/files/zh-cn/web/svg/element/path/index.md b/files/zh-cn/web/svg/element/path/index.md index 7db306653f19de..25dfe7e497626c 100644 --- a/files/zh-cn/web/svg/element/path/index.md +++ b/files/zh-cn/web/svg/element/path/index.md @@ -17,7 +17,11 @@ path 元素是用来定义形状的通用元素。所有的基本形状都可以 ## 示例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html diff --git a/files/zh-cn/web/svg/element/radialgradient/index.md b/files/zh-cn/web/svg/element/radialgradient/index.md index 1d69420bfd07ca..80e792e8b683e0 100644 --- a/files/zh-cn/web/svg/element/radialgradient/index.md +++ b/files/zh-cn/web/svg/element/radialgradient/index.md @@ -41,27 +41,27 @@ svg { ## 属性 - {{SVGAttr("cx")}} - - : 这个属性定义了径向渐变的终点圆的 X 坐标。*值类型*:[**\**](/zh-CN/docs/Web/SVG/Content_type#长度);*默认值*:`50%`;*动画性*:**有** + - : 这个属性定义了径向渐变的终点圆的 X 坐标。_值类型_:[**\**](/zh-CN/docs/Web/SVG/Content_type#长度);_默认值_:`50%`;_动画性_:**有** - {{SVGAttr("cy")}} - - : 这个属性定义了径向渐变的终点圆的 Y 坐标。*值类型*:[**\**](/zh-CN/docs/Web/SVG/Content_type#长度);*默认值*:`50%`;*动画性*:**有** + - : 这个属性定义了径向渐变的终点圆的 Y 坐标。_值类型_:[**\**](/zh-CN/docs/Web/SVG/Content_type#长度);_默认值_:`50%`;_动画性_:**有** - {{SVGAttr("fr")}} - - : 这个属性定义了径向梯度的起点圆的半径。渐变的绘制将使 0% {{SVGElement('stop','gradient stop')}} 被映射到起始圆的周长。*值类型*:[**\**](/zh-CN/docs/Web/SVG/Content_type#长度);*默认值*:`0%`;*动画性*:**有** + - : 这个属性定义了径向梯度的起点圆的半径。渐变的绘制将使 0% {{SVGElement('stop','gradient stop')}} 被映射到起始圆的周长。_值类型_:[**\**](/zh-CN/docs/Web/SVG/Content_type#长度);_默认值_:`0%`;_动画性_:**有** - {{SVGAttr("fx")}} - - : 这个属性定义了径向渐变的起点圆的 X 坐标。*值类型*:[**\**](/zh-CN/docs/Web/SVG/Content_type#长度);*默认值*:与 `cx` 相同;*动画性*:**有** + - : 这个属性定义了径向渐变的起点圆的 X 坐标。_值类型_:[**\**](/zh-CN/docs/Web/SVG/Content_type#长度);_默认值_:与 `cx` 相同;_动画性_:**有** - {{SVGAttr("fy")}} - - : 这个属性定义了径向渐变的起点圆的 Y 坐标。*值类型*:[**\**](/zh-CN/docs/Web/SVG/Content_type#长度);*默认值*:与 `cy` 相同;*动画性*:**有** + - : 这个属性定义了径向渐变的起点圆的 Y 坐标。_值类型_:[**\**](/zh-CN/docs/Web/SVG/Content_type#长度);_默认值_:与 `cy` 相同;_动画性_:**有** - {{SVGAttr("gradientUnits")}} - - : 这个属性定义了 `cx`、`cy`、`r`、`fx`、`fy`、`fr` 属性的坐标系统;*值类型*:`userSpaceOnUse`|`objectBoundingBox`;*默认值*:`objectBoundingBox`;*动画性*:**有** + - : 这个属性定义了 `cx`、`cy`、`r`、`fx`、`fy`、`fr` 属性的坐标系统;_值类型_:`userSpaceOnUse`|`objectBoundingBox`;_默认值_:`objectBoundingBox`;_动画性_:**有** - {{SVGAttr("gradientTransform")}} - - : 这个属性为梯度坐标系提供了额外的[变换](/zh-CN/docs/Web/SVG/Atribute/transform)。*值类型*:**[\](/zh-CN/docs/Web/SVG/Content_type#transform-list)** ;*默认值*:*identity transform*;*动画性*:**有** + - : 这个属性为梯度坐标系提供了额外的[变换](/zh-CN/docs/Web/SVG/Atribute/transform)。_值类型_:**[\](/zh-CN/docs/Web/SVG/Content_type#transform-list)** ;_默认值_:_identity transform_;_动画性_:**有** - {{SVGAttr("href")}} - - : 这个属性定义了对另一个将被用作模板 `` 元素的引用。*值类型*:[**\**](/zh-CN/docs/Web/SVG/Content_type#url);*默认值*:none;*动画性*:**有** + - : 这个属性定义了对另一个将被用作模板 `` 元素的引用。_值类型_:[**\**](/zh-CN/docs/Web/SVG/Content_type#url);_默认值_:none;_动画性_:**有** - {{SVGAttr("r")}} - - : 这个属性定义了径向渐变的终点圆的半径。梯度的绘制将使 100% 的{{SVGElement('stop','gradient stop')}} 被映射到终点圆的周长。*值类型*:[**\**](/zh-CN/docs/Web/SVG/Content_type#长度);*默认值*:`50%`;*动画性*:**有** + - : 这个属性定义了径向渐变的终点圆的半径。梯度的绘制将使 100% 的{{SVGElement('stop','gradient stop')}} 被映射到终点圆的周长。_值类型_:[**\**](/zh-CN/docs/Web/SVG/Content_type#长度);_默认值_:`50%`;_动画性_:**有** - {{SVGAttr("spreadMethod")}} - - : 这个属性表明,如果渐变在包含渐变的形状的边界内开始或结束,它将如何表现。*值类型*:`pad`|`reflect`|`repeat`;*默认值*:`pad`;*动画性*:**有** + - : 这个属性表明,如果渐变在包含渐变的形状的边界内开始或结束,它将如何表现。_值类型_:`pad`|`reflect`|`repeat`;_默认值_:`pad`;_动画性_:**有** - {{SVGAttr("xlink:href")}} - - : {{Deprecated_Header}}对另一个将被用作模板的 `` 元素的 [\](/zh-CN/docs/Web/SVG/Content_type#iri) 引用。*值类型*:[**\**](/zh-CN/docs/Web/SVG/Content_type#iri);*默认值*:none;*动画性*:**有** + - : {{Deprecated_Header}}对另一个将被用作模板的 `` 元素的 [\](/zh-CN/docs/Web/SVG/Content_type#iri) 引用。_值类型_:[**\**](/zh-CN/docs/Web/SVG/Content_type#iri);_默认值_:none;_动画性_:**有** ### 全局属性 diff --git a/files/zh-cn/web/svg/element/rect/index.md b/files/zh-cn/web/svg/element/rect/index.md index 6be358f804dbbd..a3793a8d075945 100644 --- a/files/zh-cn/web/svg/element/rect/index.md +++ b/files/zh-cn/web/svg/element/rect/index.md @@ -14,7 +14,11 @@ slug: Web/SVG/Element/rect ## 示例 ```css hidden -html,body,svg { height:100% } +html, +body, +svg { + height: 100%; +} ``` ```html diff --git a/files/zh-cn/web/svg/element/script/index.md b/files/zh-cn/web/svg/element/script/index.md index 51cdbc96df892c..9b4660b91a12e0 100644 --- a/files/zh-cn/web/svg/element/script/index.md +++ b/files/zh-cn/web/svg/element/script/index.md @@ -16,8 +16,11 @@ slug: Web/SVG/Element/script 下面的代码片段演示了 SVG `script`标签的作用。在代码中,我们使用 JavaScript 改变 SVG {{SVGElement("circle")}} 元素的半径。 ```html - + - + ``` diff --git a/files/zh-cn/web/svg/element/stop/index.md b/files/zh-cn/web/svg/element/stop/index.md index 0e1ef0c8c7538c..c252db3a2ef812 100644 --- a/files/zh-cn/web/svg/element/stop/index.md +++ b/files/zh-cn/web/svg/element/stop/index.md @@ -14,9 +14,11 @@ slug: Web/SVG/Element/stop ## 示例 ```html - - + @@ -25,12 +27,17 @@ slug: Web/SVG/Element/stop - + - + ``` diff --git a/files/zh-cn/web/svg/element/style/index.md b/files/zh-cn/web/svg/element/style/index.md index bb6bd3eb72b4f7..fc5d5e4aa7d2e4 100644 --- a/files/zh-cn/web/svg/element/style/index.md +++ b/files/zh-cn/web/svg/element/style/index.md @@ -14,8 +14,11 @@ slug: Web/SVG/Element/style ## 示例 ```html - + + + + + + + + + + + + - - - + + ``` @@ -49,7 +57,7 @@ slug: Web/SVG/Tutorial/Gradients 以上是一个应用了线性渐变的``元素的示例。线性渐变内部有几个{{SVGElement('stop')}} 结点,这些结点通过指定位置的 offset(偏移)属性和 stop-color(颜色中值)属性来说明在渐变的特定位置上应该是什么颜色;可以直接指定这两个属性值,也可以通过 CSS 来指定他们的值,该例子中混合使用了这两种方法。例如:该示例中指明了渐变开始颜色为红色,到中间位置时变成半透明的黑色,最后变成蓝色。虽然你可以根据需求按照自己的喜好插入很多中间颜色,但是偏移量应该始终从 0% 开始(或者 0 也可以,百分号可以扔掉),到 100%(或 1)结束。如果`stop`设置的位置有重合,将使用 XML 树中较晚设置的值。而且,类似于填充和描边,你也可以指定属性`stop-opacity`来设置某个位置的半透明度(同样,对于 FF3 你也可以设置 rgba 值)。 ```html - + ``` 使用渐变时,我们需要在一个对象的属性`fill`或属性`stroke`中引用它,这跟你在 CSS 中使用`url`引用元素的方法一样。在本例中,url 只是一个渐变的引用,我们已经给这个渐变一个 ID——“Gradient”。要想附加它,将属性`fill`设置为`url(#Gradient)`即可。现在对象就变成多色的了,也可以用同样的方式处理`stroke`。 @@ -57,19 +65,25 @@ slug: Web/SVG/Tutorial/Gradients `` 元素还需要一些其他的属性值,它们指定了渐变的大小和出现范围。渐变的方向可以通过两个点来控制,它们分别是属性 x1、x2、y1 和 y2,这些属性定义了渐变路线走向。渐变色默认是水平方向的,但是通过修改这些属性,就可以旋转该方向。下例中的 Gradient2 创建了一个垂直渐变。 ```html - + ``` > **备注:** 你也可以在渐变上使用`xlink:href 属性。如果`使用了该属性时,一个渐变的属性和颜色中值(stop)可以被另一个渐变包含引用。在下例中,你就不需要在 Grandient2 中重新创建全部的颜色中值(stop)。 > > ```html > -> -> -> +> +> +> > -> xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#Gradient1"/> +> id="Gradient2" +> x1="0" +> x2="0" +> y1="0" +> y2="1" +> xmlns:xlink="http://www.w3.org/1999/xlink" +> xlink:href="#Gradient1" /> > ``` > > 尽管通常你可能在文档的顶部就定义了 Gradient1,但我在结点上直接包含了 xlink 的命名空间,关于这点的更多信息我们会在[讨论图片](/zh-CN/Web/SVG/Tutorial/Other_content_in_SVG)的时候详解。 @@ -84,19 +98,32 @@ slug: Web/SVG/Tutorial/Gradients - - - - - - - - + + + + + + + + - - - + + ``` @@ -111,25 +138,40 @@ slug: Web/SVG/Tutorial/Gradients ```html - + - - - - + + + + - - - - - - (fx,fy) - (cx,cy) - + + + + + + + (fx,fy) + + + (cx,cy) + ``` @@ -146,34 +188,75 @@ slug: Web/SVG/Tutorial/Gradients - - - - - - - - - - - - + + + + + + + + + + + + - - - - - Pad - Repeat - Reflect - + + + + + + Pad + + + Repeat + + + Reflect + ``` diff --git a/files/zh-cn/web/svg/tutorial/patterns/index.md b/files/zh-cn/web/svg/tutorial/patterns/index.md index 2cf4f5d32c390b..e8deda164b5b95 100644 --- a/files/zh-cn/web/svg/tutorial/patterns/index.md +++ b/files/zh-cn/web/svg/tutorial/patterns/index.md @@ -16,23 +16,33 @@ slug: Web/SVG/Tutorial/Patterns - - + + - - + + - - - + + + - - + ``` diff --git a/files/zh-cn/web/svg/tutorial/svg_and_css/index.md b/files/zh-cn/web/svg/tutorial/svg_and_css/index.md index bf7b0829ff5d28..aeafeae53f2910 100644 --- a/files/zh-cn/web/svg/tutorial/svg_and_css/index.md +++ b/files/zh-cn/web/svg/tutorial/svg_and_css/index.md @@ -16,119 +16,133 @@ slug: Web/SVG/Tutorial/SVG_and_CSS 建立一个 SVG 文件 `doc8.svg`。复制下面所有内容: ```html - - - + + SVG demonstration Mozilla CSS Getting Started - SVG demonstration - - - + + + SVG demonstration - Move your mouse pointer over the flower. + + Move your mouse pointer over the flower. + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -136,93 +150,93 @@ slug: Web/SVG/Tutorial/SVG_and_CSS - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -287,7 +301,7 @@ svg { /* outer petals */ #outer-petals { - opacity: .75; + opacity: 0.75; --segment-fill-fill: azure; --segment-fill-stroke: lightsteelblue; --segment-fill-stroke-width: 1; From dfba8618f2a5785c42b44d6d6195d6413224df0f Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 04:55:21 -0700 Subject: [PATCH 22/30] zh-cn: Format /web/api using Prettier (part 2) (#14675) Co-authored-by: allo --- .../api/canvasgradient/addcolorstop/index.md | 19 +-- .../api/canvaspattern/settransform/index.md | 20 +-- .../api/canvasrenderingcontext2d/arc/index.md | 28 ++-- .../canvasrenderingcontext2d/arcto/index.md | 23 +-- .../beginpath/index.md | 8 +- .../beziercurveto/index.md | 15 +- .../canvasrenderingcontext2d/canvas/index.md | 2 +- .../clearrect/index.md | 8 +- .../canvasrenderingcontext2d/clip/index.md | 8 +- .../closepath/index.md | 12 +- .../createpattern/index.md | 3 +- .../direction/index.md | 24 ++-- .../drawfocusifneeded/index.md | 26 ++-- .../drawimage/index.md | 24 ++-- .../canvasrenderingcontext2d/ellipse/index.md | 4 +- .../fillrect/index.md | 10 +- .../fillstyle/index.md | 16 ++- .../filltext/index.md | 2 +- .../canvasrenderingcontext2d/filter/index.md | 10 +- .../gettransform/index.md | 11 +- .../globalalpha/index.md | 22 +-- .../imagesmoothingenabled/index.md | 19 +-- .../ispointinpath/index.md | 6 +- .../ispointinstroke/index.md | 6 +- .../canvasrenderingcontext2d/linecap/index.md | 16 +-- .../linedashoffset/index.md | 10 +- .../linewidth/index.md | 4 +- .../miterlimit/index.md | 3 +- .../putimagedata/index.md | 27 ++-- .../quadraticcurveto/index.md | 16 +-- .../resettransform/index.md | 6 +- .../canvasrenderingcontext2d/rotate/index.md | 12 +- .../canvasrenderingcontext2d/scale/index.md | 16 +-- .../setlinedash/index.md | 19 +-- .../shadowcolor/index.md | 6 +- .../canvasrenderingcontext2d/stroke/index.md | 4 +- .../strokerect/index.md | 16 +-- .../textalign/index.md | 18 +-- .../textbaseline/index.md | 19 ++- .../translate/index.md | 8 +- .../using_channel_messaging/index.md | 22 +-- .../channelmergernode/index.md | 4 +- files/zh-cn/web/api/cleartimeout/index.md | 22 ++- .../zh-cn/web/api/client/postmessage/index.md | 41 +++--- files/zh-cn/web/api/clients/claim/index.md | 2 +- files/zh-cn/web/api/clients/get/index.md | 4 +- files/zh-cn/web/api/clients/index.md | 54 +++---- files/zh-cn/web/api/clients/matchall/index.md | 8 +- .../zh-cn/web/api/clients/openwindow/index.md | 8 +- files/zh-cn/web/api/clipboard/index.md | 2 +- files/zh-cn/web/api/clipboard/read/index.md | 6 +- .../zh-cn/web/api/clipboard/readtext/index.md | 5 +- files/zh-cn/web/api/clipboard/write/index.md | 13 +- .../web/api/clipboard/writetext/index.md | 13 +- files/zh-cn/web/api/clipboard_api/index.md | 7 +- files/zh-cn/web/api/clipboarditem/index.md | 13 +- .../web/api/compression_streams_api/index.md | 2 +- .../compressionstream/index.md | 2 +- .../zh-cn/web/api/compressionstream/index.md | 2 +- files/zh-cn/web/api/console/assert/index.md | 14 +- files/zh-cn/web/api/console/index.md | 7 +- files/zh-cn/web/api/console/log/index.md | 2 +- files/zh-cn/web/api/console/table/index.md | 6 +- files/zh-cn/web/api/console_api/index.md | 4 +- .../index.md | 6 +- .../countqueuingstrategy/index.md | 27 ++-- .../highwatermark/index.md | 2 +- .../web/api/countqueuingstrategy/index.md | 25 ++-- .../api/countqueuingstrategy/size/index.md | 27 ++-- .../zh-cn/web/api/createimagebitmap/index.md | 16 +-- .../web/api/crossoriginisolated/index.md | 2 +- .../web/api/crypto/getrandomvalues/index.md | 2 +- files/zh-cn/web/api/crypto_property/index.md | 4 +- files/zh-cn/web/api/cryptokey/index.md | 4 + .../zh-cn/web/api/css/escape_static/index.md | 12 +- .../api/css/factory_functions_static/index.md | 10 +- .../web/api/css/supports_static/index.md | 10 +- .../web/api/css_custom_highlight_api/index.md | 28 ++-- .../web/api/css_font_loading_api/index.md | 8 +- .../index.md | 136 +++++++++--------- files/zh-cn/web/api/cssrule/csstext/index.md | 4 +- .../getpropertycssvalue/index.md | 2 +- .../getpropertypriority/index.md | 2 +- .../getpropertyvalue/index.md | 2 +- .../web/api/cssstyledeclaration/index.md | 2 +- .../web/api/cssstyledeclaration/item/index.md | 2 +- .../api/cssstyledeclaration/length/index.md | 4 +- .../removeproperty/index.md | 2 +- .../cssstyledeclaration/setproperty/index.md | 2 +- files/zh-cn/web/api/cssstylesheet/index.md | 17 +-- .../web/api/cssstylesheet/insertrule/index.md | 51 ++++--- files/zh-cn/web/api/cssvalue/index.md | 10 +- .../api/customelementregistry/define/index.md | 110 +++++++------- .../api/customelementregistry/get/index.md | 17 ++- .../web/api/customelementregistry/index.md | 20 ++- .../customelementregistry/upgrade/index.md | 2 +- .../whendefined/index.md | 12 +- .../web/api/customevent/customevent/index.md | 57 +++++--- .../zh-cn/web/api/customevent/detail/index.md | 8 +- .../web/api/datatransfer/cleardata/index.md | 70 ++++----- 100 files changed, 794 insertions(+), 710 deletions(-) diff --git a/files/zh-cn/web/api/canvasgradient/addcolorstop/index.md b/files/zh-cn/web/api/canvasgradient/addcolorstop/index.md index 70a6b4c0757380..1d957d70e2da0b 100644 --- a/files/zh-cn/web/api/canvasgradient/addcolorstop/index.md +++ b/files/zh-cn/web/api/canvasgradient/addcolorstop/index.md @@ -29,7 +29,7 @@ void gradient.addColorStop(offset, color); #### HTML ```html - + ``` #### JavaScript @@ -38,11 +38,11 @@ void gradient.addColorStop(offset, color); var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); -var gradient = ctx.createLinearGradient(0,0,200,0); -gradient.addColorStop(0,"green"); -gradient.addColorStop(1,"white"); +var gradient = ctx.createLinearGradient(0, 0, 200, 0); +gradient.addColorStop(0, "green"); +gradient.addColorStop(1, "white"); ctx.fillStyle = gradient; -ctx.fillRect(10,10,200,100); +ctx.fillRect(10, 10, 200, 100); ``` 编辑以下代码可看到画布变化: @@ -58,7 +58,8 @@ var gradient = ctx.createLinearGradient(0,0,200,0); gradient.addColorStop(0,"green"); gradient.addColorStop(1,"white"); ctx.fillStyle = gradient; -ctx.fillRect(10,10,200,100); +ctx.fillRect(10,10,200,100); ``` ```js hidden @@ -74,14 +75,14 @@ function drawCanvas() { eval(textarea.value); } -reset.addEventListener("click", function() { +reset.addEventListener("click", function () { textarea.value = code; drawCanvas(); }); -edit.addEventListener("click", function() { +edit.addEventListener("click", function () { textarea.focus(); -}) +}); textarea.addEventListener("input", drawCanvas); window.addEventListener("load", drawCanvas); diff --git a/files/zh-cn/web/api/canvaspattern/settransform/index.md b/files/zh-cn/web/api/canvaspattern/settransform/index.md index 01f07ed271ef05..bd8e8d3be192eb 100644 --- a/files/zh-cn/web/api/canvaspattern/settransform/index.md +++ b/files/zh-cn/web/api/canvaspattern/settransform/index.md @@ -27,8 +27,7 @@ setTransform(matrix) #### HTML ```html - - + ``` #### JavaScript @@ -41,13 +40,13 @@ var svg1 = document.getElementById("svg1"); var matrix = svg1.createSVGMatrix(); var img = new Image(); -img.src = 'canvas_createpattern.png'; +img.src = "canvas_createpattern.png"; -img.onload = function() { - var pattern = ctx.createPattern(img, 'repeat'); +img.onload = function () { + var pattern = ctx.createPattern(img, "repeat"); pattern.setTransform(matrix.rotate(-45).scale(1.5)); ctx.fillStyle = pattern; - ctx.fillRect(0,0,400,400); + ctx.fillRect(0, 0, 400, 400); }; ``` @@ -68,7 +67,8 @@ img.onload = function() { pattern.setTransform(matrix.rotate(-45).scale(1.5)); ctx.fillStyle = pattern; ctx.fillRect(0,0,400,400); -}; +}; ``` ```js hidden @@ -87,14 +87,14 @@ function drawCanvas() { eval(textarea.value); } -reset.addEventListener("click", function() { +reset.addEventListener("click", function () { textarea.value = code; drawCanvas(); }); -edit.addEventListener("click", function() { +edit.addEventListener("click", function () { textarea.focus(); -}) +}); textarea.addEventListener("input", drawCanvas); window.addEventListener("load", drawCanvas); diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/arc/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/arc/index.md index 5adea27eb3c9c3..7ddd2789876071 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/arc/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/arc/index.md @@ -43,8 +43,8 @@ void ctx.arc(x, y, radius, startAngle, endAngle, anticlockwise); #### JavaScript ```js -const canvas = document.querySelector('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.querySelector("canvas"); +const ctx = canvas.getContext("2d"); ctx.beginPath(); ctx.arc(100, 75, 50, 0, 2 * Math.PI); @@ -64,23 +64,23 @@ ctx.stroke(); ``` ```js -var canvas = document.getElementById('canvas'); -var ctx = canvas.getContext('2d'); +var canvas = document.getElementById("canvas"); +var ctx = canvas.getContext("2d"); // Draw shapes -for (i=0;i<4;i++){ - for(j=0;j<3;j++){ +for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { ctx.beginPath(); - var x = 25+j*50; // x coordinate - var y = 25+i*50; // y coordinate - var radius = 20; // Arc radius - var startAngle = 0; // Starting point on circle - var endAngle = Math.PI+(Math.PI*j)/2; // End point on circle - var clockwise = i%2==0 ? false : true; // clockwise or anticlockwise + var x = 25 + j * 50; // x coordinate + var y = 25 + i * 50; // y coordinate + var radius = 20; // Arc radius + var startAngle = 0; // Starting point on circle + var endAngle = Math.PI + (Math.PI * j) / 2; // End point on circle + var clockwise = i % 2 == 0 ? false : true; // clockwise or anticlockwise - ctx.arc(x,y,radius,startAngle,endAngle, clockwise); + ctx.arc(x, y, radius, startAngle, endAngle, clockwise); - if (i>1){ + if (i > 1) { ctx.fill(); } else { ctx.stroke(); diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/arcto/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/arcto/index.md index 405b539be3f55d..c37cb920236636 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/arcto/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/arcto/index.md @@ -44,29 +44,29 @@ void ctx.arcTo(x1, y1, x2, y2, radius); var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); -ctx.setLineDash([]) +ctx.setLineDash([]); ctx.beginPath(); ctx.moveTo(150, 20); -ctx.arcTo(150,100,50,20,30); +ctx.arcTo(150, 100, 50, 20, 30); ctx.stroke(); -ctx.fillStyle = 'blue'; +ctx.fillStyle = "blue"; // base point ctx.fillRect(150, 20, 10, 10); -ctx.fillStyle = 'red'; +ctx.fillStyle = "red"; // control point one ctx.fillRect(150, 100, 10, 10); // control point two ctx.fillRect(50, 20, 10, 10); // -ctx.setLineDash([5,5]) +ctx.setLineDash([5, 5]); ctx.moveTo(150, 20); -ctx.lineTo(150,100); +ctx.lineTo(150, 100); ctx.lineTo(50, 20); ctx.stroke(); ctx.beginPath(); -ctx.arc(120,38,30,0,2*Math.PI); +ctx.arc(120, 38, 30, 0, 2 * Math.PI); ctx.stroke(); ``` @@ -106,7 +106,8 @@ ctx.lineTo(50, 20); ctx.stroke(); ctx.beginPath(); ctx.arc(120,38,30,0,2*Math.PI); -ctx.stroke(); +ctx.stroke(); ``` ```js hidden @@ -122,14 +123,14 @@ function drawCanvas() { eval(textarea.value); } -reset.addEventListener("click", function() { +reset.addEventListener("click", function () { textarea.value = code; drawCanvas(); }); -edit.addEventListener("click", function() { +edit.addEventListener("click", function () { textarea.focus(); -}) +}); textarea.addEventListener("input", drawCanvas); window.addEventListener("load", drawCanvas); diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/beginpath/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/beginpath/index.md index 35f3b9f26c277f..e9102db6f6c1d0 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/beginpath/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/beginpath/index.md @@ -28,19 +28,19 @@ void ctx.beginPath(); #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); // First path ctx.beginPath(); -ctx.strokeStyle = 'blue'; +ctx.strokeStyle = "blue"; ctx.moveTo(20, 20); ctx.lineTo(200, 20); ctx.stroke(); // Second path ctx.beginPath(); -ctx.strokeStyle = 'green'; +ctx.strokeStyle = "green"; ctx.moveTo(20, 20); ctx.lineTo(120, 120); ctx.stroke(); diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/beziercurveto/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/beziercurveto/index.md index 72c41a602fc8df..03c0cb03745a9d 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/beziercurveto/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/beziercurveto/index.md @@ -47,17 +47,17 @@ var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); ctx.beginPath(); -ctx.moveTo(50,20); +ctx.moveTo(50, 20); ctx.bezierCurveTo(230, 30, 150, 60, 50, 100); ctx.stroke(); -ctx.fillStyle = 'blue'; +ctx.fillStyle = "blue"; // start point ctx.fillRect(50, 20, 10, 10); // end point ctx.fillRect(50, 100, 10, 10); -ctx.fillStyle = 'red'; +ctx.fillStyle = "red"; // control point one ctx.fillRect(230, 30, 10, 10); // control point two @@ -79,7 +79,8 @@ ctx.fillRect(150, 70, 10, 10); +ctx.stroke(); ``` ```js hidden @@ -95,14 +96,14 @@ function drawCanvas() { eval(textarea.value); } -reset.addEventListener("click", function() { +reset.addEventListener("click", function () { textarea.value = code; drawCanvas(); }); -edit.addEventListener("click", function() { +edit.addEventListener("click", function () { textarea.focus(); -}) +}); textarea.addEventListener("input", drawCanvas); window.addEventListener("load", drawCanvas); diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/canvas/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/canvas/index.md index 91eab1a8b353ab..0864cbaa109a5d 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/canvas/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/canvas/index.md @@ -26,7 +26,7 @@ ctx.canvas; ```js var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); -ctx.canvas // HTMLCanvasElement +ctx.canvas; // HTMLCanvasElement ``` ## 规范描述 diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/clearrect/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/clearrect/index.md index 1e258b0f09f2d5..4112c73825e960 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/clearrect/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/clearrect/index.md @@ -35,8 +35,8 @@ void ctx.clearRect(x, y, width, height); 这段代码清除整个画布。这段代码通常在动画的每一帧开始被执行。清除的范围涵覆盖了整个 {{HtmlElement("canvas")}} 元素。 ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); ctx.clearRect(0, 0, canvas.width, canvas.height); ``` @@ -60,12 +60,12 @@ var ctx = canvas.getContext("2d"); // 绘制黄色背景 ctx.beginPath(); -ctx.fillStyle = '#ff6'; +ctx.fillStyle = "#ff6"; ctx.fillRect(0, 0, canvas.width, canvas.height); // 绘制蓝色三角形 ctx.beginPath(); -ctx.fillStyle = 'blue'; +ctx.fillStyle = "blue"; ctx.moveTo(20, 20); ctx.lineTo(180, 20); ctx.lineTo(130, 130); diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/clip/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/clip/index.md index c1725512c08932..87f679de6be9ac 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/clip/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/clip/index.md @@ -47,8 +47,8 @@ void ctx.clip(path, fillRule); #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); // Create circular clipping region ctx.beginPath(); @@ -56,9 +56,9 @@ ctx.arc(100, 75, 50, 0, Math.PI * 2); ctx.clip(); // Draw stuff that gets clipped -ctx.fillStyle = 'blue'; +ctx.fillStyle = "blue"; ctx.fillRect(0, 0, canvas.width, canvas.height); -ctx.fillStyle = 'orange'; +ctx.fillStyle = "orange"; ctx.fillRect(0, 0, 100, 100); ``` diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/closepath/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/closepath/index.md index 5bbda5f9a4e120..3de7c56c46bb41 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/closepath/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/closepath/index.md @@ -28,14 +28,14 @@ void ctx.closePath(); #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); ctx.beginPath(); -ctx.moveTo(20, 140); // Move pen to bottom-left corner -ctx.lineTo(120, 10); // Line to top corner -ctx.lineTo(220, 140); // Line to bottom-right corner -ctx.closePath(); // Line to bottom-left corner +ctx.moveTo(20, 140); // Move pen to bottom-left corner +ctx.lineTo(120, 10); // Line to top corner +ctx.lineTo(220, 140); // Line to bottom-right corner +ctx.closePath(); // Line to bottom-left corner ctx.stroke(); ``` diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/createpattern/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/createpattern/index.md index c1092ea332d5c1..55847c2918df8f 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/createpattern/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/createpattern/index.md @@ -63,7 +63,8 @@ const ctx = canvas.getContext("2d"); const img = new Image(); img.src = "canvas_createpattern.png"; -img.onload = () => { // Only use the image after it's loaded +img.onload = () => { + // Only use the image after it's loaded const pattern = ctx.createPattern(img, "repeat"); ctx.fillStyle = pattern; ctx.fillRect(0, 0, 300, 300); diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/direction/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/direction/index.md index 4130fb613c498a..8bb374ae15523e 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/direction/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/direction/index.md @@ -41,13 +41,13 @@ ctx.direction = "ltr" || "rtl" || "inherit"; #### JavaScript ```js -var canvas = document.getElementById('canvas'); -var ctx = canvas.getContext('2d'); +var canvas = document.getElementById("canvas"); +var ctx = canvas.getContext("2d"); -ctx.font = '48px serif'; -ctx.fillText('Hi!', 150, 50); -ctx.direction = 'rtl'; -ctx.fillText('Hi!', 150, 130); +ctx.font = "48px serif"; +ctx.fillText("Hi!", 150, 50); +ctx.direction = "rtl"; +ctx.fillText("Hi!", 150, 130); ``` ```html hidden @@ -55,13 +55,13 @@ ctx.fillText('Hi!', 150, 130); ``` ```js hidden -var canvas = document.getElementById('canvas'); -var ctx = canvas.getContext('2d'); +var canvas = document.getElementById("canvas"); +var ctx = canvas.getContext("2d"); -ctx.font = '48px serif'; -ctx.fillText('Hi!', 150, 50); -ctx.direction = 'rtl'; -ctx.fillText('Hi!', 150, 130); +ctx.font = "48px serif"; +ctx.fillText("Hi!", 150, 50); +ctx.direction = "rtl"; +ctx.fillText("Hi!", 150, 130); ``` #### 结果 diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/drawfocusifneeded/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/drawfocusifneeded/index.md index 1eaa0f924aa620..0cdee1b82ec2d8 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/drawfocusifneeded/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/drawfocusifneeded/index.md @@ -39,14 +39,14 @@ void ctx.drawFocusIfNeeded(path, element); #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); -const button1 = document.getElementById('button1'); -const button2 = document.getElementById('button2'); - -document.addEventListener('focus', redraw, true); -document.addEventListener('blur', redraw, true); -canvas.addEventListener('click', handleClick, false); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); +const button1 = document.getElementById("button1"); +const button2 = document.getElementById("button2"); + +document.addEventListener("focus", redraw, true); +document.addEventListener("blur", redraw, true); +canvas.addEventListener("click", handleClick, false); redraw(); function redraw() { @@ -79,14 +79,14 @@ function drawButton(el, x, y) { const height = 40; // Button background - ctx.fillStyle = active ? 'pink' : 'lightgray'; + ctx.fillStyle = active ? "pink" : "lightgray"; ctx.fillRect(x, y, width, height); // Button text - ctx.font = '15px sans-serif'; - ctx.textAlign = 'center'; - ctx.textBaseline = 'middle'; - ctx.fillStyle = active ? 'blue' : 'black'; + ctx.font = "15px sans-serif"; + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + ctx.fillStyle = active ? "blue" : "black"; ctx.fillText(el.textContent, x + width / 2, y + height / 2); // Define clickable area diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/drawimage/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/drawimage/index.md index 4e043226641cca..4116a4a1bd5fe8 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/drawimage/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/drawimage/index.md @@ -10,9 +10,9 @@ Canvas 2D API 中的 **`CanvasRenderingContext2D.drawImage()`** 方法提供了 ## 语法 ```js -drawImage(image, dx, dy) -drawImage(image, dx, dy, dWidth, dHeight) -drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight) +drawImage(image, dx, dy); +drawImage(image, dx, dy, dWidth, dHeight); +drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight); ``` ![drawImage](canvas_drawimage.jpg) @@ -61,9 +61,7 @@ drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight) ```html
- +
``` @@ -72,11 +70,11 @@ drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight) 原图像从坐标 (33,71) 处截取一个宽度为 104 高度为 124 的图像。并将其绘制到画布的 (21, 20) 坐标处,并将其缩放为宽 87、高 104 的图像。 ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); -const image = document.getElementById('source'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); +const image = document.getElementById("source"); -image.addEventListener('load', (e) => { +image.addEventListener("load", (e) => { ctx.drawImage(image, 33, 71, 104, 124, 21, 20, 87, 104); }); ``` @@ -100,14 +98,14 @@ image.addEventListener('load', (e) => { #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); const image = new Image(60, 45); // Using optional size for image image.onload = drawImageActualSize; // Draw when image has loaded // Load an image of intrinsic size 300x227 in CSS pixels -image.src = 'rhino.jpg'; +image.src = "rhino.jpg"; function drawImageActualSize() { // Use the intrinsic size of image in CSS pixels for the canvas element diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/ellipse/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/ellipse/index.md index e98f26b9ed4111..35fe92d5a19605 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/ellipse/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/ellipse/index.md @@ -47,8 +47,8 @@ void ctx.ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlo #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); // Draw the ellipse ctx.beginPath(); diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/fillrect/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/fillrect/index.md index 77f4b8b43b2e07..f2eda6154ffe41 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/fillrect/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/fillrect/index.md @@ -45,9 +45,9 @@ void ctx.fillRect(x, y, width, height); 下面绘制的矩形左上顶点在 (20, 10),宽高分别是 150 和 100 像素。 ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); -ctx.fillStyle = 'green'; +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); +ctx.fillStyle = "green"; ctx.fillRect(20, 10, 150, 100); ``` @@ -60,8 +60,8 @@ ctx.fillRect(20, 10, 150, 100); 下面这个代码片段使用本方法填充了整个画布。这样做通常的目的是在开始绘制其他内容前设置一个背景。为了达到这样的效果,需要让填充的范围和画布的范围相同,需要访问{{HtmlElement("canvas")}}元素的`width` 和 `height` 属性。 ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); ctx.fillRect(0, 0, canvas.width, canvas.height); ``` diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/fillstyle/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/fillstyle/index.md index 557c9fa09af897..dfd6e3fae2be8d 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/fillstyle/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/fillstyle/index.md @@ -61,12 +61,16 @@ ctx.fillRect(10, 10, 100, 100); ``` ```js -var ctx = document.getElementById('canvas').getContext('2d'); -for (var i=0;i<6;i++){ - for (var j=0;j<6;j++){ - ctx.fillStyle = 'rgb(' + Math.floor(255-42.5*i) + ',' + - Math.floor(255-42.5*j) + ',0)'; - ctx.fillRect(j*25,i*25,25,25); +var ctx = document.getElementById("canvas").getContext("2d"); +for (var i = 0; i < 6; i++) { + for (var j = 0; j < 6; j++) { + ctx.fillStyle = + "rgb(" + + Math.floor(255 - 42.5 * i) + + "," + + Math.floor(255 - 42.5 * j) + + ",0)"; + ctx.fillRect(j * 25, i * 25, 25, 25); } } ``` diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/filltext/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/filltext/index.md index a4478ec416141f..07bb2b04433485 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/filltext/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/filltext/index.md @@ -5,7 +5,7 @@ slug: Web/API/CanvasRenderingContext2D/fillText {{APIRef}} -**`CanvasRenderingContext2D.fillText()`** 是 Canvas 2D API 在 *(x, y)* 位置填充文本的方法。如果选项的第四个参数提供了最大宽度,文本会进行缩放以适应最大宽度。 +**`CanvasRenderingContext2D.fillText()`** 是 Canvas 2D API 在 _(x, y)_ 位置填充文本的方法。如果选项的第四个参数提供了最大宽度,文本会进行缩放以适应最大宽度。 参见 {{domxref("CanvasRenderingContext2D.strokeText()")}} 方法对文本进行描边。 diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/filter/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/filter/index.md index f349813dbcbdc8..7cdf8784c2ebe6 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/filter/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/filter/index.md @@ -66,12 +66,12 @@ filter 属性接受{{domxref("DOMString")}}字符串,可以包含一个或多 #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); -ctx.filter = 'blur(4px)'; -ctx.font = '48px serif'; -ctx.fillText('Hello world', 50, 100); +ctx.filter = "blur(4px)"; +ctx.font = "48px serif"; +ctx.fillText("Hello world", 50, 100); ``` #### 结果 diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/gettransform/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/gettransform/index.md index d07c745785dcaf..53a29dd8dc9454 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/gettransform/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/gettransform/index.md @@ -34,8 +34,7 @@ let storedTransform = ctx.getTransform(); #### HTML ```html - - + ``` #### CSS @@ -49,11 +48,11 @@ canvas { #### JavaScript ```js -const canvases = document.querySelectorAll('canvas'); -const ctx1 = canvases[0].getContext('2d'); -const ctx2 = canvases[1].getContext('2d'); +const canvases = document.querySelectorAll("canvas"); +const ctx1 = canvases[0].getContext("2d"); +const ctx2 = canvases[1].getContext("2d"); -ctx1.setTransform(1, .2, .8, 1, 0, 0); +ctx1.setTransform(1, 0.2, 0.8, 1, 0, 0); ctx1.fillRect(25, 25, 50, 50); let storedTransform = ctx1.getTransform(); diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/globalalpha/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/globalalpha/index.md index c5499b6fb4571a..03a018323f13de 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/globalalpha/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/globalalpha/index.md @@ -33,15 +33,15 @@ ctx.globalAlpha = value; #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); ctx.globalAlpha = 0.5; -ctx.fillStyle = 'blue'; +ctx.fillStyle = "blue"; ctx.fillRect(10, 10, 100, 100); -ctx.fillStyle = 'red'; +ctx.fillStyle = "red"; ctx.fillRect(50, 50, 100, 100); ``` @@ -58,19 +58,19 @@ ctx.fillRect(50, 50, 100, 100); ``` ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); // Draw background -ctx.fillStyle = '#FD0'; +ctx.fillStyle = "#FD0"; ctx.fillRect(0, 0, 75, 75); -ctx.fillStyle = '#6C0'; +ctx.fillStyle = "#6C0"; ctx.fillRect(75, 0, 75, 75); -ctx.fillStyle = '#09F'; +ctx.fillStyle = "#09F"; ctx.fillRect(0, 75, 75, 75); -ctx.fillStyle = '#F30'; +ctx.fillStyle = "#F30"; ctx.fillRect(75, 75, 75, 75); -ctx.fillStyle = '#FFF'; +ctx.fillStyle = "#FFF"; // Set transparency value ctx.globalAlpha = 0.2; diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/imagesmoothingenabled/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/imagesmoothingenabled/index.md index d2de0b95b814e8..40a9ecd5e669d2 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/imagesmoothingenabled/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/imagesmoothingenabled/index.md @@ -37,26 +37,27 @@ ctx.imageSmoothingEnabled = value; #### JavaScript ```js -const canvas = document.getElementById('canvas'); +const canvas = document.getElementById("canvas"); -const ctx = canvas.getContext('2d'); -ctx.font = '16px sans-serif'; -ctx.textAlign = 'center'; +const ctx = canvas.getContext("2d"); +ctx.font = "16px sans-serif"; +ctx.textAlign = "center"; const img = new Image(); -img.src = 'https://interactive-examples.mdn.mozilla.net/media/examples/star.png'; +img.src = + "https://interactive-examples.mdn.mozilla.net/media/examples/star.png"; img.onload = () => { const w = img.width, - h = img.height; + h = img.height; - ctx.fillText('Source', w * .5, 20); + ctx.fillText("Source", w * 0.5, 20); ctx.drawImage(img, 0, 24, w, h); - ctx.fillText('Smoothing = TRUE', w * 2.5, 20); + ctx.fillText("Smoothing = TRUE", w * 2.5, 20); ctx.imageSmoothingEnabled = true; ctx.drawImage(img, w, 24, w * 3, h * 3); - ctx.fillText('Smoothing = FALSE', w * 5.5, 20); + ctx.fillText("Smoothing = FALSE", w * 5.5, 20); ctx.imageSmoothingEnabled = false; ctx.drawImage(img, w * 4, 24, w * 3, h * 3); }; diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/ispointinpath/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/ispointinpath/index.md index 4b77bd66290091..dbc68370f999ac 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/ispointinpath/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/ispointinpath/index.md @@ -56,9 +56,9 @@ isPointInPath(path, x, y, fillRule) #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); -const result = document.getElementById('result'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); +const result = document.getElementById("result"); ctx.rect(10, 10, 100, 100); ctx.fill(); diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/ispointinstroke/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/ispointinstroke/index.md index 0bf955f38a6f8d..67429c4eca731c 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/ispointinstroke/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/ispointinstroke/index.md @@ -44,9 +44,9 @@ boolean ctx.isPointInStroke(path, x, y); #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); -const result = document.getElementById('result'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); +const result = document.getElementById("result"); ctx.rect(10, 10, 100, 100); ctx.stroke(); diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/linecap/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/linecap/index.md index 0042c5bf7e2405..e1451fad60b252 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/linecap/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/linecap/index.md @@ -41,13 +41,13 @@ ctx.lineCap = "square"; #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); ctx.beginPath(); ctx.moveTo(20, 20); ctx.lineWidth = 15; -ctx.lineCap = 'round'; +ctx.lineCap = "round"; ctx.lineTo(100, 100); ctx.stroke(); ``` @@ -67,11 +67,11 @@ ctx.stroke(); ``` ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); // Draw guides -ctx.strokeStyle = '#09f'; +ctx.strokeStyle = "#09f"; ctx.beginPath(); ctx.moveTo(10, 10); ctx.lineTo(140, 10); @@ -80,8 +80,8 @@ ctx.lineTo(140, 140); ctx.stroke(); // Draw lines -ctx.strokeStyle = 'black'; -['butt', 'round', 'square'].forEach((lineCap, i) => { +ctx.strokeStyle = "black"; +["butt", "round", "square"].forEach((lineCap, i) => { ctx.lineWidth = 15; ctx.lineCap = lineCap; ctx.beginPath(); diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/linedashoffset/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/linedashoffset/index.md index e989c979e7f946..3fa4d331c613a2 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/linedashoffset/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/linedashoffset/index.md @@ -31,8 +31,8 @@ ctx.lineDashOffset = value; #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); ctx.setLineDash([4, 16]); @@ -44,7 +44,7 @@ ctx.stroke(); // Dashed line with offset of 4 ctx.beginPath(); -ctx.strokeStyle = 'red'; +ctx.strokeStyle = "red"; ctx.lineDashOffset = 4; ctx.moveTo(0, 100); ctx.lineTo(300, 100); @@ -71,10 +71,10 @@ var ctx = canvas.getContext("2d"); var offset = 0; function draw() { - ctx.clearRect(0,0, canvas.width, canvas.height); + ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.setLineDash([4, 2]); ctx.lineDashOffset = -offset; - ctx.strokeRect(10,10, 100, 100); + ctx.strokeRect(10, 10, 100, 100); } function march() { diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/linewidth/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/linewidth/index.md index 33e0760096620a..61b4a3069e0310 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/linewidth/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/linewidth/index.md @@ -35,8 +35,8 @@ ctx.lineWidth = value; #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); ctx.lineWidth = 15; diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/miterlimit/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/miterlimit/index.md index 205da75349f1ca..7178c2aae04d08 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/miterlimit/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/miterlimit/index.md @@ -45,7 +45,8 @@ ctx.beginPath(); ctx.moveTo(0,0); ctx.lineWidth = 15; ctx.lineTo(100, 100); -ctx.stroke(); +ctx.stroke(); ``` ```js hidden diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/putimagedata/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/putimagedata/index.md index c8f45a17d48efd..b4c8a4693930c5 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/putimagedata/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/putimagedata/index.md @@ -55,25 +55,34 @@ void ctx.putImageData(imagedata, dx, dy, dirtyX, dirtyY, dirtyWidth, dirtyHeight #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); - -function putImageData(ctx, imageData, dx, dy, - dirtyX, dirtyY, dirtyWidth, dirtyHeight) { +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); + +function putImageData( + ctx, + imageData, + dx, + dy, + dirtyX, + dirtyY, + dirtyWidth, + dirtyHeight, +) { const data = imageData.data; const height = imageData.height; const width = imageData.width; dirtyX = dirtyX || 0; dirtyY = dirtyY || 0; - dirtyWidth = dirtyWidth !== undefined? dirtyWidth: width; - dirtyHeight = dirtyHeight !== undefined? dirtyHeight: height; + dirtyWidth = dirtyWidth !== undefined ? dirtyWidth : width; + dirtyHeight = dirtyHeight !== undefined ? dirtyHeight : height; const limitBottom = dirtyY + dirtyHeight; const limitRight = dirtyX + dirtyWidth; for (let y = dirtyY; y < limitBottom; y++) { for (let x = dirtyX; x < limitRight; x++) { const pos = y * width + x; - ctx.fillStyle = - `rgba(${data[pos*4+0]}, ${data[pos*4+1]}, ${data[pos*4+2]}, ${data[pos*4+3]/255})`; + ctx.fillStyle = `rgba(${data[pos * 4 + 0]}, ${data[pos * 4 + 1]}, ${ + data[pos * 4 + 2] + }, ${data[pos * 4 + 3] / 255})`; ctx.fillRect(x + dx, y + dy, 1, 1); } } diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/quadraticcurveto/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/quadraticcurveto/index.md index a5651fcba98dc1..4281e62440f0d5 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/quadraticcurveto/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/quadraticcurveto/index.md @@ -39,8 +39,8 @@ void ctx.quadraticCurveTo(cpx, cpy, x, y); #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); // Quadratic Bézier curve ctx.beginPath(); @@ -49,14 +49,14 @@ ctx.quadraticCurveTo(230, 30, 50, 100); ctx.stroke(); // Start and end points -ctx.fillStyle = 'blue'; +ctx.fillStyle = "blue"; ctx.beginPath(); -ctx.arc(50, 20, 5, 0, 2 * Math.PI); // Start point -ctx.arc(50, 100, 5, 0, 2 * Math.PI); // End point +ctx.arc(50, 20, 5, 0, 2 * Math.PI); // Start point +ctx.arc(50, 100, 5, 0, 2 * Math.PI); // End point ctx.fill(); // Control point -ctx.fillStyle = 'red'; +ctx.fillStyle = "red"; ctx.beginPath(); ctx.arc(230, 30, 5, 0, 2 * Math.PI); ctx.fill(); @@ -81,8 +81,8 @@ ctx.fill(); 曲线从`moveTo()`指定的点开始:(20, 110)。控制点位于 (230, 150)。曲线在 (250, 20) 处结束。 ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); ctx.beginPath(); ctx.moveTo(20, 110); diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/resettransform/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/resettransform/index.md index 97191f300c033a..a1b9622fa94dcf 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/resettransform/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/resettransform/index.md @@ -28,11 +28,11 @@ void ctx.resetTransform(); #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); // Draw a rotated rectangle -ctx.rotate(45 * Math.PI / 180); +ctx.rotate((45 * Math.PI) / 180); ctx.fillRect(60, 0, 100, 30); // Reset transformation matrix to the identity matrix diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/rotate/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/rotate/index.md index 6f4e8b5b75b1fe..d05a17d997b60d 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/rotate/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/rotate/index.md @@ -37,21 +37,21 @@ void ctx.rotate(angle); #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); // Point of transform origin ctx.arc(0, 0, 5, 0, 2 * Math.PI); -ctx.fillStyle = 'blue'; +ctx.fillStyle = "blue"; ctx.fill(); // Non-rotated rectangle -ctx.fillStyle = 'gray'; +ctx.fillStyle = "gray"; ctx.fillRect(100, 0, 80, 20); // Rotated rectangle -ctx.rotate(45 * Math.PI / 180); -ctx.fillStyle = 'red'; +ctx.rotate((45 * Math.PI) / 180); +ctx.fillStyle = "red"; ctx.fillRect(100, 0, 80, 20); // Reset transformation matrix to the identity matrix diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/scale/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/scale/index.md index a94aeafa31fea2..ecf542d9fced52 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/scale/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/scale/index.md @@ -41,19 +41,19 @@ The rectangle has a specified width of 8 and a height of 20. The transformation Notice that its position on the canvas also changes. Since its specified corner is (10, 10), its rendered corner becomes (90, 30). ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); // Scaled rectangle ctx.scale(9, 3); -ctx.fillStyle = 'red'; +ctx.fillStyle = "red"; ctx.fillRect(10, 10, 8, 20); // Reset current transformation matrix to the identity matrix ctx.setTransform(1, 0, 0, 1, 0, 0); // Non-scaled rectangle -ctx.fillStyle = 'gray'; +ctx.fillStyle = "gray"; ctx.fillRect(10, 10, 8, 20); ``` @@ -78,12 +78,12 @@ Note that the call to {{domxref("CanvasRenderingContext2D.fillText()", "fillText #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); ctx.scale(-1, 1); -ctx.font = '48px serif'; -ctx.fillText('Hello world!', -280, 90); +ctx.font = "48px serif"; +ctx.fillText("Hello world!", -280, 90); ctx.setTransform(1, 0, 0, 1, 0, 0); ``` diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/setlinedash/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/setlinedash/index.md index bb629eab204a96..72cdbf50da9c79 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/setlinedash/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/setlinedash/index.md @@ -39,8 +39,8 @@ setLineDash(segments); #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); // Dashed line ctx.beginPath(); @@ -70,7 +70,8 @@ ctx.setLineDash([5, 15]); ctx.beginPath(); ctx.moveTo(0,100); ctx.lineTo(400, 100); -ctx.stroke(); +ctx.stroke(); ``` ```js hidden @@ -86,14 +87,14 @@ function drawCanvas() { eval(textarea.value); } -reset.addEventListener("click", function() { +reset.addEventListener("click", function () { textarea.value = code; drawCanvas(); }); -edit.addEventListener("click", function() { +edit.addEventListener("click", function () { textarea.focus(); -}) +}); textarea.addEventListener("input", drawCanvas); window.addEventListener("load", drawCanvas); @@ -125,8 +126,8 @@ function drawDashedLine(pattern) { y += 20; } -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); let y = 15; drawDashedLine([]); @@ -135,7 +136,7 @@ drawDashedLine([10, 10]); drawDashedLine([20, 5]); drawDashedLine([15, 3, 3, 3]); drawDashedLine([20, 3, 3, 3, 3, 3, 3, 3]); -drawDashedLine([12, 3, 3]); // Equals [12, 3, 3, 12, 3, 3] +drawDashedLine([12, 3, 3]); // Equals [12, 3, 3, 12, 3, 3] ``` #### Result diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/shadowcolor/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/shadowcolor/index.md index 46c58c30b2a2d2..b984ebb1eeffe4 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/shadowcolor/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/shadowcolor/index.md @@ -31,11 +31,11 @@ ctx.shadowColor = color; #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); // Shadow -ctx.shadowColor = 'red'; +ctx.shadowColor = "red"; ctx.shadowOffsetX = 10; ctx.shadowOffsetY = 10; diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/stroke/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/stroke/index.md index 86063df603c7fc..f62a3ef5d77293 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/stroke/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/stroke/index.md @@ -34,8 +34,8 @@ void ctx.stroke(path); #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); ctx.rect(10, 10, 150, 100); ctx.stroke(); ``` diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/strokerect/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/strokerect/index.md index 58e0c6c081c9d8..dc530da8009377 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/strokerect/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/strokerect/index.md @@ -45,9 +45,9 @@ void ctx.strokeRect(x, y, width, height); 矩形的左上角是(20,10)。它的宽度为 160,高度为 100。 ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); -ctx.strokeStyle = 'green'; +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); +ctx.strokeStyle = "green"; ctx.strokeRect(20, 10, 160, 100); ``` @@ -68,13 +68,13 @@ ctx.strokeRect(20, 10, 160, 100); #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); -ctx.shadowColor = '#d53'; +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); +ctx.shadowColor = "#d53"; ctx.shadowBlur = 20; -ctx.lineJoin = 'bevel'; +ctx.lineJoin = "bevel"; ctx.lineWidth = 15; -ctx.strokeStyle = '#38f'; +ctx.strokeStyle = "#38f"; ctx.strokeRect(30, 30, 160, 90); ``` diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/textalign/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/textalign/index.md index fa5346589b22d3..93ae9f990d2f44 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/textalign/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/textalign/index.md @@ -49,9 +49,9 @@ ctx.textAlign = "left" || "right" || "center" || "start" || "end"; #### JavaScript ```js -const canvas = document.getElementById('canvas'); +const canvas = document.getElementById("canvas"); canvas.width = 350; -const ctx = canvas.getContext('2d'); +const ctx = canvas.getContext("2d"); const x = canvas.width / 2; ctx.beginPath(); @@ -59,16 +59,16 @@ ctx.moveTo(x, 0); ctx.lineTo(x, canvas.height); ctx.stroke(); -ctx.font = '30px serif'; +ctx.font = "30px serif"; -ctx.textAlign = 'left'; -ctx.fillText('left-aligned', x, 40); +ctx.textAlign = "left"; +ctx.fillText("left-aligned", x, 40); -ctx.textAlign = 'center'; -ctx.fillText('center-aligned', x, 85); +ctx.textAlign = "center"; +ctx.fillText("center-aligned", x, 85); -ctx.textAlign = 'right'; -ctx.fillText('right-aligned', x, 130); +ctx.textAlign = "right"; +ctx.fillText("right-aligned", x, 130); ``` #### 结果 diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/textbaseline/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/textbaseline/index.md index cc7ba60c81bd26..cdec2659e46dad 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/textbaseline/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/textbaseline/index.md @@ -49,12 +49,19 @@ ctx.textBaseline = "top" || "hanging" || "middle" || "alphabetic" || "ideographi #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); - -const baselines = ['top', 'hanging', 'middle', 'alphabetic', 'ideographic', 'bottom']; -ctx.font = '36px serif'; -ctx.strokeStyle = 'red'; +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); + +const baselines = [ + "top", + "hanging", + "middle", + "alphabetic", + "ideographic", + "bottom", +]; +ctx.font = "36px serif"; +ctx.strokeStyle = "red"; baselines.forEach((baseline, index) => { ctx.textBaseline = baseline; diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/translate/index.md b/files/zh-cn/web/api/canvasrenderingcontext2d/translate/index.md index 420549562a6bb9..2983eec4a7807a 100644 --- a/files/zh-cn/web/api/canvasrenderingcontext2d/translate/index.md +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/translate/index.md @@ -39,19 +39,19 @@ void ctx.translate(x, y); #### JavaScript ```js -const canvas = document.getElementById('canvas'); -const ctx = canvas.getContext('2d'); +const canvas = document.getElementById("canvas"); +const ctx = canvas.getContext("2d"); // Moved square ctx.translate(110, 30); -ctx.fillStyle = 'red'; +ctx.fillStyle = "red"; ctx.fillRect(0, 0, 80, 80); // Reset current transformation matrix to the identity matrix ctx.setTransform(1, 0, 0, 1, 0, 0); // Unmoved square -ctx.fillStyle = 'gray'; +ctx.fillStyle = "gray"; ctx.fillRect(0, 0, 80, 80); ``` diff --git a/files/zh-cn/web/api/channel_messaging_api/using_channel_messaging/index.md b/files/zh-cn/web/api/channel_messaging_api/using_channel_messaging/index.md index 92baa8a9c231d4..5cac2ad10f634d 100644 --- a/files/zh-cn/web/api/channel_messaging_api/using_channel_messaging/index.md +++ b/files/zh-cn/web/api/channel_messaging_api/using_channel_messaging/index.md @@ -34,10 +34,10 @@ Channel messaging 在这样的场景中特别有用:假如你有一个社交 在例子的主页面,我们有一个简单的表单,内含一个文本输入框,用来输入要发送到 {{htmlelement("iframe")}} 的消息。我们还有一个段落,我们在稍后将会用它来显示 {{htmlelement("iframe")}} 回传回来的确认消息。 ```js -var input = document.getElementById('message-input'); -var output = document.getElementById('message-output'); -var button = document.querySelector('button'); -var iframe = document.querySelector('iframe'); +var input = document.getElementById("message-input"); +var output = document.getElementById("message-output"); +var button = document.querySelector("button"); +var iframe = document.querySelector("iframe"); var channel = new MessageChannel(); var port1 = channel.port1; @@ -47,13 +47,13 @@ iframe.addEventListener("load", onLoad); function onLoad() { // 监听按钮点击 - button.addEventListener('click', onClick); + button.addEventListener("click", onClick); // 在 port1 监听消息 port1.onmessage = onMessage; // 把 port2 传给 iframe - iframe.contentWindow.postMessage('init', '*', [channel.port2]); + iframe.contentWindow.postMessage("init", "*", [channel.port2]); } // 当按钮点击时,在 port1 上发送一个消息 @@ -65,7 +65,7 @@ function onClick(e) { // 处理 port1 收到的消息 function onMessage(e) { output.innerHTML = e.data; - input.value = ''; + input.value = ""; } ``` @@ -86,11 +86,11 @@ function onMessage(e) { 在 IFrame 里,我们有下面的 JavaScript: ```js -var list = document.querySelector('ul'); +var list = document.querySelector("ul"); var port2; // 监听初始的 port 传递消息 -window.addEventListener('message', initPort); +window.addEventListener("message", initPort); // 设置传过来的 port function initPort(e) { @@ -100,7 +100,7 @@ function initPort(e) { // 处理 port2 收到的消息 function onMessage(e) { - var listItem = document.createElement('li'); + var listItem = document.createElement("li"); listItem.textContent = e.data; list.appendChild(listItem); port2.postMessage('Message received by IFrame: "' + e.data + '"'); @@ -121,7 +121,7 @@ function onMessage(e) { // 处理 port1 上收到的消息 function onMessage(e) { output.innerHTML = e.data; - input.value = ''; + input.value = ""; } ``` diff --git a/files/zh-cn/web/api/channelmergernode/channelmergernode/index.md b/files/zh-cn/web/api/channelmergernode/channelmergernode/index.md index c74eebe5ed97f4..40225385dcc793 100644 --- a/files/zh-cn/web/api/channelmergernode/channelmergernode/index.md +++ b/files/zh-cn/web/api/channelmergernode/channelmergernode/index.md @@ -35,8 +35,8 @@ _从字典_ _{{domxref("AudioNodeOptions")}} 继承。_ var ac = new AudioContext(); var options = { - numberOfInputs : 2 -} + numberOfInputs: 2, +}; var myMerger = new ChannelMergerNode(ac, options); ``` diff --git a/files/zh-cn/web/api/cleartimeout/index.md b/files/zh-cn/web/api/cleartimeout/index.md index 3b11e3a57d8277..d76f69286f4620 100644 --- a/files/zh-cn/web/api/cleartimeout/index.md +++ b/files/zh-cn/web/api/cleartimeout/index.md @@ -26,25 +26,33 @@ scope.clearTimeout(timeoutID) ```js var alarm = { - remind: function(aMessage) { + remind: function (aMessage) { alert(aMessage); delete this.timeoutID; }, - setup: function() { + setup: function () { this.cancel(); var self = this; - this.timeoutID = window.setTimeout(function(msg) {self.remind(msg);}, 1000, "Wake up!"); + this.timeoutID = window.setTimeout( + function (msg) { + self.remind(msg); + }, + 1000, + "Wake up!", + ); }, - cancel: function() { - if(typeof this.timeoutID == "number") { + cancel: function () { + if (typeof this.timeoutID == "number") { window.clearTimeout(this.timeoutID); delete this.timeoutID; } - } + }, +}; +window.onclick = function () { + alarm.setup(); }; -window.onclick = function() { alarm.setup() }; ``` ## 注意 diff --git a/files/zh-cn/web/api/client/postmessage/index.md b/files/zh-cn/web/api/client/postmessage/index.md index 8c0b260c76ee67..977a228525f21b 100644 --- a/files/zh-cn/web/api/client/postmessage/index.md +++ b/files/zh-cn/web/api/client/postmessage/index.md @@ -29,32 +29,33 @@ Void. 从 service worker 向 client 发送消息: ```js -addEventListener('fetch', event => { - event.waitUntil(async function() { - // Exit early if we don't have access to the client. - // Eg, if it's cross-origin. - if (!event.clientId) return; - - // Get the client. - const client = await clients.get(event.clientId); - // Exit early if we don't get the client. - // Eg, if it closed. - if (!client) return; - - // Send a message to the client. - client.postMessage({ - msg: "Hey I just got a fetch from you!", - url: event.request.url - }); - - }()); +addEventListener("fetch", (event) => { + event.waitUntil( + (async function () { + // Exit early if we don't have access to the client. + // Eg, if it's cross-origin. + if (!event.clientId) return; + + // Get the client. + const client = await clients.get(event.clientId); + // Exit early if we don't get the client. + // Eg, if it closed. + if (!client) return; + + // Send a message to the client. + client.postMessage({ + msg: "Hey I just got a fetch from you!", + url: event.request.url, + }); + })(), + ); }); ``` 接收 message: ```js -navigator.serviceWorker.addEventListener('message', event => { +navigator.serviceWorker.addEventListener("message", (event) => { console.log(event.data.msg, event.data.url); }); ``` diff --git a/files/zh-cn/web/api/clients/claim/index.md b/files/zh-cn/web/api/clients/claim/index.md index 7f6f48fe19a3f9..2340bbc9e12650 100644 --- a/files/zh-cn/web/api/clients/claim/index.md +++ b/files/zh-cn/web/api/clients/claim/index.md @@ -28,7 +28,7 @@ A {{jsxref("Promise")}} for `void`. The following example uses `claim()` inside service worker's "`activate`" event listener so that clients loaded in the same scope do not need to be reloaded before their fetches will go through this service worker. ```js -self.addEventListener('activate', event => { +self.addEventListener("activate", (event) => { event.waitUntil(clients.claim()); }); ``` diff --git a/files/zh-cn/web/api/clients/get/index.md b/files/zh-cn/web/api/clients/get/index.md index 19135090ddc946..66913eb6fb5072 100644 --- a/files/zh-cn/web/api/clients/get/index.md +++ b/files/zh-cn/web/api/clients/get/index.md @@ -10,7 +10,7 @@ slug: Web/API/Clients/get ## 语法 ```js -self.clients.get(id).then(function(client) { +self.clients.get(id).then(function (client) { // do something with your returned client }); ``` @@ -27,7 +27,7 @@ self.clients.get(id).then(function(client) { ## 示例 ```js -self.clients.get(options).then(function(client) { +self.clients.get(options).then(function (client) { self.clients.openWindow(client.url); }); ``` diff --git a/files/zh-cn/web/api/clients/index.md b/files/zh-cn/web/api/clients/index.md index aaba90ab4312ca..5d202e24f3f2a2 100644 --- a/files/zh-cn/web/api/clients/index.md +++ b/files/zh-cn/web/api/clients/index.md @@ -23,35 +23,37 @@ slug: Web/API/Clients 下面示例显示一个已有的聊天窗口,或者当用户点击通知时创建新的窗口。 ```js -addEventListener('notificationclick', event => { - event.waitUntil(async function() { - const allClients = await clients.matchAll({ - includeUncontrolled: true - }); - - let chatClient; - - // Let's see if we already have a chat window open: - for (const client of allClients) { - const url = new URL(client.url); - - if (url.pathname == '/chat/') { - // Excellent, let's use it! - client.focus(); - chatClient = client; - break; +addEventListener("notificationclick", (event) => { + event.waitUntil( + (async function () { + const allClients = await clients.matchAll({ + includeUncontrolled: true, + }); + + let chatClient; + + // Let's see if we already have a chat window open: + for (const client of allClients) { + const url = new URL(client.url); + + if (url.pathname == "/chat/") { + // Excellent, let's use it! + client.focus(); + chatClient = client; + break; + } } - } - // If we didn't find an existing chat window, - // open a new one: - if (!chatClient) { - chatClient = await clients.openWindow('/chat/'); - } + // If we didn't find an existing chat window, + // open a new one: + if (!chatClient) { + chatClient = await clients.openWindow("/chat/"); + } - // Message the client: - chatClient.postMessage("New chat messages!"); - }()); + // Message the client: + chatClient.postMessage("New chat messages!"); + })(), + ); }); ``` diff --git a/files/zh-cn/web/api/clients/matchall/index.md b/files/zh-cn/web/api/clients/matchall/index.md index df0f5f56a2e062..6b89827593154a 100644 --- a/files/zh-cn/web/api/clients/matchall/index.md +++ b/files/zh-cn/web/api/clients/matchall/index.md @@ -10,7 +10,7 @@ slug: Web/API/Clients/matchAll ## 语法 ```js -ServiceWorkerClients.matchAll(options).then(function(clients) { +ServiceWorkerClients.matchAll(options).then(function (clients) { // do something with your clients list }); ``` @@ -31,9 +31,9 @@ resolve 为一个 {{domxref("Client")}} 对象数组的 [`Promise`](/zh-CN/docs/ ## 示例 ```js -clients.matchAll(options).then(function(clientList) { - for (var i = 0 ; i < clients.length ; i++) { - if (clientList[i].url === 'index.html') { +clients.matchAll(options).then(function (clientList) { + for (var i = 0; i < clients.length; i++) { + if (clientList[i].url === "index.html") { clients.openWindow(clientList[i]); // or do something else involving the matching client } diff --git a/files/zh-cn/web/api/clients/openwindow/index.md b/files/zh-cn/web/api/clients/openwindow/index.md index 92064e56ec04b9..ae694b2f214e2f 100644 --- a/files/zh-cn/web/api/clients/openwindow/index.md +++ b/files/zh-cn/web/api/clients/openwindow/index.md @@ -14,7 +14,7 @@ slug: Web/API/Clients/openWindow ## 语法 ```js -ServiceWorkerClients.openWindow(url).then(function(WindowClient) { +ServiceWorkerClients.openWindow(url).then(function (WindowClient) { // do something with your WindowClient }); ``` @@ -33,9 +33,9 @@ ServiceWorkerClients.openWindow(url).then(function(WindowClient) { ```js // When the user clicks a notification focus the window if it exists or open // a new one otherwise. -onotificationclick = function(event) { +onotificationclick = function (event) { var found = false; - clients.matchAll().then(function(clientsArr) { + clients.matchAll().then(function (clientsArr) { for (i = 0; i < clientsArr.length; i++) { if (clientsArr[i].url === event.data.url) { // We already have a window to use, focus it. @@ -46,7 +46,7 @@ onotificationclick = function(event) { } if (!found) { // Create a new window. - clients.openWindow(event.data.url).then(function(windowClient) { + clients.openWindow(event.data.url).then(function (windowClient) { // do something with the windowClient. }); } diff --git a/files/zh-cn/web/api/clipboard/index.md b/files/zh-cn/web/api/clipboard/index.md index 33277883036746..a7ab2b349ccd2c 100644 --- a/files/zh-cn/web/api/clipboard/index.md +++ b/files/zh-cn/web/api/clipboard/index.md @@ -23,7 +23,7 @@ slug: Web/API/Clipboard ## 方法 -*`Clipboard` 继承自 {{domxref("EventTarget")}} 接口,因此拥有它的方法。* +_`Clipboard` 继承自 {{domxref("EventTarget")}} 接口,因此拥有它的方法。_ - {{domxref("Clipboard.read()","read()")}} - : 从剪贴板读取数据(比如图片),返回一个 {{jsxref("Promise")}} 对象。在检索到数据后,promise 将兑现一个 {{domxref("ClipboardItem")}} 对象的数组来提供剪切板数据。 diff --git a/files/zh-cn/web/api/clipboard/read/index.md b/files/zh-cn/web/api/clipboard/read/index.md index 9bc7bc42b97f1f..9e33ef113b98e7 100644 --- a/files/zh-cn/web/api/clipboard/read/index.md +++ b/files/zh-cn/web/api/clipboard/read/index.md @@ -33,13 +33,13 @@ After using {{domxref("Permissions.query", "navigator.permissions.query()")}} to // First, ask the Permissions API if we have some kind of access to // the "clipboard-read" feature. -navigator.permissions.query({name: "clipboard-read"}).then(result => { +navigator.permissions.query({ name: "clipboard-read" }).then((result) => { // If permission to read the clipboard is granted or if the user will // be prompted to allow it, we proceed. if (result.state == "granted" || result.state == "prompt") { - navigator.clipboard.read().then(data => { - for (let i=0; i { + for (let i = 0; i < data.items.length; i++) { if (data.items[i].type != "text/plain") { alert("Clipboard contains non-text data. Unable to access it."); } else { diff --git a/files/zh-cn/web/api/clipboard/readtext/index.md b/files/zh-cn/web/api/clipboard/readtext/index.md index 701c672f224ca2..dda2be6e248057 100644 --- a/files/zh-cn/web/api/clipboard/readtext/index.md +++ b/files/zh-cn/web/api/clipboard/readtext/index.md @@ -28,8 +28,9 @@ A {{jsxref("Promise")}} that resolves with a {{domxref("DOMString")}} containing 此示例检索剪贴板的文本内容,并将返回的文本插入元素的内容中。 ```js -navigator.clipboard.readText().then( - clipText => document.getElementById("outbox").innerText = clipText); +navigator.clipboard + .readText() + .then((clipText) => (document.getElementById("outbox").innerText = clipText)); ``` ## 规范 diff --git a/files/zh-cn/web/api/clipboard/write/index.md b/files/zh-cn/web/api/clipboard/write/index.md index 78ca3a5f4ea81a..3bc68cddb43f93 100644 --- a/files/zh-cn/web/api/clipboard/write/index.md +++ b/files/zh-cn/web/api/clipboard/write/index.md @@ -35,11 +35,14 @@ function setClipboard(text) { let data = new DataTransfer(); data.items.add("text/plain", text); - navigator.clipboard.write(data).then(function() { - /* success */ - }, function() { - /* failure */ - }); + navigator.clipboard.write(data).then( + function () { + /* success */ + }, + function () { + /* failure */ + }, + ); } ``` diff --git a/files/zh-cn/web/api/clipboard/writetext/index.md b/files/zh-cn/web/api/clipboard/writetext/index.md index b93ce9cb058ad2..95b9b9bf9a9eb3 100644 --- a/files/zh-cn/web/api/clipboard/writetext/index.md +++ b/files/zh-cn/web/api/clipboard/writetext/index.md @@ -29,11 +29,14 @@ var promise = navigator.clipboard.writeText(newClipText) 此示例将剪贴板的内容设置为字符串“\”。 ```js -navigator.clipboard.writeText("").then(function() { - /* clipboard successfully set */ -}, function() { - /* clipboard write failed */ -}); +navigator.clipboard.writeText("").then( + function () { + /* clipboard successfully set */ + }, + function () { + /* clipboard write failed */ + }, +); ``` ## 规范 diff --git a/files/zh-cn/web/api/clipboard_api/index.md b/files/zh-cn/web/api/clipboard_api/index.md index 3eb6ce0fdd2347..be729c2e97d6b8 100644 --- a/files/zh-cn/web/api/clipboard_api/index.md +++ b/files/zh-cn/web/api/clipboard_api/index.md @@ -14,8 +14,11 @@ slug: Web/API/Clipboard_API 除了在实例化中创建一个 `Clipboard` 对象,你还可以使用全局的 {{domxref("Navigator.clipboard")}} 来访问系统剪贴板。 ```js -navigator.clipboard.readText().then( - clipText => document.querySelector(".editor").innerText += clipText); +navigator.clipboard + .readText() + .then( + (clipText) => (document.querySelector(".editor").innerText += clipText), + ); ``` 上述代码提取了剪贴板的文本并将其附在 class 为 `editor` 的第一个元素后面。因为当剪贴板中不是文本时, {{domxref("Clipboard.readText", "readText()")}} (and {{domxref("Clipboard.read", "read()")}}, for that matter) 会返回一个空字符串,所以这段代码是安全的。 diff --git a/files/zh-cn/web/api/clipboarditem/index.md b/files/zh-cn/web/api/clipboarditem/index.md index 230ba714d86139..ee13098c4d47a3 100644 --- a/files/zh-cn/web/api/clipboarditem/index.md +++ b/files/zh-cn/web/api/clipboarditem/index.md @@ -43,17 +43,17 @@ Here we're writing a new {{domxref("ClipboardItem.ClipboardItem()")}} to the {{d ```js async function writeClipImg() { try { - const imgURL = '/myimage.png'; + const imgURL = "/myimage.png"; const data = await fetch(imgURL); const blob = await data.blob(); await navigator.clipboard.write([ new ClipboardItem({ - [blob.type]: blob - }) + [blob.type]: blob, + }), ]); - console.log('Fetched image copied.'); - } catch(err) { + console.log("Fetched image copied."); + } catch (err) { console.error(err.name, err.message); } } @@ -69,14 +69,11 @@ async function getClipboardContents() { const clipboardItems = await navigator.clipboard.read(); for (const clipboardItem of clipboardItems) { - for (const type of clipboardItem.types) { const blob = await clipboardItem.getType(type); // we can now use blob here } - } - } catch (err) { console.error(err.name, err.message); } diff --git a/files/zh-cn/web/api/compression_streams_api/index.md b/files/zh-cn/web/api/compression_streams_api/index.md index 3b55b1fa62cac8..5657ee261a2fd5 100644 --- a/files/zh-cn/web/api/compression_streams_api/index.md +++ b/files/zh-cn/web/api/compression_streams_api/index.md @@ -22,7 +22,7 @@ slug: Web/API/Compression_Streams_API ```js const compressedReadableStream = inputReadableStream.pipeThrough( - new CompressionStream("gzip") + new CompressionStream("gzip"), ); ``` diff --git a/files/zh-cn/web/api/compressionstream/compressionstream/index.md b/files/zh-cn/web/api/compressionstream/compressionstream/index.md index c295169fde6134..2ec1a5a0abdb1b 100644 --- a/files/zh-cn/web/api/compressionstream/compressionstream/index.md +++ b/files/zh-cn/web/api/compressionstream/compressionstream/index.md @@ -34,7 +34,7 @@ new CompressionStream(format) ```js const compressedReadableStream = inputReadableStream.pipeThrough( - new CompressionStream("gzip") + new CompressionStream("gzip"), ); ``` diff --git a/files/zh-cn/web/api/compressionstream/index.md b/files/zh-cn/web/api/compressionstream/index.md index 2f0f0521aa02f1..0e135ef1f17ea1 100644 --- a/files/zh-cn/web/api/compressionstream/index.md +++ b/files/zh-cn/web/api/compressionstream/index.md @@ -25,7 +25,7 @@ slug: Web/API/CompressionStream ```js const compressedReadableStream = inputReadableStream.pipeThrough( - new CompressionStream("gzip") + new CompressionStream("gzip"), ); ``` diff --git a/files/zh-cn/web/api/console/assert/index.md b/files/zh-cn/web/api/console/assert/index.md index 2074a22463f07b..aef5c0a50227e8 100644 --- a/files/zh-cn/web/api/console/assert/index.md +++ b/files/zh-cn/web/api/console/assert/index.md @@ -34,12 +34,12 @@ console.assert(assertion, msg [, subst1, ..., substN]); // c-like message format 下面的代码示例演示了 JavaScript 对象的使用: ```js -const errorMsg = 'the # is not even'; +const errorMsg = "the # is not even"; for (let number = 2; number <= 5; number += 1) { - console.log('the # is ' + number); - console.assert(number % 2 === 0, {number: number, errorMsg: errorMsg}); - // 或者使用 ES2015 对象简写: - // console.assert(number % 2 === 0, {number, errorMsg}); + console.log("the # is " + number); + console.assert(number % 2 === 0, { number: number, errorMsg: errorMsg }); + // 或者使用 ES2015 对象简写: + // console.assert(number % 2 === 0, {number, errorMsg}); } // 输出: // the # is 2 @@ -53,14 +53,14 @@ for (let number = 2; number <= 5; number += 1) { 请注意,你可以在大多数浏览器中使用 console.log 进行格式化输出 ```js -console.log('the word is %s try number %d', 'foo', 123); +console.log("the word is %s try number %d", "foo", 123); // 输出:the word is foo try number 123 ``` `但是 console.assert` 在不同浏览器中可能获得不同的效果: ```js -console.assert(false, 'the word is %s', 'foo'); +console.assert(false, "the word is %s", "foo"); // correct output in Node (e.g. v8.10.0) and some browsers // (e.g. Firefox v60.0.2): // Assertion failed: the word is foo diff --git a/files/zh-cn/web/api/console/index.md b/files/zh-cn/web/api/console/index.md index b048aa6558f69f..a1d761035e7278 100644 --- a/files/zh-cn/web/api/console/index.md +++ b/files/zh-cn/web/api/console/index.md @@ -10,7 +10,7 @@ slug: Web/API/console `Console` 对象可以从任何全局对象中访问到,如 浏览器作用域上的 {{domxref("Window")}},以及通过属性控制台作为 workers 中的特定变体的 {{domxref("WorkerGlobalScope")}}。可以通过 {{domxref("Window.console")}} 引用,也可以简单的通过 `console` 引用。例: ```js -console.log("Failed to open the specified link") +console.log("Failed to open the specified link"); ``` 本页面记录了 `Console` 对象上的[方法](#方法)并给出了几个 [Usage](#usage) (用例)。 @@ -143,7 +143,10 @@ for (var i=0; i<5; i++) { 可以使用 `%c` 为打印内容定义样式: ```js -console.log("This is %cMy stylish message", "color: yellow; font-style: italic; background-color: blue;padding: 2px"); +console.log( + "This is %cMy stylish message", + "color: yellow; font-style: italic; background-color: blue;padding: 2px", +); ``` 指令前的文本不会受到影响,但指令后的文本将会使用参数中声明的 CSS 样式。![](css-styling.png) diff --git a/files/zh-cn/web/api/console/log/index.md b/files/zh-cn/web/api/console/log/index.md index 769e696482dc77..b14dd46ac23657 100644 --- a/files/zh-cn/web/api/console/log/index.md +++ b/files/zh-cn/web/api/console/log/index.md @@ -5,7 +5,7 @@ slug: Web/API/console/log {{APIRef("Console API")}} - **`console.log()`** 方法向 Web 控制台输出一条信息。这条信息可能是单个字符串(包括可选的替代字符串),也可能是一个或多个对象。 +**`console.log()`** 方法向 Web 控制台输出一条信息。这条信息可能是单个字符串(包括可选的替代字符串),也可能是一个或多个对象。 {{AvailableInWorkers}} diff --git a/files/zh-cn/web/api/console/table/index.md b/files/zh-cn/web/api/console/table/index.md index 7ce0c825826b70..cef454ea915019 100644 --- a/files/zh-cn/web/api/console/table/index.md +++ b/files/zh-cn/web/api/console/table/index.md @@ -49,7 +49,11 @@ console.table(me); ```js // 二元数组的打印 -var people = [["John", "Smith"], ["Jane", "Doe"], ["Emily", "Jones"]] +var people = [ + ["John", "Smith"], + ["Jane", "Doe"], + ["Emily", "Jones"], +]; console.table(people); ``` diff --git a/files/zh-cn/web/api/console_api/index.md b/files/zh-cn/web/api/console_api/index.md index 3956c782c0ccf4..6a58bf346e3482 100644 --- a/files/zh-cn/web/api/console_api/index.md +++ b/files/zh-cn/web/api/console_api/index.md @@ -26,10 +26,10 @@ Console API 最初是一个专有的 API,不同的浏览器以自己的实现 ## 示例 ```js -let myString = 'Hello world'; +let myString = "Hello world"; // Output "Hello world" to the console -console.log(myString) +console.log(myString); ``` 到[Console reference page](/zh-CN/docs/Web/API/Console#Usage)查看更多示例 diff --git a/files/zh-cn/web/api/contentvisibilityautostatechangeevent/index.md b/files/zh-cn/web/api/contentvisibilityautostatechangeevent/index.md index 5299eb03fb0fa0..7a0cecc590ef24 100644 --- a/files/zh-cn/web/api/contentvisibilityautostatechangeevent/index.md +++ b/files/zh-cn/web/api/contentvisibilityautostatechangeevent/index.md @@ -20,7 +20,7 @@ slug: Web/API/ContentVisibilityAutoStateChangeEvent ## 实例属性 -*从其父接口 {{DOMxRef("Event")}} 继承属性。* +_从其父接口 {{DOMxRef("Event")}} 继承属性。_ - {{domxref("ContentVisibilityAutoStateChangeEvent.skipped", "skipped")}} {{ReadOnlyInline}} - : 如果用户代理正在跳过元素的渲染则返回 `true`,否则返回 `false`。 @@ -28,9 +28,9 @@ slug: Web/API/ContentVisibilityAutoStateChangeEvent ## 示例 ```js -const canvasElem = document.querySelector('canvas'); +const canvasElem = document.querySelector("canvas"); -canvasElem.addEventListener('contentvisibilityautostatechange', stateChanged); +canvasElem.addEventListener("contentvisibilityautostatechange", stateChanged); canvasElem.style.contentVisibility = "auto"; function stateChanged(event) { diff --git a/files/zh-cn/web/api/countqueuingstrategy/countqueuingstrategy/index.md b/files/zh-cn/web/api/countqueuingstrategy/countqueuingstrategy/index.md index 8322374d5df7c6..5c53adec806e1e 100644 --- a/files/zh-cn/web/api/countqueuingstrategy/countqueuingstrategy/index.md +++ b/files/zh-cn/web/api/countqueuingstrategy/countqueuingstrategy/index.md @@ -9,7 +9,7 @@ slug: Web/API/CountQueuingStrategy/CountQueuingStrategy ## 语法 -```js +```js-nolint new CountQueuingStrategy(highWaterMark) ``` @@ -31,18 +31,21 @@ new CountQueuingStrategy(highWaterMark) ```js const queuingStrategy = new CountQueuingStrategy({ highWaterMark: 1 }); -const writableStream = new WritableStream({ - // Implement the sink - write(chunk) { - // … - }, - close() { - // … +const writableStream = new WritableStream( + { + // Implement the sink + write(chunk) { + // … + }, + close() { + // … + }, + abort(err) { + console.log("Sink error:", err); + }, }, - abort(err) { - console.log("Sink error:", err); - } -}, queuingStrategy); + queuingStrategy, +); const size = queuingStrategy.size(); ``` diff --git a/files/zh-cn/web/api/countqueuingstrategy/highwatermark/index.md b/files/zh-cn/web/api/countqueuingstrategy/highwatermark/index.md index e19047864ca2fe..12b764a631adfa 100644 --- a/files/zh-cn/web/api/countqueuingstrategy/highwatermark/index.md +++ b/files/zh-cn/web/api/countqueuingstrategy/highwatermark/index.md @@ -28,7 +28,7 @@ const readableStream = new ReadableStream( console.log("stream error:", err); }, }, - queuingStrategy + queuingStrategy, ); const size = queuingStrategy.size(chunk); diff --git a/files/zh-cn/web/api/countqueuingstrategy/index.md b/files/zh-cn/web/api/countqueuingstrategy/index.md index 6fdd2339c4d086..4e8d51bca011d1 100644 --- a/files/zh-cn/web/api/countqueuingstrategy/index.md +++ b/files/zh-cn/web/api/countqueuingstrategy/index.md @@ -27,18 +27,21 @@ slug: Web/API/CountQueuingStrategy ```js const queueingStrategy = new CountQueuingStrategy({ highWaterMark: 1 }); -const writableStream = new WritableStream({ - // Implement the sink - write(chunk) { - // … +const writableStream = new WritableStream( + { + // Implement the sink + write(chunk) { + // … + }, + close() { + // … + }, + abort(err) { + console.log("Sink error:", err); + }, }, - close() { - // … - }, - abort(err) { - console.log("Sink error:", err); - } -}, queueingStrategy); + queueingStrategy, +); const size = queueingStrategy.size(); ``` diff --git a/files/zh-cn/web/api/countqueuingstrategy/size/index.md b/files/zh-cn/web/api/countqueuingstrategy/size/index.md index 818f98ff56e885..61a9086a8336aa 100644 --- a/files/zh-cn/web/api/countqueuingstrategy/size/index.md +++ b/files/zh-cn/web/api/countqueuingstrategy/size/index.md @@ -9,7 +9,7 @@ slug: Web/API/CountQueuingStrategy/size ## 语法 -```js +```js-nolint size() ``` @@ -26,18 +26,21 @@ size() ```js const queuingStrategy = new CountQueuingStrategy({ highWaterMark: 1 }); -const writableStream = new WritableStream({ - // Implement the sink - write(chunk) { - // … - }, - close() { - // … +const writableStream = new WritableStream( + { + // Implement the sink + write(chunk) { + // … + }, + close() { + // … + }, + abort(err) { + console.log("Sink error:", err); + }, }, - abort(err) { - console.log("Sink error:", err); - } -}, queuingStrategy); + queuingStrategy, +); const size = queuingStrategy.size(); ``` diff --git a/files/zh-cn/web/api/createimagebitmap/index.md b/files/zh-cn/web/api/createimagebitmap/index.md index f1f8f455cc781c..397b7ed02c46f3 100644 --- a/files/zh-cn/web/api/createimagebitmap/index.md +++ b/files/zh-cn/web/api/createimagebitmap/index.md @@ -44,21 +44,21 @@ createImageBitmap(image, sx, sy, sw, sh[, options]).then(function(response) { .. ## Example ```js -var canvas = document.getElementById('myCanvas'), -ctx = canvas.getContext('2d'), -image = new Image(); +var canvas = document.getElementById("myCanvas"), + ctx = canvas.getContext("2d"), + image = new Image(); -image.onload = function() { +image.onload = function () { Promise.all([ createImageBitmap(this, 0, 0, 32, 32), - createImageBitmap(this, 32, 0, 32, 32) - ]).then(function(sprites) { + createImageBitmap(this, 32, 0, 32, 32), + ]).then(function (sprites) { ctx.drawImage(sprites[0], 0, 0); ctx.drawImage(sprites[1], 32, 32); }); -} +}; -image.src = 'sprites.png'; +image.src = "sprites.png"; ``` ## Specifications diff --git a/files/zh-cn/web/api/crossoriginisolated/index.md b/files/zh-cn/web/api/crossoriginisolated/index.md index a707f61b18b505..4d33121291f379 100644 --- a/files/zh-cn/web/api/crossoriginisolated/index.md +++ b/files/zh-cn/web/api/crossoriginisolated/index.md @@ -22,7 +22,7 @@ var myCrossOriginIsolated = self.crossOriginIsolated; // 或直接 crossOriginIs ## 示例 ```js -if(crossOriginIsolated) { +if (crossOriginIsolated) { // post SharedArrayBuffer } else { // Do something else diff --git a/files/zh-cn/web/api/crypto/getrandomvalues/index.md b/files/zh-cn/web/api/crypto/getrandomvalues/index.md index a057cf8b5a69f8..60b09aea8fb252 100644 --- a/files/zh-cn/web/api/crypto/getrandomvalues/index.md +++ b/files/zh-cn/web/api/crypto/getrandomvalues/index.md @@ -35,7 +35,7 @@ window.crypto.getRandomValues(array); console.log("Your lucky numbers:"); for (var i = 0; i < array.length; i++) { - console.log(array[i]); + console.log(array[i]); } ``` diff --git a/files/zh-cn/web/api/crypto_property/index.md b/files/zh-cn/web/api/crypto_property/index.md index daeb0683590c89..6961a8db1b778a 100644 --- a/files/zh-cn/web/api/crypto_property/index.md +++ b/files/zh-cn/web/api/crypto_property/index.md @@ -35,9 +35,7 @@ globalThis.genRandomNumbers = () => { ```html

随机数为:

- + ``` ### 结果 diff --git a/files/zh-cn/web/api/cryptokey/index.md b/files/zh-cn/web/api/cryptokey/index.md index c8893273a49078..c77a8dce12e1c1 100644 --- a/files/zh-cn/web/api/cryptokey/index.md +++ b/files/zh-cn/web/api/cryptokey/index.md @@ -12,6 +12,7 @@ slug: Web/API/CryptoKey ## 实例属性 - `CryptoKey.type` + - : 返回一个表示密钥类型的字符串,可使用以下值: - `"secret"`:为密钥(secret key),用于{{Glossary("Symmetric-key cryptography", "对称加密算法")}}。 @@ -19,12 +20,14 @@ slug: Web/API/CryptoKey - `"public"`:为{{Glossary("Public-key cryptography", "非对称加密算法")}}的 [`CryptoKeyPair`](/zh-CN/docs/Web/API/CryptoKeyPair) 的公钥(public key)部分。 - `CryptoKey.extractable` + - : 一个布尔值,表示原始信息是否能使用 [`SubtleCrypto.exportKey()`](/zh-CN/docs/Web/API/SubtleCrypto/exportKey) 或 [`SubtleCrypto.wrapKey()`](/zh-CN/docs/Web/API/SubtleCrypto/wrapKey) 导出。 - `true`:密钥可以导出。 - `false`:密钥不能导出。使用 [`exportKey()`](/zh-CN/docs/Web/API/SubtleCrypto/exportKey) 或 [`wrapKey()`](/zh-CN/docs/Web/API/SubtleCrypto/wrapKey) 方法来导出此密钥将会抛出异常。 - `CryptoKey.algorithm` + - : 一个描述可使用此密钥的算法及任何关联的额外参数的对象。 - [`AesKeyGenParams`](/zh-CN/docs/Web/API/AesKeyGenParams) 如果算法是任意高级加密标准(AES)的变体。 @@ -33,6 +36,7 @@ slug: Web/API/CryptoKey - [`HmacKeyGenParams`](/zh-CN/docs/Web/API/HmacKeyGenParams) 如果算法是任意密钥散列消息认证码(HMAC)的变体。 - `CryptoKey.usages` + - : 一个字符串的{{jsxref("Array", "数组", "", 1)}},指明密钥的用途。数组元素可能的值有: - `"encrypt"`:密钥可用于{{domxref("SubtleCrypto.encrypt()", "加密", "", 1)}}消息。 diff --git a/files/zh-cn/web/api/css/escape_static/index.md b/files/zh-cn/web/api/css/escape_static/index.md index 3ee66eb42db2d9..c600bfe15173bc 100644 --- a/files/zh-cn/web/api/css/escape_static/index.md +++ b/files/zh-cn/web/api/css/escape_static/index.md @@ -24,11 +24,11 @@ escapedStr = CSS.escape(str); ### 基本结果 ```js -CSS.escape(".foo#bar") // "\.foo\#bar" -CSS.escape("()[]{}") // "\(\)\[\]\\{\\}" -CSS.escape('--a') // "--a" -CSS.escape(0) // "\30 ", Unicode 代码点“0”是 30 -CSS.escape('\0') // "\ufffd", Unicode 替换字符 +CSS.escape(".foo#bar"); // "\.foo\#bar" +CSS.escape("()[]{}"); // "\(\)\[\]\\{\\}" +CSS.escape("--a"); // "--a" +CSS.escape(0); // "\30 ", Unicode 代码点“0”是 30 +CSS.escape("\0"); // "\ufffd", Unicode 替换字符 ``` ### 在上下文使用 @@ -36,7 +36,7 @@ CSS.escape('\0') // "\ufffd", Unicode 替换字符 要转义一个字符串作为选择器使用, `escape()`方法可以用于: ```js -var element = document.querySelector('#' + CSS.escape(id) + ' > img'); +var element = document.querySelector("#" + CSS.escape(id) + " > img"); ``` `escape()`方法也可以用于转义字符串,它也转义了不严格需要转义的字符: diff --git a/files/zh-cn/web/api/css/factory_functions_static/index.md b/files/zh-cn/web/api/css/factory_functions_static/index.md index 71cfd02a300370..968c628c38c9af 100644 --- a/files/zh-cn/web/api/css/factory_functions_static/index.md +++ b/files/zh-cn/web/api/css/factory_functions_static/index.md @@ -64,16 +64,16 @@ CSS.fr(number); ```js let height = CSS.vmax(50); -console.log( height ); // CSSUnitValue {value: 50, unit: "vmax"} -console.log( height.value ) // 50 -console.log( height.unit ) // vmax +console.log(height); // CSSUnitValue {value: 50, unit: "vmax"} +console.log(height.value); // 50 +console.log(height.unit); // vmax ``` 在这个例子中,我们给元素设定 margin 属性值,使用 `CSS.px()` 函数: ```js -myElement.attributeStyleMap.set('margin', CSS.px(40)); -let currentMargin = myElement.attributeStyleMap.get('margin'); +myElement.attributeStyleMap.set("margin", CSS.px(40)); +let currentMargin = myElement.attributeStyleMap.get("margin"); console.log(currentMargin.value, currentMargin.unit); // 40, 'px' ``` diff --git a/files/zh-cn/web/api/css/supports_static/index.md b/files/zh-cn/web/api/css/supports_static/index.md index 335f05c2815d0b..1fbda172fffcb3 100644 --- a/files/zh-cn/web/api/css/supports_static/index.md +++ b/files/zh-cn/web/api/css/supports_static/index.md @@ -34,11 +34,13 @@ boolValue = CSS.supports(supportCondition); ```js result = CSS.supports("text-decoration-style", "blink"); result = CSS.supports("display", "flex"); -result = CSS.supports('--foo', 'red'); -result = CSS.supports('(--foo: red)'); +result = CSS.supports("--foo", "red"); +result = CSS.supports("(--foo: red)"); result = CSS.supports("( transform-origin: 5% 5% )"); -result = CSS.supports("( transform-style: preserve ) or ( -moz-transform-style: preserve ) or " + - "( -o-transform-style: preserve ) or ( -webkit-transform-style: preserve )" ); +result = CSS.supports( + "( transform-style: preserve ) or ( -moz-transform-style: preserve ) or " + + "( -o-transform-style: preserve ) or ( -webkit-transform-style: preserve )", +); //result is true or false ``` diff --git a/files/zh-cn/web/api/css_custom_highlight_api/index.md b/files/zh-cn/web/api/css_custom_highlight_api/index.md index 3ca8c9fb92a5e5..7288189969c6b1 100644 --- a/files/zh-cn/web/api/css_custom_highlight_api/index.md +++ b/files/zh-cn/web/api/css_custom_highlight_api/index.md @@ -109,25 +109,25 @@ CSS.highlights.clear(); 下面的 HTML 代码片段定义了一个搜索框和有几段文字的文章: ```html - +

Maxime debitis hic, delectus perspiciatis laborum molestiae labore, - deleniti, quam consequatur iure veniam alias voluptas nisi quo. - Dolorem eaque alias, quo vel quas repudiandae architecto deserunt - quidem, sapiente laudantium nulla. + deleniti, quam consequatur iure veniam alias voluptas nisi quo. Dolorem + eaque alias, quo vel quas repudiandae architecto deserunt quidem, sapiente + laudantium nulla.

- Maiores odit molestias, necessitatibus doloremque dolor illum - reprehenderit provident nostrum laboriosam iste, tempore perferendis! - Ab porro neque esse voluptas libero necessitatibus fugiat, ex, minus - atque deserunt veniam molestiae tempora? Vitae. + Maiores odit molestias, necessitatibus doloremque dolor illum reprehenderit + provident nostrum laboriosam iste, tempore perferendis! Ab porro neque esse + voluptas libero necessitatibus fugiat, ex, minus atque deserunt veniam + molestiae tempora? Vitae.

- Dolorum facilis voluptate eaque eius similique ducimus dignissimos - assumenda quos architecto. Doloremque deleniti non exercitationem - rerum quam alias harum, nisi obcaecati corporis temporibus vero sapiente - voluptatum est quibusdam id ipsa. + Dolorum facilis voluptate eaque eius similique ducimus dignissimos assumenda + quos architecto. Doloremque deleniti non exercitationem rerum quam alias + harum, nisi obcaecati corporis temporibus vero sapiente voluptatum est + quibusdam id ipsa.

``` @@ -159,7 +159,7 @@ query.addEventListener("input", () => { return; } - // Clear the HighlightRegistry to remove the + // Clear the HighlightRegistry to remove the // previous search results. CSS.highlights.clear(); @@ -185,7 +185,7 @@ query.addEventListener("input", () => { startPos = index + str.length; } - // Create a range object for each instance of + // Create a range object for each instance of // str we found in the text node. return indices.map((index) => { const range = new Range(); diff --git a/files/zh-cn/web/api/css_font_loading_api/index.md b/files/zh-cn/web/api/css_font_loading_api/index.md index 3b570877da3c51..6f8ffd5ffe8e9b 100644 --- a/files/zh-cn/web/api/css_font_loading_api/index.md +++ b/files/zh-cn/web/api/css_font_loading_api/index.md @@ -120,7 +120,7 @@ canvas.height = 75; ```js const bitterFontFace = new FontFace( "FontFamily Bitter", - "url(https://fonts.gstatic.com/s/bitter/v7/HEpP8tJXlWaYHimsnXgfCOvvDin1pK8aKteLpeZ5c0A.woff2)" + "url(https://fonts.gstatic.com/s/bitter/v7/HEpP8tJXlWaYHimsnXgfCOvvDin1pK8aKteLpeZ5c0A.woff2)", ); document.fonts.add(bitterFontFace); log.textContent += `Bitter font: ${bitterFontFace.status}\n`; // > Bitter font: unloaded @@ -139,7 +139,7 @@ bitterFontFace.load().then( }, (err) => { console.error(err); - } + }, ); ``` @@ -176,7 +176,7 @@ const ctx = canvas.getContext("2d"); const oxygenFontFace = new FontFace( "FontFamily Oxygen", - "url(https://fonts.gstatic.com/s/oxygen/v5/qBSyz106i5ud7wkBU-FrPevvDin1pK8aKteLpeZ5c0A.woff2)" + "url(https://fonts.gstatic.com/s/oxygen/v5/qBSyz106i5ud7wkBU-FrPevvDin1pK8aKteLpeZ5c0A.woff2)", ); document.fonts.add(oxygenFontFace); log.textContent += `Oxygen status: ${oxygenFontFace.status}\n`; @@ -194,7 +194,7 @@ document.fonts.load("36px FontFamily Oxygen").then( }, (err) => { console.error(err); - } + }, ); ``` diff --git a/files/zh-cn/web/api/css_object_model/using_dynamic_styling_information/index.md b/files/zh-cn/web/api/css_object_model/using_dynamic_styling_information/index.md index 2fea78af708464..adc45e24fddd7f 100644 --- a/files/zh-cn/web/api/css_object_model/using_dynamic_styling_information/index.md +++ b/files/zh-cn/web/api/css_object_model/using_dynamic_styling_information/index.md @@ -17,21 +17,22 @@ CSS 对象模型(CSSOM),是 DOM 的一部分,通过暴露一些接口, ```html - -Modifying a stylesheet rule with CSSOM - - - - -The stylesheet declaration for the body's background color is modified via JavaScript. - + + Modifying a stylesheet rule with CSSOM + + + + + The stylesheet declaration for the body's background color is modified via + JavaScript. + ``` @@ -51,39 +52,36 @@ The stylesheet declaration for the body's background color is modified via JavaS ```html - -simple style example - - - - - - - - - -

- Click here to change background color. -

- - - - - + + simple style example + + + + + + + + +

+ Click here to change background color. +

+ + + + ``` @@ -98,26 +96,26 @@ function resetStyle(elemId) { 比这两个属性更重要的是使用 `style` 对象来给某个元素设置单独的样式属性。 ```html - + - - style Property Example - - - - - -
Thunder
- - - + + style Property Example + + + + + +
Thunder
+ + + ``` @@ -130,8 +128,8 @@ style 的 media 和 type 给不给出都可以。 注意,你也可以通过获得元素的引用,然后使用它的 [`setAttribute`](/zh-CN/DOM/element.setAttribute) 方法,指定 CSS 属性和值,来改变该元素的样式。 ```js -var el = document.getElementById('some-element'); -el.setAttribute('style', 'background-color:darkblue;'); +var el = document.getElementById("some-element"); +el.setAttribute("style", "background-color:darkblue;"); ``` 但请注意,`setAttribute` 会移除该元素样式对象中已经定义的其他样式属性。如果上面的 `some-element` 有一个行内样式属性:`style="font-size: 18px"`,其值将会因为使用了 `setAttribute` 方法而被移除。 diff --git a/files/zh-cn/web/api/cssrule/csstext/index.md b/files/zh-cn/web/api/cssrule/csstext/index.md index a5a3cbc516a27c..1e2d20f41842f5 100644 --- a/files/zh-cn/web/api/cssrule/csstext/index.md +++ b/files/zh-cn/web/api/cssrule/csstext/index.md @@ -17,7 +17,9 @@ string = cssRule.cssText ```html @@ -339,14 +351,14 @@ for (let i = 0; i < divs.length; i++) {
- +
- +
- +

@@ -361,17 +373,17 @@ div { さあちょっとした JavaScript です — ここでは [onsubmit](/ja/docs/Web/API/GlobalEventHandlers/onsubmit) イベントハンドラー(フォームがサブミットされるとサブミットイベントが発火します)の中で、テキストフィールドが空かどうかテストするだけのとても簡単なチェックを実装します。もし空なら、イベントオブジェクトの [`preventDefault()`](/ja/docs/Web/API/Event/preventDefault) 関数— これでフォームの送信を抑制します — を呼び、それからフォームの下にあるパラグラフに、何が問題なのかユーザーに伝えるためのエラーメッセージを表示します: ```js -const form = document.querySelector('form'); -const fname = document.getElementById('fname'); -const lname = document.getElementById('lname'); -const para = document.querySelector('p'); +const form = document.querySelector("form"); +const fname = document.getElementById("fname"); +const lname = document.getElementById("lname"); +const para = document.querySelector("p"); -form.onsubmit = function(e) { - if (fname.value === '' || lname.value === '') { +form.onsubmit = function (e) { + if (fname.value === "" || lname.value === "") { e.preventDefault(); - para.textContent = 'You need to fill in both names!'; + para.textContent = "You need to fill in both names!"; } -} +}; ``` 言うまでもなく弱っちいフォームの検証です — 例えばフォームに空白や数字が入っていても止められません — が、例としては十分です。結果はこうなります。 @@ -385,21 +397,25 @@ form.onsubmit = function(e) { ここで最後に説明していくのは、滅多には遭遇しませんが、理解できていないととても苦痛になるかもしれない事柄です。ある一つの要素で同じイベントに紐付く二つのハンドラが活性化された時に何が起きるのかを説明するのが、イベントのバブリングとキャプチャリングという二種類のメカニズムです。わかりやすくするために次の例を見てください — [show-video-box.html](http://mdn.github.io/learning-area/javascript/building-blocks/events/show-video-box.html) 例を新しいタブで開いてください ([ソースコード](https://github.com/mdn/learning-area/blob/master/javascript/building-blocks/events/show-video-box.html) もまた別のタブに)。ライブでも下で見られます: ```html hidden - + - + Show video box example @@ -423,36 +438,41 @@ form.onsubmit = function(e) { @@ -467,9 +487,12 @@ form.onsubmit = function(e) { ``` @@ -477,9 +500,9 @@ form.onsubmit = function(e) { {{htmlelement("button")}} がクリックされると、`
` のクラス属性を `hidden` から `showing` に変更するので、ビデオが表示されます(例の CSS にこの二つのクラスが含まれており、それぞれはボックスの位置をスクリーンの外、内にします)。 ```js -btn.onclick = function() { - videoBox.setAttribute('class', 'showing'); -} +btn.onclick = function () { + videoBox.setAttribute("class", "showing"); +}; ``` では二つばかり `onclick` イベントハンドラーを追加します — 最初のは `
` に、二つ目は `
- - - - - - - - - - - - - - - - - - -
バブリングあり
キャンセル不可
インターフェイス{{domxref("TransitionEvent")}}
イベントハンドラープロパティ - {{domxref("GlobalEventHandlers.ontransitioncancel")}} -
- -このイベントの本来の対象は、トランジションが適用された {{domxref("Element")}} です。このイベントを {{domxref("Document")}} インターフェイス上で待ち受けし、キャプチャやバブリングの局面で処理することができます。このイベントについて完全な詳細は、 [HTMLElement: transitioncancel イベント](/ja/docs/Web/API/HTMLElement/transitioncancel_event)を参照してください。 +{{APIRef}} + +**`transitioncancel`** イベントは、 [CSS トランジション](/ja/docs/Web/CSS/CSS_transitions/Using_CSS_transitions)がキャンセルされたときに発生します。 + +## 構文 + +このイベント名を {{domxref("EventTarget.addEventListener", "addEventListener()")}} などのメソッドで使用するか、イベントハンドラープロパティを設定するかしてください。 + +```js +addEventListener("transitioncancel", (event) => {}); + +ontransitioncancel = (event) => {}; +``` + +## イベント型 + +{{domxref("TransitionEvent")}} です。 {{domxref("Event")}} を継承しています。 + +{{InheritanceDiagram("TransitionEvent")}} + +## イベントプロパティ + +_親である {{domxref("Event")}} から継承したプロパティもあります。_ + +- {{domxref("TransitionEvent.propertyName")}} {{ReadOnlyInline}} + - : 文字列で、このトランジションに関連付けられた CSS プロパティの名前が入ります。 +- {{domxref("TransitionEvent.elapsedTime")}} {{ReadOnlyInline}} + - : float` で、このイベントが発行されたときにトランジションが実行されていた時間を秒単位で表します。この値は {{cssxref("transition-delay")}} プロパティの影響を受けません。 +- {{domxref("TransitionEvent.pseudoElement")}} {{ReadOnlyInline}} + - : 文字列で、アニメーションが実行する[擬似要素](/ja/docs/Web/CSS/Pseudo-elements)の名前が入ります。トランジションが擬似要素上で実行されず、要素上で実行される場合は空文字列 (`''`) です。 ## 例 -このコードは、リスナーに `transitioncancel` イベントを追加します。 +このコードはトランジションを定義している要素を取得し、`transitioncancel` イベントのリスナーを追加します。 ```js -document.addEventListener('transitioncancel', () => { - console.log('Transition canceled'); +const transition = document.querySelector(".transition"); + +transition.addEventListener("transitioncancel", () => { + console.log("Transition canceled"); }); ``` -同様に、 {{domxref("GlobalEventHandlers.ontransitioncancel", "ontransitioncancel")}} プロパティを `addEventListener()` の代わりに使用した例です。 +同じことを、`ontransitioncancel` プロパティを `addEventListener()` の代わりに使用して行った例です。 ```js -document.ontransitioncancel = () => { - console.log('Transition canceled'); +const transition = document.querySelector(".transition"); + +transition.ontransitioncancel = () => { + console.log("Transition canceled"); }; ``` -[このイベントのライブデモを参照してください。](/ja/docs/Web/API/HTMLElement/transitioncancel_event#Live_example) +### ライブ例 + +次の例では、単純な {{htmlelement("div")}} 要素に遅延を含むトランジションをスタイル設定しています。 + +```html +
+
+``` + +```css +.transition { + width: 100px; + height: 100px; + background: rgba(255, 0, 0, 1); + transition-property: transform, background; + transition-duration: 2s; + transition-delay: 2s; +} + +.transition:hover { + transform: rotate(90deg); + background: rgba(255, 0, 0, 0); +} +``` + +これにいくらかの JavaScript を追加して、[`transitionstart`](/ja/docs/Web/API/Element/transitionstart_event)、[`transitionrun`](/ja/docs/Web/API/Element/transitionrun_event)、`transitioncancel`、[`transitionend`](/ja/docs/Web/API/Element/transitionend_event) の各イベントが発生すると実行されるようにします。この例では、トランジションをキャンセルするには、トランジションが終了する前にトランジション中のボックスに宛てたマウスを外してください。トランジション終了イベントを発生させるには、トランジションが終了するまでトランジションの上にマウスを当てたままにしてください。 + +```js +const message = document.querySelector(".message"); +const el = document.querySelector(".transition"); + +el.addEventListener("transitionrun", () => { + message.textContent = "transitionrun が発生"; +}); + +el.addEventListener("transitionstart", () => { + message.textContent = "transitionstart が発生"; +}); + +el.addEventListener("transitioncancel", () => { + message.textContent = "transitioncancel が発生"; +}); + +el.addEventListener("transitionend", () => { + message.textContent = "transitionend が発生"; +}); +``` + +{{ EmbedLiveSample('Live_example', '100%', '150px') }} + +`transitioncancel` イベントは `transitionrun` イベントが発生した後、`transitionend` イベントが発生する前にトランジションがどちらかの方向に取り消された場合に発行されます。 + +トランジションの遅延や継続時間がない場合、両方が 0s である場合、または両方とも宣言されていない場合、トランジションは発生せず、トランジションイベントは何も発行されません。 + +`transitioncancel` イベントが発行された場合、`transitionend` イベントは発行されません。 ## 仕様書 @@ -65,9 +126,6 @@ document.ontransitioncancel = () => { ## 関連情報 -- {{domxref("GlobalEventHandlers.ontransitioncancel")}} イベントハンドラー - {{domxref("TransitionEvent")}} インターフェイス - CSS プロパティ: {{cssxref("transition")}}, {{cssxref("transition-delay")}}, {{cssxref("transition-duration")}}, {{cssxref("transition-property")}}, {{cssxref("transition-timing-function")}} -- 関連イベント: {{domxref("Document/transitionrun_event", "transitionrun")}}, {{domxref("Document/transitionstart_event", "transitionstart")}}, {{domxref("Document/transitionend_event", "transitionend")}} -- {{domxref("HTMLElement")}} を対象としたこのイベント: {{domxref("HTMLElement/transitioncancel_event", "transitioncancel")}} -- {{domxref("Window")}} を対象としたこのイベント: {{domxref("Window/transitioncancel_event", "transitioncancel")}} +- 関連イベント: {{domxref("Element/transitionrun_event", "transitionrun")}}, {{domxref("Element/transitionstart_event", "transitionstart")}}, {{domxref("Element/transitionend_event", "transitionend")}} diff --git a/files/ja/web/api/element/transitionend_event/index.md b/files/ja/web/api/element/transitionend_event/index.md index 7082260652abac..e98c72447d15fb 100644 --- a/files/ja/web/api/element/transitionend_event/index.md +++ b/files/ja/web/api/element/transitionend_event/index.md @@ -1,59 +1,124 @@ --- -title: 'Document: transitionend イベント' +title: "Element: transitionend イベント" +short-title: transitionend slug: Web/API/Element/transitionend_event original_slug: Web/API/Document/transitionend_event +l10n: + sourceCommit: 1b094710cd2816a6669ce616b6f56d0a5b25e6ad --- {{APIRef}} -**`transitionend`** イベントは、 [CSS トランジション](/ja/docs/CSS/Using_CSS_transitions)が完了したときに発生します。トランジションが完了前に削除された場合、例えば {{cssxref("transition-property")}} が削除されたり、 {{cssxref("display")}} が `none` に設定されたりした場合、イベントは生成されません。 - - - - - - - - - - - - - - - - - - - - -
バブリングあり
キャンセル
インターフェイス{{domxref("TransitionEvent")}}
イベントハンドラープロパティ - {{domxref("GlobalEventHandlers/ontransitionend", "ontransitionend")}} -
- -`transitionend` イベントは二つの方向で発生します。 - トランジション終了の状態まで遷移し終わったときと、既定またはトランジションがない状態まで完全に戻ったときです。トランジションに待ち時間や実行時間がない場合、両方が 0 秒またはどちらも宣言されていなかった場合、トランジションは発生せず、トランジションイベントは発生しません。 `transitioncancel` イベントが発生すると、 `transitionend` イベントは発生しません。 - -このイベントの本来の対象は、トランジションが適用された {{domxref("Element")}} です。このイベントを {{domxref("Document")}} インターフェイス上で待ち受けし、キャプチャやバブリングの局面で処理することができます。このイベントについて完全な詳細は、 [HTMLElement: transitionend イベント](/ja/docs/Web/API/HTMLElement/transitionend_event)を参照してください。 +**`transitionend`** イベントは、 [CSS トランジション](/ja/docs/Web/CSS/CSS_transitions/Using_CSS_transitions)が完了したときに発生します。トランジションが完了前に削除された場合、例えば {{cssxref("transition-property")}} が削除されたり、 {{cssxref("display")}} が `none` に設定されたりした場合、イベントは生成されません。 + +`transitionend` イベントは二つの方向で発生します。トランジション終了の状態まで遷移し終わったときと、既定またはトランジションがない状態まで完全に戻ったときです。トランジションに待ち時間や実行時間がない場合、両方が 0 秒またはどちらも宣言されていなかった場合、トランジションは発生せず、トランジションイベントは発生しません。 `transitioncancel` イベントが発生すると、 `transitionend` イベントは発生しません。 + +このイベントはキャンセルできません。 + +## 構文 + +このイベント名を {{domxref("EventTarget.addEventListener", "addEventListener()")}} などのメソッドで使用するか、イベントハンドラープロパティを設定するかしてください。 + +```js +addEventListener("transitionend", (event) => {}); + +ontransitionend = (event) => {}; +``` + +## イベント型 + +{{domxref("TransitionEvent")}} です。 {{domxref("Event")}} を継承しています。 + +{{InheritanceDiagram("TransitionEvent")}} + +## イベントプロパティ + +_親である {{domxref("Event")}} から継承したプロパティもあります。_ + +- {{domxref("TransitionEvent.propertyName")}} {{ReadOnlyInline}} + - : 文字列で、このトランジションに関連付けられた CSS プロパティの名前が入ります。 +- {{domxref("TransitionEvent.elapsedTime")}} {{ReadOnlyInline}} + - : float` で、このイベントが発行されたときにトランジションが実行されていた時間を秒単位で表します。この値は {{cssxref("transition-delay")}} プロパティの影響を受けません。 +- {{domxref("TransitionEvent.pseudoElement")}} {{ReadOnlyInline}} + - : 文字列で、アニメーションが実行する[擬似要素](/ja/docs/Web/CSS/Pseudo-elements)の名前が入ります。トランジションが擬似要素上で実行されず、要素上で実行される場合は空文字列 (`''`) です。 ## 例 -このコードはリスナーに `transitionend` イベントを追加します。 +このコードはトランジションを定義している要素を取得し、`transitionend` イベントのリスナーを追加します。 ```js -document.addEventListener('transitionend', () => { - console.log('Transition ended'); +const transition = document.querySelector(".transition"); + +transition.addEventListener("transitionend", () => { + console.log("Transition ended"); }); ``` -同様に、 {{domxref("GlobalEventHandlers/ontransitioncancel", "ontransitionend")}} プロパティを `addEventListener()` の代わりに使用した例です。 +同じことを、`ontransitionend` を使用して行う例です。 ```js -document.ontransitionend = () => { - console.log('Transition ended'); +const transition = document.querySelector(".transition"); + +transition.ontransitionend = () => { + console.log("Transition ended"); }; ``` -[このイベントのライブデモを参照してください。](/ja/docs/Web/API/HTMLElement/transitionend_event#Live_example) +### ライブ例 + +次の例では、単純な {{htmlelement("div")}} 要素に遅延を含むトランジションをスタイル設定しています。 + +```html +
+
+``` + +```css +.transition { + width: 100px; + height: 100px; + background: rgba(255, 0, 0, 1); + transition-property: transform, background; + transition-duration: 2s; + transition-delay: 2s; +} + +.transition:hover { + transform: rotate(90deg); + background: rgba(255, 0, 0, 0); +} +``` + +これにいくらかの JavaScript を追加して、[`transitionstart`](/ja/docs/Web/API/Element/transitionstart_event)、[`transitionrun`](/ja/docs/Web/API/Element/transitionrun_event)、[`transitioncancel`](/ja/docs/Web/API/Element/transitioncancel_event)、`transitionend` の各イベントが発生すると実行されるようにします。この例では、トランジションをキャンセルするには、トランジションが終了する前にトランジション中のボックスに宛てたマウスを外してください。トランジション終了イベントを発生させるには、トランジションが終了するまでトランジションの上にマウスを当てたままにしてください。 + +```js +const message = document.querySelector(".message"); +const el = document.querySelector(".transition"); + +el.addEventListener("transitionrun", () => { + message.textContent = "transitionrun が発生"; +}); + +el.addEventListener("transitionstart", () => { + message.textContent = "transitionstart が発生"; +}); + +el.addEventListener("transitioncancel", () => { + message.textContent = "transitioncancel が発生"; +}); + +el.addEventListener("transitionend", () => { + message.textContent = "transitionend が発生"; +}); +``` + +{{ EmbedLiveSample('Live_example', '100%', '150px') }} + +`transitionend` イベントは両方向に発生します。ボックスの回転が完了し、不透明度が方向に応じて 0 または 1 になったときです。 + +トランジションの遅延や継続時間がない場合、両方が 0s である場合、または両方とも宣言されていない場合、トランジションは発生せず、トランジションイベントは何も発行されません。 + +`transitioncancel` イベントが発行された場合、`transitionend` イベントは発行されません。 ## 仕様書 @@ -65,9 +130,6 @@ document.ontransitionend = () => { ## 関連情報 -- {{domxref("GlobalEventHandlers.ontransitionend")}} イベントハンドラー - {{domxref("TransitionEvent")}} インターフェイス - CSS プロパティ: {{cssxref("transition")}}, {{cssxref("transition-delay")}}, {{cssxref("transition-duration")}}, {{cssxref("transition-property")}}, {{cssxref("transition-timing-function")}} -- 関連イベント: {{domxref("Document/transitionrun_event", "transitionrun")}}, {{domxref("Document/transitionstart_event", "transitionstart")}}, {{domxref("Document/transitioncancel_event", "transitioncancel")}} -- {{domxref("HTMLElement")}} を対象としたこのイベント: {{domxref("HTMLElement/transitionend_event", "transitionend")}} -- {{domxref("Window")}} を対象としたこのイベント: {{domxref("Window/transitionend_event", "transitionend")}} +- 関連イベント: {{domxref("Element/transitionrun_event", "transitionrun")}}, {{domxref("Element/transitionstart_event", "transitionstart")}}, {{domxref("Element/transitioncancel_event", "transitioncancel")}} diff --git a/files/ja/web/api/element/transitionrun_event/index.md b/files/ja/web/api/element/transitionrun_event/index.md index cbb7c0f7ae7c93..444d04a9c66fda 100644 --- a/files/ja/web/api/element/transitionrun_event/index.md +++ b/files/ja/web/api/element/transitionrun_event/index.md @@ -1,57 +1,119 @@ --- -title: 'Document: transitionrun イベント' +title: "Element: transitionrun イベント" +short-title: transitionrun slug: Web/API/Element/transitionrun_event original_slug: Web/API/Document/transitionrun_event +l10n: + sourceCommit: 1b094710cd2816a6669ce616b6f56d0a5b25e6ad --- -{{APIRef}}{{SeeCompatTable}} - -**`transitionrun`** イベントは、 [CSS トランジション](/ja/docs/CSS/Using_CSS_transitions)が最初に生成されたとき、すなわち {{cssxref("transition-delay")}} が始まる前に発生します。 - - - - - - - - - - - - - - - - - - - - -
バブリングあり
キャンセル不可
インターフェイス{{domxref("TransitionEvent")}}
イベントハンドラープロパティ - {{domxref("GlobalEventHandlers/ontransitionrun", "ontransitionrun")}} -
- -このイベントの本来の対象は、トランジションが適用された {{domxref("Element")}} です。このイベントを {{domxref("Document")}} インターフェイス上で待ち受けし、キャプチャやバブリングの局面で処理することができます。このイベントについて完全な詳細は、 [HTMLElement: transitionrun イベント](/ja/docs/Web/API/HTMLElement/transitionrun_event)を参照してください。 +{{APIRef}} + +**`transitionrun`** イベントは、 [CSS トランジション](/ja/docs/Web/CSS/CSS_transitions/Using_CSS_transitions)が最初に生成されたとき、すなわち {{cssxref("transition-delay")}} が始まる前に発生します。 + +このイベントはキャンセルできません。 + +## 構文 + +このイベント名を {{domxref("EventTarget.addEventListener", "addEventListener()")}} などのメソッドで使用するか、イベントハンドラープロパティを設定するかしてください。 + +```js +addEventListener("transitionrun", (event) => {}); + +ontransitionrun = (event) => {}; +``` + +## イベント型 + +{{domxref("TransitionEvent")}} です。 {{domxref("Event")}} を継承しています。 + +{{InheritanceDiagram("TransitionEvent")}} + +## イベントプロパティ + +_親である {{domxref("Event")}} から継承したプロパティもあります。_ + +- {{domxref("TransitionEvent.propertyName")}} {{ReadOnlyInline}} + - : 文字列で、このトランジションに関連付けられた CSS プロパティの名前が入ります。 +- {{domxref("TransitionEvent.elapsedTime")}} {{ReadOnlyInline}} + - : float` で、このイベントが発行されたときにトランジションが実行されていた時間を秒単位で表します。この値は {{cssxref("transition-delay")}} プロパティの影響を受けません。 +- {{domxref("TransitionEvent.pseudoElement")}} {{ReadOnlyInline}} + - : 文字列で、アニメーションが実行する[擬似要素](/ja/docs/Web/CSS/Pseudo-elements)の名前が入ります。トランジションが擬似要素上で実行されず、要素上で実行される場合は空文字列 (`''`) です。 ## 例 -次のコードは `transitionrun` イベントにリスナーを追加します。 +このコードは `transitionrun` イベントのリスナーを追加します。 ```js -document.addEventListener('transitionrun', () => { - console.log('Transition is running but hasn't necessarily started transitioning yet'); +el.addEventListener("transitionrun", () => { + console.log( + "トランジションは実行中ですが、まだトランジションは始まっていません。", + ); }); ``` -同じですが、 {{domxref("GlobalEventHandlers/ontransitionrun", "ontransitionrun")}} を `addEventListener()` の代わりに使用すると次のようになります。 +同じことを、`ontransitionrun` プロパティを `addEventListener()` の代わりに使用して行います。 ```js -document.ontransitionrun = () => { - console.log('Transition started running'); +el.ontransitionrun = () => { + console.log( + "トランジションの実行が開始され、トランジションの遅延時間が経過した時点でトランジションを開始します。", + ); }; ``` -[このイベントのライブデモを参照してください。](/ja/docs/Web/API/HTMLElement/transitionrun_event#Live_example) +### ライブ例 + +次の例では、単純な {{htmlelement("div")}} 要素に遅延を含むトランジションをスタイル設定しています。 + +```html +
ここにポインターを当ててください
+
+``` + +```css +.transition { + width: 100px; + height: 100px; + background: rgba(255, 0, 0, 1); + transition-property: transform, background; + transition-duration: 2s; + transition-delay: 1s; +} + +.transition:hover { + transform: rotate(90deg); + background: rgba(255, 0, 0, 0); +} +``` + +これにいくらかの JavaScript を追加して、{{domxref("Element/transitionstart_event", "transitionstart")}} および {{domxref("Element/transitionrun_event", "transitionrun")}} イベントが発生すると実行されるようにします。 + +```js +const el = document.querySelector(".transition"); +const message = document.querySelector(".message"); + +el.addEventListener("transitionrun", () => { + message.textContent = "transitionrun が発生"; +}); + +el.addEventListener("transitionstart", () => { + message.textContent = "transitionstart が発生"; +}); + +el.addEventListener("transitionend", () => { + message.textContent = "transitionend が発生"; +}); +``` + +{{ EmbedLiveSample('Live_example', '100%', '150px') }} + +違いは次の通りです。 + +- `transitionrun` は、トランジションが作成されたとき(つまり、遅延が始まるとき)に発生します。 +- `transitionstart` は、実際のアニメーションが始まったとき(つまり、遅延が終わったとき)に発生します。 + +`transitionrun` は、トランジションが遅延時間内にキャンセルされた場合でも発生します。トランジションの遅延がない場合や、transition-delay が負の場合は、`transitionrun` と `transitionstart` の両方が発生します。 ## 仕様書 @@ -63,9 +125,6 @@ document.ontransitionrun = () => { ## 関連情報 -- {{domxref("GlobalEventHandlers.ontransitionrun")}} イベントハンドラー - {{domxref("TransitionEvent")}} インターフェイス - CSS プロパティ: {{cssxref("transition")}}, {{cssxref("transition-delay")}}, {{cssxref("transition-duration")}}, {{cssxref("transition-property")}}, {{cssxref("transition-timing-function")}} -- 関連イベント: {{domxref("Document/transitionend_event", "transitionend")}}, {{domxref("Document/transitionstart_event", "transitionstart")}}, {{domxref("Document/transitioncancel_event", "transitioncancel")}} -- {{domxref("HTMLElement")}} を対象としたこのイベント: {{domxref("HTMLElement/transitionrun_event", "transitionrun")}} -- {{domxref("Window")}} を対象としたこのイベント: {{domxref("Window/transitionstart_run", "transitionrun")}} +- 関連イベント: {{domxref("Element/transitionend_event", "transitionend")}}, {{domxref("Element/transitionstart_event", "transitionstart")}}, {{domxref("Element/transitioncancel_event", "transitioncancel")}} diff --git a/files/ja/web/api/element/transitionstart_event/index.md b/files/ja/web/api/element/transitionstart_event/index.md index 0f023fa69b8890..62638fd5bf89ce 100644 --- a/files/ja/web/api/element/transitionstart_event/index.md +++ b/files/ja/web/api/element/transitionstart_event/index.md @@ -1,59 +1,113 @@ --- -title: 'Document: transitionstart イベント' +title: "Element: transitionstart イベント" +short-title: transitionstart slug: Web/API/Element/transitionstart_event original_slug: Web/API/Document/transitionstart_event +l10n: + sourceCommit: 1b094710cd2816a6669ce616b6f56d0a5b25e6ad --- -{{APIRef}}{{SeeCompatTable}} - -**`transitionstart`** イベントは、 [CSS トランジション](/ja/docs/CSS/Using_CSS_transitions)が実際に始まったとき、すなわち {{cssxref("transition-delay")}} が終了した後に発生します。 - -`transitionstart` と `transitionrun` の違いは、 `transitionrun` がトランジションが生成されたとき (すなわち、待ち時間の開始) に発生するのに対し、 `transitionstart` は実際にアニメーションが始まったとき (すなわち、待ち時間の終了) に発生することです。 - - - - - - - - - - - - - - - - - - - - -
バブリングあり
キャンセル不可
インターフェイス{{domxref("TransitionEvent")}}
イベントハンドラープロパティ - {{domxref("GlobalEventHandlers.ontransitionstart")}} -
- -このイベントの本来の対象は、トランジションが適用された {{domxref("Element")}} です。このイベントを {{domxref("Document")}} インターフェイス上で待ち受けし、キャプチャやバブリングの局面で処理することができます。このイベントについて完全な詳細は、 [HTMLElement: transitionstart イベント](/ja/docs/Web/API/HTMLElement/transitionstart_event)を参照してください。 +{{APIRef}} + +**`transitionstart`** イベントは、 [CSS トランジション](/ja/docs/Web/CSS/CSS_transitions/Using_CSS_transitions)が実際に始まったとき、すなわち {{cssxref("transition-delay")}} が終了した後に発生します。 + +このイベントはキャンセルできません。 + +## 構文 + +このイベント名を {{domxref("EventTarget.addEventListener", "addEventListener()")}} などのメソッドで使用するか、イベントハンドラープロパティを設定するかしてください。 + +```js +addEventListener("transitionstart", (event) => {}); + +ontransitionstart = (event) => {}; +``` + +## イベント型 + +{{domxref("TransitionEvent")}} です。 {{domxref("Event")}} を継承しています。 + +{{InheritanceDiagram("TransitionEvent")}} + +## イベントプロパティ + +_親である {{domxref("Event")}} から継承したプロパティもあります。_ + +- {{domxref("TransitionEvent.propertyName")}} {{ReadOnlyInline}} + - : 文字列で、このトランジションに関連付けられた CSS プロパティの名前が入ります。 +- {{domxref("TransitionEvent.elapsedTime")}} {{ReadOnlyInline}} + - : float` で、このイベントが発行されたときにトランジションが実行されていた時間を秒単位で表します。この値は {{cssxref("transition-delay")}} プロパティの影響を受けません。 +- {{domxref("TransitionEvent.pseudoElement")}} {{ReadOnlyInline}} + - : 文字列で、アニメーションが実行する[擬似要素](/ja/docs/Web/CSS/Pseudo-elements)の名前が入ります。トランジションが擬似要素上で実行されず、要素上で実行される場合は空文字列 (`''`) です。 ## 例 -次のコードは `transitionstart` イベントにリスナーを追加します。 +このコードは `transitionstart` イベントのリスナーを追加します。 ```js -document.addEventListener('transitionrun', () => { - console.log('Transition is running but hasn't necessarily started transitioning yet'); +element.addEventListener("transitionstart", () => { + console.log("トランジション開始"); }); ``` -同じですが、 {{domxref("GlobalEventHandlers/ontransitionstart", "ontransitionstart")}} を `addEventListener()` の代わりに使用すると次のようになります。 +同じことを、`ontransitionstart` プロパティを `addEventListener()` の代わりに使用して行います。 ```js -document.ontransitionrun = () => { - console.log('Transition started running'); +element.ontransitionstart = () => { + console.log("トランジション開始"); }; ``` -[このイベントのライブデモを参照してください。](/ja/docs/Web/API/HTMLElement/transitionstart_event#Live_example) +### ライブ例 + +次の例では、単純な {{htmlelement("div")}} 要素に遅延を含むトランジションをスタイル設定しています。 + +```html +
ここにポインターを当ててください
+
+``` + +```css +.transition { + width: 100px; + height: 100px; + background: rgba(255, 0, 0, 1); + transition-property: transform, background; + transition-duration: 2s; + transition-delay: 1s; +} + +.transition:hover { + transform: rotate(90deg); + background: rgba(255, 0, 0, 0); +} +``` + +これにいくらかの JavaScript を追加して、{{domxref("Element/transitionstart_event", "transitionstart")}} および {{domxref("Element/transitionrun_event", "transitionrun")}} イベントが発生すると実行されるようにします。 + +```js +const transition = document.querySelector(".transition"); +const message = document.querySelector(".message"); + +transition.addEventListener("transitionrun", () => { + message.textContent = "transitionrun が発生"; +}); + +transition.addEventListener("transitionstart", () => { + message.textContent = "transitionstart が発生"; +}); + +transition.addEventListener("transitionend", () => { + message.textContent = "transitionend が発生"; +}); +``` + +{{ EmbedLiveSample('Live example', '100%', '170') }} + +違いは次の通りです。 + +- `transitionrun` は、トランジションが作成されたとき(つまり、遅延が始まるとき)に発生します。 +- `transitionstart` は、実際のアニメーションが始まったとき(つまり、遅延が終わったとき)に発生します。 ## 仕様書 @@ -65,9 +119,6 @@ document.ontransitionrun = () => { ## 関連情報 -- {{domxref("GlobalEventHandlers.ontransitionstart")}} イベントハンドラー - {{domxref("TransitionEvent")}} インターフェイス - CSS プロパティ: {{cssxref("transition")}}, {{cssxref("transition-delay")}}, {{cssxref("transition-duration")}}, {{cssxref("transition-property")}}, {{cssxref("transition-timing-function")}} -- 関連イベント: {{domxref("Document/transitionend_event", "transitionend")}}, {{domxref("Document/transitionrun_event", "transitionrun")}}, {{domxref("Document/transitioncancel_event", "transitioncancel")}} -- {{domxref("HTMLElement")}} を対象としたこのイベント: {{domxref("HTMLElement/transitionstart_event", "transitionstart")}} -- {{domxref("Window")}} を対象としたこのイベント: {{domxref("Window/transitionstart_event", "transitionstart")}} +- 関連イベント: {{domxref("Element/transitionend_event", "transitionend")}}, {{domxref("Element/transitionrun_event", "transitionrun")}}, {{domxref("Element/transitioncancel_event", "transitioncancel")}} From 60c19b1e1cf344f2ccf2c72891f438e367da0b4b Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Tue, 25 Jul 2023 00:06:39 +0900 Subject: [PATCH 25/30] =?UTF-8?q?2023/04/07=20=E6=99=82=E7=82=B9=E3=81=AE?= =?UTF-8?q?=E8=8B=B1=E8=AA=9E=E7=89=88=E3=81=AB=E5=90=8C=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/federatedcredential/protocol/index.md | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/files/ja/web/api/federatedcredential/protocol/index.md b/files/ja/web/api/federatedcredential/protocol/index.md index 034220c759bb31..2e894d8e0395d8 100644 --- a/files/ja/web/api/federatedcredential/protocol/index.md +++ b/files/ja/web/api/federatedcredential/protocol/index.md @@ -1,21 +1,18 @@ --- -title: FederatedCredential.protocol +title: "FederatedCredential: protocol プロパティ" +short-title: protocol slug: Web/API/FederatedCredential/protocol +l10n: + sourceCommit: 339595951b78774e951b1a9d215a6db6b856f6b2 --- -{{SeeCompatTable}}{{APIRef("")}}{{securecontext_header}} +{{SeeCompatTable}}{{APIRef("Credential Management API")}}{{securecontext_header}} -**`protocol`** は {{domxref("FederatedCredential")}} インターフェイスのプロパティで、認証情報の連合アイデンティティプロトコルが入った読み取り専用の {{domxref("DOMString")}} を返します。このプロパティが {{jsxref("null")}} の場合、プロトコルは {{domxref("FederatedCredential.provider")}} プロパティから推測される可能性があります。 - -## 構文 - -``` -var protocol = FederatedCredential.protocol -``` +**`protocol`** は {{domxref("FederatedCredential")}} インターフェイスのプロパティで、資格情報の連合アイデンティティプロトコルが入った読み取り専用の文字列を返します。このプロパティが [`null`](/ja/docs/Web/JavaScript/Reference/Operators/null) の場合、プロトコルは {{domxref("FederatedCredential.provider")}} プロパティから推測される可能性があります。 ### 値 -認証情報の連合アイデンティティプロトコルが入った {{domxref("DOMString")}} です (例えば `openidconnect`)。 +資格情報の連合アイデンティティプロトコル(例えば `openidconnect`)が入った文字列です。 ## 例 @@ -27,6 +24,6 @@ var protocol = FederatedCredential.protocol {{Specifications}} -## ブラウザーの対応 +## ブラウザーの互換性 -{{Compat("api.FederatedCredential.protocol")}} +{{Compat}} From a4d5ab56b9417afd104a4b2c874623cccfc81365 Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Tue, 25 Jul 2023 00:04:08 +0900 Subject: [PATCH 26/30] =?UTF-8?q?2023/04/07=20=E6=99=82=E7=82=B9=E3=81=AE?= =?UTF-8?q?=E8=8B=B1=E8=AA=9E=E7=89=88=E3=81=AB=E5=9F=BA=E3=81=A5=E3=81=8D?= =?UTF-8?q?=E6=96=B0=E8=A6=8F=E7=BF=BB=E8=A8=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../federatedcredential/index.md | 34 +++++++++++++++++++ .../api/federatedcredential/provider/index.md | 29 ++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 files/ja/web/api/federatedcredential/federatedcredential/index.md create mode 100644 files/ja/web/api/federatedcredential/provider/index.md diff --git a/files/ja/web/api/federatedcredential/federatedcredential/index.md b/files/ja/web/api/federatedcredential/federatedcredential/index.md new file mode 100644 index 00000000000000..3a843cbf6a4aba --- /dev/null +++ b/files/ja/web/api/federatedcredential/federatedcredential/index.md @@ -0,0 +1,34 @@ +--- +title: "FederatedCredential: FederatedCredential() コンストラクター" +short-title: FederatedCredential() +slug: Web/API/FederatedCredential/FederatedCredential +l10n: + sourceCommit: 339595951b78774e951b1a9d215a6db6b856f6b2 +--- + +{{APIRef("Credential Management API")}}{{SeeCompatTable}} + +**`FederatedCredential()`** コンストラクターは、新しい {{domxref("FederatedCredential")}} オブジェクトを作成します。対応しているブラウザーでは、このクラスのインスタンスにグローバル {{domxref('fetch()')}} の `init` オブジェクトから受け取った `credential` を渡すことができます。 + +## 構文 + +```js-nolint +new FederatedCredential(init) +``` + +### 引数 + +- `init` + + - : オプションは次の通りです。 + + - `provider` + - : 文字列で、資格情報プロバイダーを識別します。 + +## 仕様書 + +{{Specifications}} + +## ブラウザーの互換性 + +{{Compat}} diff --git a/files/ja/web/api/federatedcredential/provider/index.md b/files/ja/web/api/federatedcredential/provider/index.md new file mode 100644 index 00000000000000..9dfda0b5cce5a9 --- /dev/null +++ b/files/ja/web/api/federatedcredential/provider/index.md @@ -0,0 +1,29 @@ +--- +title: "FederatedCredential: provider プロパティ" +short-title: provider +slug: Web/API/FederatedCredential/provider +l10n: + sourceCommit: 339595951b78774e951b1a9d215a6db6b856f6b2 +--- + +{{SeeCompatTable}}{{APIRef("Credential Management API")}} + +**`provider`** は {{domxref("FederatedCredential")}} インターフェイスのプロパティで、資格情報の連合アイデンティティプロバイダーの入った文字列を返します。 + +## 値 + +資格情報の連合アイデンティティプロバイダーの入った文字列です。 + +## 例 + +```js +// TBD +``` + +## 仕様書 + +{{Specifications}} + +## ブラウザーの互換性 + +{{Compat}} From 51156b3843bf6c64a339aa09f088bc415cd537ea Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Tue, 25 Jul 2023 00:13:25 +0900 Subject: [PATCH 27/30] =?UTF-8?q?2023/03/22=20=E6=99=82=E7=82=B9=E3=81=AE?= =?UTF-8?q?=E8=8B=B1=E8=AA=9E=E7=89=88=E3=81=AB=E5=90=8C=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- files/ja/web/api/federatedcredential/index.md | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/files/ja/web/api/federatedcredential/index.md b/files/ja/web/api/federatedcredential/index.md index e17677b92838b6..12ca9f238ca775 100644 --- a/files/ja/web/api/federatedcredential/index.md +++ b/files/ja/web/api/federatedcredential/index.md @@ -1,27 +1,33 @@ --- title: FederatedCredential slug: Web/API/FederatedCredential +l10n: + sourceCommit: 1ac70b362b94fc4d781b4cfbc7d0508eaf91b05c --- {{SeeCompatTable}}{{APIRef("Credential Management API")}} -**`FederatedCredential`** は [Credential Management API](/ja/docs/Web/API/Credential_Management_API) のインターフェイスで、連合アイデンティティのプロバイダーからの認証情報についての情報を提供します。連合アイデンティティのプロバイダーは、ウェブサイトが正しくユーザーを認証し、そのための API を提供する主体です。連合アイデンティティプロバイダーの一例として、 [OpenID Connect](http://openid.net/developers/specs/) があります。 +**`FederatedCredential`** は[資格情報管理 API](/ja/docs/Web/API/Credential_Management_API) のインターフェイスで、連合アイデンティティプロバイダーからの資格情報についての情報を提供します。連合アイデンティティプロバイダーは、ウェブサイトが正しくユーザーを認証し、そのための API を提供する主体です。連合アイデンティティプロバイダーの一例として、 [OpenID Connect](https://openid.net/developers/specs/) があります。 + +> **メモ:** [連合資格情報管理 API (FedCM)](/ja/docs/Web/API/FedCM_API) は、ブラウザーで ID フェデレーションを処理するためのより完全なソリューションを提供し、{{domxref("IdentityCredential")}} 型を使用します。 対応しているブラウザーにおいては、このインターフェイスのインスタンスがグローバル {{domxref('fetch')}} の `init` オブジェクトの `credential` メンバーとして渡されることがあります。 +{{InheritanceDiagram}} + ## コンストラクター -- {{domxref("FederatedCredential.FederatedCredential()","FederatedCredential()")}} +- {{domxref("FederatedCredential.FederatedCredential()","FederatedCredential()")}} {{Experimental_Inline}} - : 新しい `FederatedCredential` オブジェクトを生成します。 ## プロパティ -_祖先である {{domxref("Credential")}} からプロパティを継承しています。_ +_祖先である {{domxref("Credential")}} から継承したプロパティがあります。_ -- {{domxref("FederatedCredential.provider")}} {{readonlyInline}} - - : 認証情報の連合アイデンティティプロバイダーを含む {{domxref("USVString")}} です。 -- {{domxref("FederatedCredential.protocol")}} {{readonlyInline}} - - : 認証情報の連合アイデンティティプロトコルを含む {{domxref("DOMString")}} です。 +- {{domxref("FederatedCredential.provider")}} {{ReadOnlyInline}} {{Experimental_Inline}} + - : 資格情報の連合アイデンティティプロバイダーの入った文字列を返します。 +- {{domxref("FederatedCredential.protocol")}} {{ReadOnlyInline}} {{Experimental_Inline}} + - : 資格情報の連合アイデンティティプロトコルの入った文字列を返します。 ### イベントハンドラー @@ -34,16 +40,15 @@ _祖先である {{domxref("Credential")}} からプロパティを継承して ## 例 ```js -var cred = new FederatedCredential({ - id: id, - name: name, - provider: 'https://account.google.com', - iconURL: iconUrl +const cred = new FederatedCredential({ + id, + name, + provider: "https://account.google.com", + iconURL, }); // 格納 -navigator.credentials.store(cred) - .then(function() { +navigator.credentials.store(cred).then(() => { // 他に何かをする }); ``` @@ -52,6 +57,6 @@ navigator.credentials.store(cred) {{Specifications}} -## ブラウザーの対応 +## ブラウザーの互換性 -{{Compat("api.FederatedCredential")}} +{{Compat}} From 11a19c13ff40f04efc1ba00a084a7c8aad5a0780 Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Tue, 25 Jul 2023 01:10:18 +0900 Subject: [PATCH 28/30] =?UTF-8?q?2023/07/07=20=E6=99=82=E7=82=B9=E3=81=AE?= =?UTF-8?q?=E8=8B=B1=E8=AA=9E=E7=89=88=E3=81=AB=E5=90=8C=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ja/web/api/file/lastmodifieddate/index.md | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/files/ja/web/api/file/lastmodifieddate/index.md b/files/ja/web/api/file/lastmodifieddate/index.md index 56109631b9a527..e08cd135b6e1d0 100644 --- a/files/ja/web/api/file/lastmodifieddate/index.md +++ b/files/ja/web/api/file/lastmodifieddate/index.md @@ -1,19 +1,16 @@ --- -title: File.lastModifiedDate +title: "File: lastModifiedDate プロパティ" +short-title: lastModifiedDate slug: Web/API/File/lastModifiedDate +l10n: + sourceCommit: acfe8c9f1f4145f77653a2bc64a9744b001358dc --- -{{APIRef("File API") }} {{deprecated_header}} +{{APIRef("File API")}}{{Deprecated_Header}}{{Non-standard_Header}} **`File.lastModifiedDate`** 読み取り専用プロパティは、ファイルの最終更新日を返します。最終更新日がわからないファイルは、現在の日付を返します。 -## 構文 - -```js -var time = instanceOfFile.lastModifiedDate -``` - -### 値 +## 値 [`Date`](/ja/docs/Web/JavaScript/Reference/Global_Objects/Date) オブジェクトで、ファイルが最後に変更された日時を表します。 @@ -21,19 +18,18 @@ var time = instanceOfFile.lastModifiedDate ```js // fileInput は HTMLInputElement である -var fileInput = document.getElementById("myfileinput"); - -// files は (NodeList に似た) FileList オブジェクト -var files = fileInput.files; +const fileInput = document.getElementById("myfileinput"); -for (var i = 0; i < files.length; i++) { - alert(files[i].name + " の最終更新日は " + files[i].lastModifiedDate); +for (const file of fileInput.files) { + console.log( + `${file.name} の最終更新日は ${file.lastModifiedDate}`, + ); } ``` ## 時間の精度の低下 -タイミング攻撃やフィンガープリンティングに対する保護機能を提供するために、 `someFile.lastModifiedDate.getTime()` の精度がブラウザーの設定に応じて丸められることがあります。 +タイミング攻撃や[フィンガープリンティング](/ja/docs/Glossary/Fingerprinting)に対する保護機能を提供するために、 `someFile.lastModifiedDate.getTime()` の精度がブラウザーの設定に応じて丸められることがあります。 Firefox では、`privacy.reduceTimerPrecision` 設定は既定で有効になっており、 Firefox 59 では既定で 20 us に設定されています。60 で 2 ms になります。 @@ -43,21 +39,21 @@ someFile.lastModifiedDate.getTime(); // 1519211809934 // 1519211810362 // 1519211811670 -// ... +// … // `privacy.resistFingerprinting` が有効な場合の時間の制度の低下 someFile.lastModifiedDate.getTime(); // 1519129853500 // 1519129858900 // 1519129864400 -// ... +// … ``` Firefox では、`privacy.resistFingerprinting` を有効にすることもできます。精度は 100ms か `privacy.resistFingerprinting.reduceTimerPrecision.microseconds` のいずれか大きい方の値になります。 ## 仕様書 -_File API 仕様の初期のドラフトにありますが、このプロパティは削除されており、現在は非標準です。代わりに{{domxref("File.lastModified")}} を使用してください。_ +_ファイル API 仕様の初期のドラフトにありますが、このプロパティは削除されており、現在は非標準です。代わりに{{domxref("File.lastModified")}} を使用してください。_ ## ブラウザーの互換性 From ec318ee3571a390c9236f18fb288ec274c5b9ec3 Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Tue, 25 Jul 2023 01:01:23 +0900 Subject: [PATCH 29/30] =?UTF-8?q?2023/04/07=20=E6=99=82=E7=82=B9=E3=81=AE?= =?UTF-8?q?=E8=8B=B1=E8=AA=9E=E7=89=88=E3=81=AB=E5=90=8C=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- files/ja/web/api/file/file/index.md | 22 ++++--- files/ja/web/api/file/lastmodified/index.md | 66 ++++++++++++------- files/ja/web/api/file/name/index.md | 52 +++++++-------- files/ja/web/api/file/type/index.md | 45 ++++++++----- .../web/api/file/webkitrelativepath/index.md | 58 ++++++++-------- 5 files changed, 141 insertions(+), 102 deletions(-) diff --git a/files/ja/web/api/file/file/index.md b/files/ja/web/api/file/file/index.md index 1d4a772a83ad94..dbf09db9c208e3 100644 --- a/files/ja/web/api/file/file/index.md +++ b/files/ja/web/api/file/file/index.md @@ -1,6 +1,9 @@ --- -title: File() +title: "File: File() コンストラクター" +short-title: File() slug: Web/API/File/File +l10n: + sourceCommit: 339595951b78774e951b1a9d215a6db6b856f6b2 --- {{APIRef("File")}} @@ -9,27 +12,30 @@ slug: Web/API/File/File ## 構文 -```js -new File(bits, name[, options]); +```js-nolint +new File(bits, name) +new File(bits, name, options) ``` ### 引数 - `bits` - - : {{jsxref("Array")}}、{{jsxref("ArrayBuffer")}}、{{domxref("ArrayBufferView")}}、{{domxref("Blob")}}、{{domxref("USVString")}} の {{jsxref("Array")}} オブジェクト、またはそれらをあわせたものを {{domxref("File")}} 内に格納します。`USVString` オブジェクトは UTF-8 でエンコードされます。 + - : [反復可能](/ja/docs/Web/JavaScript/Reference/Iteration_protocols#反復可能プロトコル)オブジェクト、例えば {{jsxref("Array")}}、{{jsxref("ArrayBuffer")}}、{{jsxref("TypedArray")}}、{{jsxref("DataView")}}、{{domxref("Blob")}}、文字列、またはそのような要素を混合させたものを {{domxref("File")}} 内に格納します。なお、文字列は JavaScript の UTF-16 文字列ではなく、UTF-8 でエンコードされます。 - `name` - - : {{domxref("USVString")}} で、ファイル名またはファイルへのパスを表します。 + - : 文字列で、ファイル名またはファイルへのパスを表します。 - `options` {{optional_inline}} - : ファイルのオプション属性を含むオプションオブジェクト。利用可能なオプションは以下の通りです。 - - `type`: ファイルの中に入るコンテンツの MIME タイプを表す {{domxref("DOMString")}} です。既定値は `""` です。 - - `lastModified`: UNIX 元期からのミリ秒単位で、ファイルが最後に更新された時刻を表す数値です。既定値は {{jsxref("Date.now()")}} です。 + - `type` + - : ファイルの中に入るコンテンツの MIME タイプを表す文字列です。既定値は `""` です。 + - `lastModified` + - : UNIX 元期からのミリ秒単位で、ファイルが最後に更新された時刻を表す数値です。既定値は {{jsxref("Date.now()")}} です。 ## 例 ```js -var file = new File(["foo"], "foo.txt", { +const file = new File(["foo"], "foo.txt", { type: "text/plain", }); ``` diff --git a/files/ja/web/api/file/lastmodified/index.md b/files/ja/web/api/file/lastmodified/index.md index 0cccd9560456dd..1960b12530ac1a 100644 --- a/files/ja/web/api/file/lastmodified/index.md +++ b/files/ja/web/api/file/lastmodified/index.md @@ -1,59 +1,75 @@ --- -title: File.lastModified +title: "File: lastModified プロパティ" +short-title: lastModified slug: Web/API/File/lastModified +l10n: + sourceCommit: 339595951b78774e951b1a9d215a6db6b856f6b2 --- {{APIRef("File")}} -**`File.lastModified`** は読み取り専用プロパティで、ファイルの最終更新日時を UNIX 元期 (1970 年 1 月 1 日の深夜 0 時) からのミリ秒数で返します。最終更新日時が分からないファイルは、現在の日時を返します。 +**`File.lastModified`** は読み取り専用プロパティで、ファイルの最終更新日時を UNIX 元期(1970 年 1 月 1 日の深夜 0 時)からのミリ秒数で返します。最終更新日時が分からないファイルは、現在の日時を返します。 -## 構文 +## 値 -```js -const time = instanceOfFile.lastModified; -``` - -### 値 - -UNIX 元気からのミリ秒数を表す数値です。 +UNIX 元期からのミリ秒数を表す数値です。 ## 例 -### file 入力欄からの読み込み +下記の例では、選んだファイルをループして、それぞれのファイルが過去 1 年以内に変更されたかどうかを出力します。 + +### HTML ```html - + + ``` +```css hidden +output { + display: block; + white-space: pre-wrap; +} +``` + +### JavaScript + ```js -const fileInput = document.querySelector('#fileInput'); -fileInput.addEventListener('change', (event) => { - // filesはFileList型オブジェクト (NodeListと似ている) +const output = document.getElementById("output"); +const filepicker = document.getElementById("filepicker"); + +filepicker.addEventListener("change", (event) => { const files = event.target.files; + const now = new Date(); + output.textContent = ""; - for (let file of files) { + for (const file of files) { const date = new Date(file.lastModified); - console.log(`${file.name} has a last modified date of ${date}`); + // ファイルが 1 年以上変更されていなければtrue + const stale = now.getTime() - file.lastModified > 31_536_000_000; + output.textContent += `${file.name} is ${ + stale ? "stale" : "fresh" + } (${date}).\n`; } }); ``` -以下の結果を試してみてください。 +### 結果 -{{ EmbedLiveSample('Reading_from_file_input', 300, 50) }} +{{EmbedLiveSample('Examples')}} ### 動的に生成されるファイル ファイルが動的に生成された場合、最終更新日時は {{domxref("File.File()", "new File()")}} コンストラクター関数で指定することができます。ファイルが見つからない場合、 `lastModified` は `File` オブジェクトの作成時に {{jsxref("Date.now()")}} から現在の時刻を継承します。 ```js -const fileWithDate = new File([], 'file.bin', { +const fileWithDate = new File([], "file.bin", { lastModified: new Date(2017, 1, 1), }); -console.log(fileWithDate.lastModified); //returns 1485903600000 +console.log(fileWithDate.lastModified); // returns 1485903600000 -const fileWithoutDate = new File([], 'file.bin'); -console.log(fileWithoutDate.lastModified); //returns current time +const fileWithoutDate = new File([], "file.bin"); +console.log(fileWithoutDate.lastModified); // returns current time ``` ## 時間の精度の低下 @@ -67,14 +83,14 @@ someFile.lastModified; // 1519211809934 // 1519211810362 // 1519211811670 -// ... +// … // `privacy.resistFingerprinting` が有効な場合の時間の制度の低下 someFile.lastModified; // 1519129853500 // 1519129858900 // 1519129864400 -// ... +// … ``` Firefox では、`privacy.resistFingerprinting` を有効にすることもできます。精度は 100ms か `privacy.resistFingerprinting.reduceTimerPrecision.microseconds` のいずれか大きい方の値になります。 diff --git a/files/ja/web/api/file/name/index.md b/files/ja/web/api/file/name/index.md index af9b9ff3a049bb..f6ad5518f74748 100644 --- a/files/ja/web/api/file/name/index.md +++ b/files/ja/web/api/file/name/index.md @@ -1,52 +1,52 @@ --- -title: File.name +title: "File: name プロパティ" +short-title: name slug: Web/API/File/name +l10n: + sourceCommit: 339595951b78774e951b1a9d215a6db6b856f6b2 --- {{APIRef("File API")}} {{domxref("File")}} オブジェクトによって表されるファイルの名前を返します。セキュリティ上の理由から、パスはこのプロパティから除外されます。 -## 構文 - -```js -var name = file.name; -``` - ## 値 パスを除いたファイル名の入った文字列。 "My Resume.rtf" など。 ## 例 -```html - +### HTML -
+```html + +
+

選択されたファイルのリスト:

+
    +
    ``` +### JavaScript + ```js -const output = document.querySelector("#output"); -function processSelectedFiles(fileInput) { - let files = fileInput.files; - output.textContent = "選択されたファイルのリスト:"; +const output = document.getElementById("output"); +const filepicker = document.getElementById("filepicker"); - for (let i = 0; i < files.length; i++) { - output.textContent += `\nファイル名: ${files[i].name}`; - } -} -``` +filepicker.addEventListener("change", (event) => { + const files = event.target.files; + output.textContent = ""; -```css hidden -#output{ - padding: 0.5em 0; - white-space: pre; -} + for (const file of files) { + const li = document.createElement("li"); + li.textContent = file.name; + output.appendChild(li); + } +}); ``` -#### 結果 +### 結果 -{{ EmbedLiveSample('Example', 300, 100) }} +{{EmbedLiveSample('Examples')}} ## 仕様書 diff --git a/files/ja/web/api/file/type/index.md b/files/ja/web/api/file/type/index.md index 1cd5a100c58ca9..050a4bc1ffb5ca 100644 --- a/files/ja/web/api/file/type/index.md +++ b/files/ja/web/api/file/type/index.md @@ -1,40 +1,55 @@ --- -title: File.type +title: "File: type プロパティ" +short-title: type slug: Web/API/File/type +l10n: + sourceCommit: 339595951b78774e951b1a9d215a6db6b856f6b2 --- {{APIRef("File API")}} {{domxref("File")}} オブジェクトによって表されるファイルのメディアタイプ ([MIME](/ja/docs/Web/HTTP/Basics_of_HTTP/MIME_types)) を返します。 -## 構文 - -```js -var name = file.type; -``` - ## 値 ファイルのタイプを示すメディアタイプ (MIME) を含む文字列。たとえば、 PNG 画像の場合は "image/png" です。 ## 例 +### HTML + ```html - + + ``` +```css hidden +output { + display: block; + white-space: pre-wrap; +} +``` + +### JavaScript + ```js -function showType(fileInput) { - var files = fileInput.files; +const output = document.getElementById("output"); +const filepicker = document.getElementById("filepicker"); + +filepicker.addEventListener("change", (event) => { + const files = event.target.files; + output.textContent = ""; - for (var i = 0; i < files.length; i++) { - var name = files[i].name; - var type = files[i].type; - alert("Filename: " + name + " , Type: " + type); + for (const file of files) { + output.textContent += `${file.name}: ${file.type || "unknown"}\n`; } -} +}); ``` +### 結果 + +{{EmbedLiveSample('Examples')}} + > **メモ:** 現在の実装に基づくと、ブラウザーは実際にファイルのバイトストリームを読み取ってメディアタイプを判断している訳ではありません。ファイルの拡張子に基づいて推測します。 PNG 画像ファイルを .txt に改名すると "_text/plain_" となり、"_image/png_" とはなりません。さらに `file.type` は一般的に、画像、 HTML 文書、音声、動画などの一般的なファイルタイプに対してのみ信頼できます。一般的ではないファイルの拡張子に対しては、空の文字列を返します。クライアントの構成 (Windows レジストリーなど) によっては、一般的なタイプの場合でも予期しない値が発生することがあります。**開発者は、このプロパティを唯一の検証方法として信頼しないことをお勧めします。** ## 仕様書 diff --git a/files/ja/web/api/file/webkitrelativepath/index.md b/files/ja/web/api/file/webkitrelativepath/index.md index 8d7f2aa8230460..9086d006befbf2 100644 --- a/files/ja/web/api/file/webkitrelativepath/index.md +++ b/files/ja/web/api/file/webkitrelativepath/index.md @@ -1,64 +1,66 @@ --- -title: File.webkitRelativePath +title: "File: webkitRelativePath プロパティ" +short-title: webkitRelativePath slug: Web/API/File/webkitRelativePath +l10n: + sourceCommit: 339595951b78774e951b1a9d215a6db6b856f6b2 --- -{{APIRef("File API")}}{{non-standard_header}} +{{APIRef("File API")}} -**`File.webkitRelativePath`** は、 [`webkitdirectory`](/ja/docs/Web/HTML/Element/input#webkitdirectory) 属性が設定された {{HTMLElement("input")}} 要素でユーザーが選択したディレクトリーに対するファイルのパスを指定する {{domxref("USVString")}} を持つ読み取り専用のプロパティです。 +**`File.webkitRelativePath`** は、[`webkitdirectory`](/ja/docs/Web/HTML/Element/input#webkitdirectory) 属性が設定された {{HTMLElement("input")}} 要素で、ユーザーが選択したディレクトリーに対するファイルのパスを指定する文字列を持つ読み取り専用のプロパティです。 -## 構文 +## 値 -```js -relativePath = File.webkitRelativePath -``` - -### 値 - -ユーザーが選択した祖先ディレクトリーを基準にしたファイルのパスを含む {{domxref("USVString")}}。 +ユーザーが選択した祖先ディレクトリーを基準にしたファイルのパスを含む文字列。 ## 例 この例では、ユーザーが 1 つまたは複数のディレクトリーを選択することができるディレクトリーピッカーが表示されます。 {{domxref("HTMLElement/change_event", "change")}} イベントが発生すると、選択されたディレクトリ階層に含まれるすべてのファイルのリストが生成され、表示されます。 -### HTML コンテンツ +### HTML ```html -
      + ``` -### JavaScript コンテンツ +```css hidden +output { + display: block; + white-space: pre-wrap; +} +``` + +### JavaScript ```js -document.getElementById("filepicker").addEventListener("change", function(event) { - let output = document.getElementById("listing"); - let files = event.target.files; - - for (let i=0; i { + const files = event.target.files; + + for (const file of files) { + output.textContent += `${file.webkitRelativePath}\n`; + } +}); ``` ### 結果 -{{ EmbedLiveSample('Example') }} +{{EmbedLiveSample('Example')}} ## 仕様書 {{Specifications}} -この API には、公式の W3C または WHATWG 仕様はありません。 - ## ブラウザーの互換性 {{Compat}} ## 関連情報 -- [File and Directory Entries API](/ja/docs/Web/API/File_and_Directory_Entries_API) +- [ファイルとディレクトリー項目 API](/ja/docs/Web/API/File_and_Directory_Entries_API) - {{domxref("HTMLInputElement.webkitEntries")}} - {{domxref("HTMLInputElement.webkitdirectory")}} From 6cb0f57a3455a84e625f852947f9caa9228a07d6 Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Tue, 25 Jul 2023 01:26:30 +0900 Subject: [PATCH 30/30] =?UTF-8?q?2023/04/15=20=E6=99=82=E7=82=B9=E3=81=AE?= =?UTF-8?q?=E8=8B=B1=E8=AA=9E=E7=89=88=E3=81=AB=E5=90=8C=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- files/ja/web/api/file/index.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/files/ja/web/api/file/index.md b/files/ja/web/api/file/index.md index ae4a60ac5c3919..fb09cd0a48ec84 100644 --- a/files/ja/web/api/file/index.md +++ b/files/ja/web/api/file/index.md @@ -1,15 +1,17 @@ --- title: File slug: Web/API/File +l10n: + sourceCommit: 2a09bee9b36fd9a53c1bce641297021bfe274a33 --- -{{APIRef}} +{{APIRef("File API")}} **`File`** インターフェイスは、ファイルについての情報を提供したり、ウェブページ内の JavaScript からその内容にアクセスできるようにしたりします。 -`File` オブジェクトは通常、 {{HTMLElement("input")}} 要素を使用してファイルを選択した結果として返される {{DOMxRef("FileList")}} オブジェクト、ドラッグ&ドロップ操作の {{DOMxRef("DataTransfer")}} オブジェクト、または {{DOMxRef("HTMLCanvasElement")}} 上の `mozGetAsFile()` API から取得します。 +`File` オブジェクトは通常、{{HTMLElement("input")}} 要素を使用してファイルを選択した結果として返される {{DOMxRef("FileList")}} オブジェクト、またはドラッグ&ドロップ操作の {{DOMxRef("DataTransfer")}} オブジェクトから取得します。 -`File` オブジェクトは特別な種類の {{DOMxRef("Blob")}} オブジェクトであり、 Blob が利用できる場面ではどこでも利用できます。特に、{{DOMxRef("FileReader")}}、{{DOMxRef("URL.createObjectURL()")}}、{{DOMxRef("createImageBitmap()")}}、{{DOMxRef("XMLHttpRequest", "", "send()")}} は、`Blob` と `File` の両方を受け付けます。 +`File` オブジェクトは特別な種類の {{DOMxRef("Blob")}} オブジェクトであり、 Blob が利用できる場面ではどこでも利用できます。特に、{{DOMxRef("FileReader")}}、{{DOMxRef("URL.createObjectURL_static")}}、{{DOMxRef("createImageBitmap()")}}、{{DOMxRef("XMLHttpRequest", "", "send()")}} は、`Blob` と `File` の両方を受け付けます。 詳しい情報や例は、[ウェブアプリケーションからのファイルの使用](/ja/docs/Web/API/File_API/Using_files_from_web_applications) を参照してください。 @@ -24,16 +26,16 @@ slug: Web/API/File - {{DOMxRef("File.prototype.lastModified")}} {{ReadOnlyInline}} - : ファイルの最終更新時刻を、 UNIX 元期 (1970 年 1 月 1 日深夜) からの経過ミリ秒数で返します。 -- {{DOMxRef("File.prototype.lastModifiedDate")}} {{Deprecated_Inline}} {{ReadOnlyInline}} +- {{DOMxRef("File.prototype.lastModifiedDate")}} {{Deprecated_Inline}} {{ReadOnlyInline}} {{Non-standard_Inline}} - : `File` オブジェクトが参照しているファイルの最終更新時刻の {{JSxRef("Date")}} を返します。 -- {{DOMxRef("File.prototype.name")}}{{ReadOnlyInline}} +- {{DOMxRef("File.prototype.name")}} {{ReadOnlyInline}} - : `File` オブジェクトが参照しているファイルの名前を返します。 -- {{DOMxRef("File.prototype.webkitRelativePath")}} {{Non-standard_Inline}} {{ReadOnlyInline}} +- {{DOMxRef("File.prototype.webkitRelativePath")}} {{ReadOnlyInline}} - : {{DOMxRef("File")}} の URL の相対パスを返します。 `File` は {{DOMxRef("Blob")}} を実装しているので、以下のようなプロパティも利用できます。 -- {{DOMxRef("File.prototype.size")}} {{ReadOnlyInline}} +- {{DOMxRef("Blob.size")}} {{ReadOnlyInline}} - : ファイルのサイズをバイト単位で返します。 - {{DOMxRef("File.prototype.type")}} {{ReadOnlyInline}} - : ファイルの [MIME](/ja/docs/Web/HTTP/Basics_of_HTTP/MIME_types) タイプを返します。 @@ -47,7 +49,7 @@ _`File` インターフェイスはメソッドを定義せず、{{DOMxRef("Blob - {{DOMxRef("Blob.prototype.stream()")}} - : `File` を {{DOMxRef("ReadableStream")}} に変換し、`File` の内容を読み込めるようにします。 - {{DOMxRef("Blob.prototype.text()")}} - - : `File` をストリームに変換し、最後まで読み込みます。これは、{{DOMxRef("USVString")}} (テキスト) で解決するプロミスを返します。 + - : `File` をストリームに変換し、最後まで読み込みます。これは、文字列(テキスト)で解決するプロミスを返します。 - {{DOMxRef("Blob.prototype.arrayBuffer()")}} - : `File` をストリームに変換し、最後まで読み込みます。 {{jsxref("ArrayBuffer")}} で解決するプロミスを返します。 @@ -63,4 +65,3 @@ _`File` インターフェイスはメソッドを定義せず、{{DOMxRef("Blob - [ウェブアプリケーションからのファイルの使用](/ja/docs/Web/API/File_API/Using_files_from_web_applications) - {{DOMxRef("FileReader")}} -- [DOM の File API をクロームコードで使う](/ja/docs/Extensions/Using_the_DOM_File_API_in_chrome_code) (Firefox アドオンのような Gecko で実行される特権コード向け)