aboutsummaryrefslogtreecommitdiff
path: root/files/zh-tw/conflicting/web/javascript/guide/functions_536f6bf46bbdf38cc1a0b28ca1bc41b9/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-tw/conflicting/web/javascript/guide/functions_536f6bf46bbdf38cc1a0b28ca1bc41b9/index.html')
-rw-r--r--files/zh-tw/conflicting/web/javascript/guide/functions_536f6bf46bbdf38cc1a0b28ca1bc41b9/index.html37
1 files changed, 37 insertions, 0 deletions
diff --git a/files/zh-tw/conflicting/web/javascript/guide/functions_536f6bf46bbdf38cc1a0b28ca1bc41b9/index.html b/files/zh-tw/conflicting/web/javascript/guide/functions_536f6bf46bbdf38cc1a0b28ca1bc41b9/index.html
new file mode 100644
index 0000000000..2c791124d8
--- /dev/null
+++ b/files/zh-tw/conflicting/web/javascript/guide/functions_536f6bf46bbdf38cc1a0b28ca1bc41b9/index.html
@@ -0,0 +1,37 @@
+---
+title: Number 和 String 函數
+slug: conflicting/Web/JavaScript/Guide/Functions_536f6bf46bbdf38cc1a0b28ca1bc41b9
+translation_of: Web/JavaScript/Guide/Functions
+translation_of_original: >-
+ Web/JavaScript/Guide/Obsolete_Pages/Predefined_Functions/parseInt_and_parseFloat_Functions
+original_slug: >-
+ Web/JavaScript/Obsolete_Pages/Obsolete_Pages/Obsolete_Pages/預先定義的函數/Number_和_String_函數
+---
+<h4 id="Number_和_String_函數">Number 和 String 函數</h4>
+<div class="onlyinclude">
+<p><code>Number</code> 和 <code>String</code> 函數讓你把物件轉換為數字或字串。這些函數的語句是︰</p>
+<pre>var objRef=Number(objRef);
+var objRef=String(objRef);
+</pre>
+<p>此處的 <code>objRef</code> 就是物件的參考。</p>
+<p>以下的範例把 <code><a class="internal" href="/zh_tw/Core_JavaScript_1.5_%E5%8F%83%E8%80%83/%E5%85%A8%E5%9F%9F%E7%89%A9%E4%BB%B6/Date" title="zh tw/Core JavaScript 1.5 參考/全域物件/Date">Date</a></code> 物件轉換為可讀的字串。</p>
+<pre>var D = new Date (430054663215);
+// 返回以下字串
+// "Thu Aug 18 04:37:43 GMT-0700 (Pacific Daylight Time) 1983"
+var x = String(D);
+</pre>
+</div>
+<p> </p>
+<p>以下範例把 <code><a class="internal" href="/zh_tw/Core_JavaScript_1.5_%E5%8F%83%E8%80%83/%E5%85%A8%E5%9F%9F%E7%89%A9%E4%BB%B6/String" title="zh tw/Core JavaScript 1.5 參考/全域物件/String">String</a></code> 物件轉換為 <a class="internal" href="/zh_tw/Core_JavaScript_1.5_%E5%8F%83%E8%80%83/%E5%85%A8%E5%9F%9F%E7%89%A9%E4%BB%B6/Number" title="zh tw/Core JavaScript 1.5 參考/全域物件/Number"><font face="Courier New">Number</font></a> 物件。</p>
+<pre>var str="12";
+var num=Number(str);
+</pre>
+<p>你可以使用 DOM 的方法 write() 和 JavaScript 的 typeof 運算子來檢驗。</p>
+<pre>var str="12";
+document.write(typeof str);
+document.write("&lt;br/&gt;");
+var num=Number(str);
+document.write(typeof num);
+</pre>
+<p> {{ PreviousNext("Core_JavaScript_1.5_教學:預先定義的函數:parseInt_和_parseFloat_函數", "Core_JavaScript_1.5_教學:預先定義的函數:escape_和_unescape_函數") }}</p>
+<p>{{ languages( {"en": "en/Core_JavaScript_1.5_Guide/Predefined_Functions/Number_and_String_Functions", "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>