JavaScript String valueOf() method
- Προηγούμενη σελίδα trimStart()
- Επόμενη σελίδα at()
- Επιστροφή στο προηγούμενο επίπεδο Εγχειρίδιο Εφαρμογής JavaScript String
Definition and usage
valueOf()
The method returns the original value of the string.
valueOf()
The method does not change the original string.
valueOf()
The method can be used to convert a string object to a string.
See also:
Note
valueOf()
The method is the default method of JavaScript strings.
JavaScript 在内部使用它。
通常,您不会在代码中使用它。
Instance
Example 1
Get the value of the text:
let text = "Hello World!"; let result = text.valueOf();
It is equivalent to:
let text = "Hello World!"; let result = text;
Example 2
Get the value of the String object:
let text = new String("Hello World!"); let result = text.valueOf();
Syntax
string.valueOf()
Parameter
No parameters.
Return value
Type | Description |
---|---|
String | The original value of the string. |
Thrown
Exception | Description |
---|---|
TypeError | An exception is thrown when the object calling this method is not a String. |
Browser support
valueOf()
It is an ECMAScript1 (ES1) feature.
All browsers support ES1 (JavaScript 1997):
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Υποστήριξη | Υποστήριξη | Υποστήριξη | Υποστήριξη | Υποστήριξη | Υποστήριξη |
Σχετικές σελίδες
- Προηγούμενη σελίδα trimStart()
- Επόμενη σελίδα at()
- Επιστροφή στο προηγούμενο επίπεδο Εγχειρίδιο Εφαρμογής JavaScript String