<html>
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript">
function Person(name,age,gender){
this.name = name;
this.age = age;
this.gender = gender;
}
var per = new Person("孙悟空",16,"男");
per.toString = function(){
return "Person[name="+this.name+",age= "+this.age+",gender="+this.gender+"]"
return "Person[name=孙悟空,age= 18,gender=男]"
}
console.log("per="+per);
</script>
</head>
<body>
</body>
</html>
问题一:为什么上面的变量this.name要加双引号,而且前后还加了两个+号?
问题二:为什么孙悟空这几个汉字作为字符串来说不能加引号?
产品经理不是经理
产品经理不是经理
相关分类