Discuss
/
JavaScript
/
老师,我有两个地方不解。
老师,我有两个地方不解。
Topic source第二个问题是Student的构造函数的问题
可能是吧props.name
写成了this.name
,然后传入的Object
传给了this.name
正确的写法
//Constructor for Student
function Student (props) {
this.name = props.name||'wujunchuan';
}
- 1
U_can
1、为什么我用xiaoming.hello(),返回的是 Hello, [object,object]呢?难道不能调用Student的hello方法吗? 2、我调用xiaoming.name的时候返回的是: Object {name: "wencan", grade: 6},和您的结果不一样,为什么呢?