JS:private variables
来源:互联网 发布:西安航海家软件 编辑:程序博客网 时间:2024/05/20 22:37
- -Public properties can be accessed from outside the class
- -Private properties can only be accessed from within the class
this.property ="someValue"
will be public, whereas a property declared with var property ="hiddenValue"
will be private.Just as functions can have local variables which can only be accessed from within that function, objects can have private variables. Privatevariables are pieces of information you do not want to publicly share, and they can only be directly accessed from within the class.
The Person
class has been modified to have a private variable calledbankBalance
. Notice that it looks just like a normal variable, but it is defined inside the constructor for Person
without using this
, but instead usingvar
. This makes bankBalance
a private variable.
0 0
- JS:private variables
- OOP in JS, Part 1 : Public/Private Variables and Methods
- Learning Perl: 4.5. Private Variables in Subroutines
- Creating Protected and Private Variables in Objective-C Class
- Variables
- Variables
- Variables
- variables
- Variables
- JS学习(3)----Functions、Objects、variables
- js静态 public private 属性与方法
- js 类的private public属性
- js实现类似于java的private
- private
- private
- private
- private
- private
- [转] 挨踢职场求生法则
- 线程处理函数pthread_cleanup_push / pthread_cleanup_pop
- 关于分页,SQLServer中的top、MySql中的limit、Oracle中的rownum的区别?
- linux下C语言多线程(一)线程的创建与取消
- yum 的使用以及注意点
- JS:private variables
- JavaScript运算符优先级引起的bug
- vim 的一些插件
- 线程取消(pthread_cancel)
- HashMap结构,原理
- 开通博客前言
- mapview使用方法
- Eclipse常用快捷键
- Private Methods