我看了一个教程,做了同样的事情。现在,此“未定义”错误不断显示我什至在其他浏览器中尝试过但结果相同。我是JS新手,需要帮助,谢谢。
<html>
<head>
<script type="text/javascript">
function person(name, age){
this.name = name;
this.age = age;
}
var milz = new person("milz", 23);
var stefi = new person("stefi", 19);
</script>
</head>
<body>
<script type="text/javascript">
document.write("hello ");
document.write(stefi.age);
</script>
</body>
</html>
答案 0 :(得分:2)
<html>
<head>
<script type="text/javascript">
function person(name, age){
this.name = name;
this.age = age;
}
var milz = new person("milz", 23);
var stefi = new person("stefi", 19);
</script>
</head>
<body>
<script type="text/javascript">
document.write("hello ");
document.write(stefi.age);
</script>
</body>
</html>