aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/javascript/reference/global_objects/string/fixed/index.md
blob: 482010f5286ef6800a703de9d3d52042bb48f552 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
---
title: String.prototype.fixed()
slug: Web/JavaScript/Reference/Global_Objects/String/fixed
tags:
  - Déprécié
  - JavaScript
  - Méthode
  - Prototype
  - Reference
  - String
translation_of: Web/JavaScript/Reference/Global_Objects/String/fixed
original_slug: Web/JavaScript/Reference/Objets_globaux/String/fixed
---
{{JSRef}}{{deprecated_header}}

La méthode **`fixed()`** permet de créer un élément HTML {{HTMLElement("tt")}}, ce qui permet d'afficher le texte de la chaîne de caractère dans une fonte à chasse fixe.

## Syntaxe

    str.fixed()

### Valeur de retour

Une chaîne de caractères représentant un élément HTML {{HTMLElement("tt")}}.

## Description

La méthode `fixed()` encadre une chaîne de caractères dans une balise `<tt>` :
`"<tt>str</tt>`"

## Exemples

L'exemple suivant illustre l'utilisation de la méthode `fixed` pour formater une chaîne de caractères :

```js
var worldString = "Coucou monde";

console.log(worldString.fixed());
// "<tt>Coucou monde</tt>"
```

## Spécifications

| Spécification                                                                                                | État                         | Commentaires                                                                                                                                                           |
| ------------------------------------------------------------------------------------------------------------ | ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| {{SpecName('ES6', '#sec-string.prototype.fixed', 'String.prototype.fixed')}}         | {{Spec2('ES6')}}         | Définition initiale. Implémentée dans JavaScript 1.0. Définie dans l'annexe B (normative) pour les fonctionnalités ECMAScript additionnelles pour les navigateurs web. |
| {{SpecName('ESDraft', '#sec-string.prototype.fixed', 'String.prototype.fixed')}} | {{Spec2('ESDraft')}} | Définie dans l'annexe B (normative) pour les fonctionnalités ECMAScript additionnelles pour les navigateurs web.                                                       |

## Compatibilité des navigateurs

{{Compat("javascript.builtins.String.fixed")}}

## Voir aussi

- {{jsxref("String.prototype.bold()")}}
- {{jsxref("String.prototype.italics()")}}
- {{jsxref("String.prototype.strike()")}}