代码示例:(标识:eg_js_type_convert_constructor_all)
<!DOCTYPE html>
<html>
<body>

<h2>JavaScript constructor 属性</h2>

<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>

</body>
</html>
运行结果: