Do you use 'this' in front of instance variables?

前端 未结 17 2139
猫巷女王i
猫巷女王i 2020-12-19 01:08

When accessing instance variables or properties of a class from within the class itself, do you prepend them with \"this.\"?

17条回答
  •  失恋的感觉
    2020-12-19 01:56

    I only ever use a this. prefix in constructors or setters, primarily in the case where the passed parameters have the same name as the relevant member variables.

提交回复
热议问题