當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
JavaScript中的String()函数与示例
生活随笔
收集整理的這篇文章主要介紹了
JavaScript中的String()函数与示例
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
String()函數 (String() function)
String() function is a predefined global function in JavaScript, it is used to convert an object to the string.
String()函數是JavaScript中預定義的全局函數,用于將對象轉換為字符串。
Example:
例:
In this example, we are going to convert different object’s values to the string.
在此示例中,我們將把不同對象的值轉換為字符串。
<html> <head> <title>JavaScipt Example</title> </head><body><script> var a = "10"; var b = "10 20";var c = "1234 Hello";var d = "Hello 1234";var e = true; var f = new Date();//converting values to string using String() functiondocument.write("String(a) = " + String(a) + "<br>");document.write("String(b) = " + String(b) + "<br>");document.write("String(c) = " + String(c) + "<br>");document.write("String(d) = " + String(d) + "<br>");document.write("String(e) = " + String(e) + "<br>");document.write("String(f) = " + String(f) + "<br>");</script> </body> </html>Output
輸出量
String(a) = 10 String(b) = 10 20 String(c) = 1234 Hello String(d) = Hello 1234 String(e) = true String(f) = Sat Feb 02 2019 23:03:12 GMT+0530 (India Standard Time)翻譯自: https://www.includehelp.com/code-snippets/String-function-with-example-in-javascript.aspx
總結
以上是生活随笔為你收集整理的JavaScript中的String()函数与示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: scala 随机生成整数_如何在Scal
- 下一篇: “神居既崇盛”上一句是什么