Number and String Functions

  • Revision slug: JavaScript/Guide/Obsolete_Pages/Predefined_Functions/Number_and_String_Functions
  • Revision title: Number and String Functions
  • Revision id: 117971
  • Created:
  • Creator: mmjo
  • Is current revision? No
  • Comment 4 words added

Revision Content

Number and String Functions

The Number and String functions let you convert an object to a number or a string. The syntax of these functions is:

Number(objRef)
String(objRef)

where objRef is an object reference.

The following example converts the Date object to a readable string.

D = new Date (430054663215)
// The following returns
// "Thu Aug 18 04:37:43 GMT-0700 (Pacific Daylight Time) 1983"
x = String(D)

{{ PreviousNext("Core_JavaScript_1.5_Guide:Predefined_Functions:parseInt_and_parseFloat_Functions", "Core_JavaScript_1.5_Guide:Predefined_Functions:escape_and_unescape_Functions") }}

{{ languages( { "es": "es/Gu\u00eda_JavaScript_1.5/Funciones_predefinidas/Funciones_Number_y_String", "fr": "fr/Guide_JavaScript_1.5/Fonctions_pr\u00e9d\u00e9finies/Les_fonctions_Number_et_String", "ja": "ja/Core_JavaScript_1.5_Guide/Predefined_Functions/Number_and_String_Functions", "pl": "pl/Przewodnik_po_j\u0119zyku_JavaScript_1.5/Funkcje_predefiniowane/Funkcje_Number_i_String" } ) }}

Revision Source

<h4>Number and String Functions</h4>
<div class="onlyinclude">
<p>The <code>Number</code> and <code>String</code> functions let you convert an object to a number or a string. The syntax of these functions is:</p>
<pre>Number(objRef)
String(objRef)
</pre>
<p>where <code>objRef</code> is an object reference.</p>
<p>The following example converts the <code><a href="/en/Core_JavaScript_1.5_Reference/Global_Objects/Date" title="en/Core_JavaScript_1.5_Reference/Global_Objects/Date">Date</a></code> object to a readable string.</p>
<pre>D = new Date (430054663215)
// The following returns
// "Thu Aug 18 04:37:43 GMT-0700 (Pacific Daylight Time) 1983"
x = String(D)
</pre>
</div>
<p>{{ PreviousNext("Core_JavaScript_1.5_Guide:Predefined_Functions:parseInt_and_parseFloat_Functions", "Core_JavaScript_1.5_Guide:Predefined_Functions:escape_and_unescape_Functions") }}</p>
<p>{{ languages( { "es": "es/Gu\u00eda_JavaScript_1.5/Funciones_predefinidas/Funciones_Number_y_String", "fr": "fr/Guide_JavaScript_1.5/Fonctions_pr\u00e9d\u00e9finies/Les_fonctions_Number_et_String", "ja": "ja/Core_JavaScript_1.5_Guide/Predefined_Functions/Number_and_String_Functions", "pl": "pl/Przewodnik_po_j\u0119zyku_JavaScript_1.5/Funkcje_predefiniowane/Funkcje_Number_i_String" } ) }}</p>
Revert to this revision