视频中定义圆的半径的问题
来源:2-2 画圆函数介绍
Coolyang_
2018-04-04 17:47:24
这里为什么不用 var来声明一个变量r来存储半径的值呢?
this.r,那么这里的r是代表this对象的属性,还是代表定义在this对象下的局部变量?
3回答
大迷糊虫
2018-04-06
这里的this指的是当前的
Coolyang_
提问者
2018-04-04
<script> var test = function () { this.str1 = 'hello world'; var str2 = 'hello world'; console.log(this.str1); console.log(str2); console.log(this.str1.length); console.log(str2.length); } test(); </script>
他们两个之间有什么区别?
一路电光带火花
2018-04-04
这里是对象的成员属性。应该是this的指向问题,可以改一下直接声明没有效果。
相似问题