JavaScript
JavaScript 类型转换
constructor 属性返回所有 JavaScript 变量的构造函数。
源代码:
点击运行 »
<p> constructor 属性返回变量或对象的构造函数。</p> <p id="demo"></p> <script> document.getElementById("demo").innerHTML = "john".constructor + "<br>" + (3.14).constructor + "<br>" + false.constructor + "<br>" + [1, 2, 3, 4].constructor + "<br>" + { name: 'john', age: 34 }.constructor + "<br>" + new Date().constructor + "<br>" + function() {}.constructor; </script>
运行结果:
点击运行 »