[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/String/toString [Back]  [Original]

String.prototype.toString() - JavaScript | MDN

Esta pgina foi traduzida do ingls pela comunidade. Saiba mais e junte-se comunidade MDN Web Docs.

View in English Always switch to English

String.prototype.toString()

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since julho de 2015.

O mtodo toString() retorna uma string representando o objeto especificado.

In this article

Sintaxe

str.toString()

Descrio

O objeto String substitui o mtodo toString() do objeto Object. Ele no herda Object.prototype.toString(). Para objetos String, o mtodo toString() retorna uma representao de string do objeto e o mesmo que o mtodo String.prototype.valueOf().

Exemplos

Usando toString()

O exemplo a seguir exibe o valor string de um objeto String:

js
var x = new String("Hello world");

console.log(x.toString()); // retorna 'Hello world'

Especificaes

Specification
ECMAScript 2027 LanguageSpecification
# sec-string.prototype.tostring

Veja tambm


Web Proxy Viewer  |  New URL  |  Original Page