搜索文档
首页
HTML/CSS
JavaScript
服务端开发
Java教程
移动端
数据库
当前位置:
首页
JavaScript
JavaScript 教程
JavaScript 对象
源代码
清空
点击运行
<!DOCTYPE html> <html> <title>JavaScript 构造函数示例 - 基础教程(div.cn)</title> <body> <p id="output"></p> <script> let x1 = new String(); // A new String object let x2 = new Number(); // A new Number object let x3 = new Boolean(); // A new Boolean object let x4 = new Object(); // A new Object object let x5 = new Array(); // A new Array object let x6 = new RegExp(); // A new RegExp object let x7 = new Date(); // A new Date object let x8 = new Function(); // A new Function object document.getElementById("output").innerHTML = "x1: " + typeof x1 + "<br>" + "x2: " + typeof x2 + "<br>" + "x3: " + typeof x3 + "<br>" + "x4: " + typeof x4 + "<br>" + "x5: " + typeof x5 + "<br>" + "x6: " + typeof x6 + "<br>" + "x7: " + typeof x7 + "<br>" + "x8: " + typeof x8; </script> </body> </html>
运行结果