Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getter/setter not work when set value is object #1454

Closed
beanjs opened this issue May 30, 2018 · 0 comments
Closed

getter/setter not work when set value is object #1454

beanjs opened this issue May 30, 2018 · 0 comments

Comments

@beanjs
Copy link

beanjs commented May 30, 2018

code:

var jsobj={
set prop(value){
this._prop=value;
},
get prop(){
return this._prop;
}
};
jsobj.prop={a:'astring',b:1234};
console.log(jsobj.prop);
console.log(jsobj.prop.a);

output:

{
"a": "astring",
"b": 1234 }
Uncaught Error: Cannot read property 'a' of undefined
at line 1 col 79
...rop),console.log(jsobj.prop.a);
^
=undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant