zoukankan      html  css  js  c++  java
  • JavaScript String() 函数

    [

    JavaScript String() 函数
    JavaScript 全局函数

    定义和用法

    String() 函数把对象的值转换为字符串。

    语法

    String(object)

    参数 描述
    object 必需。JavaScript 对象。

    浏览器支持

    所有主要浏览器都支持 String() 函数

    提示和注释

    注意: String() 函数返回与字符串对象的toString()方法值一样。

    实例

    实例

    把不同的对象转换为字符串:

    
    <script>
    
    var test1 = new Boolean(1);
    
    var test2 = new Boolean(0);
    
    var test3 = new Boolean(true);
    
    var test4 = new Boolean(false);
    
    var test5 = new Date();
    
    var test6 = new String("999 888");
    
    var test7 = 12345;
    
    document.write(String(test1)+ "<br>");
    
    document.write(String(test2)+ "<br>");
    
    document.write(String(test3)+ "<br>");
    
    document.write(String(test4)+ "<br>");
    
    document.write(String(test5)+ "<br>");
    
    document.write(String(test6)+ "<br>");
    
    document.write(String(test7)+ "<br>");
    
    </script>
    
    

    以上实例输出结果:

    
    
    var test1= new Boolean(1)
    
    var test2= new Boolean(0)
    
    var test3= new Boolean(true)
    
    var test4= new Boolean(false)
    
    var test5= new Date()
    
    var test6= new String("999 888")
    
    var test7=12345
    
    
    
    document.write(String(test1)+ "<br>")
    
    document.write(String(test2)+ "<br>")
    
    document.write(String(test3)+ "<br>")
    
    document.write(String(test4)+ "<br>")
    
    document.write(String(test5)+ "<br>")
    
    document.write(String(test6)+ "<br>")
    
    document.write(String(test7)+ "<br>")
    
    
    

    JavaScript 全局函数

    ]
    转载请保留页面地址:https://www.breakyizhan.com/javascript/24622.html
  • 相关阅读:
    Instruments Tutorial for iOS: How To Debug Memory Leaks
    How to Use Instruments in Xcode
    Demystifying iOS Application Crash Logs
    “iOS 推送通知”详解:从创建到设置到运行
    推送通知iOS客户端编写实现及推送服务器端编写
    cocos2d-iphone 与 UI组件
    ScrollLayer
    TexturePacker
    mybatis的配置
    spring+redis
  • 原文地址:https://www.cnblogs.com/breakyizhan/p/13281315.html
Copyright © 2011-2022 走看看