`

javascript中private,public,static,construct的理解

阅读更多

//private,public,static,construct的理解
function class1()
{
 //private fields
 var m_first=1;
 var m_second=2;
 
 
 m_third=3;//全局变量
 
 //private method
 var method1=function()
 {
  alert(m_first);
 }
 var method2=function()
 {
  alert(m_second);
 }
 
 //public
 this.m_five=5;//在公有方法和原型方法中this表示实例对象
 this.method5=function()//在公有方法和原型方法中this表示实例对象
 {
  alert(this.m_five);
 }
 
 //构造函数用于调用私有函数
 //class1//名字可有可无
 {
  method1();
  method2();
 }
}
class1.m_fourth=4;//静态变量
class1.method3=function()//静态成员函数
{
 alert(this.toString);//在静态成员中this表示类本身这里是class1
 alert(this.m_fourth);
}

class1.prototype.method4=function()//public公有方法
{
 alert(this.toString);//在公有方法和原型方法中this表示实例对象
}

分享到:
评论

相关推荐

    php class中public,private,protected的区别以及实例分析

    一,public,private,protected的区别public:权限是最大的,可以内部调用,实例调用等。protected: 受保护类型,用于本类和继承类调用。private: 私有类型,只有在本类中使用。二,实例复制代码 代码如下:<?...

    Discuz!_X2笔记.pdf

    Discuz!_X2 笔记 单例模式(单一实例模式) class db { ...public static function instance() { if(!is_object(self::$obj)) { self::$obj = new self(); } return self::$obj; } } ?>....................

    Construct合成大西瓜H5游戏项目JavaScript源码Watermelon

    游戏将两个相同的水果组合到游戏中的玻璃容器中,每个水果组合都会根据水果组合获得分数。水果越大,获得的分数就越高。 玩法: 按住游戏屏幕引导水果掉落,尝试瞄准相同的水果来组合水果。确保它不超过玻璃容器。 ...

    Construct2源码-笔记

    Construct2 引擎Runtime源码 详细描述 有助于阅读引擎源码,加深对Construct2 引擎的理解

    construct2 三消示例

    一个H5游戏开发引擎Construct 2 的三消游戏工程文件 Demo, 注意,只能用construct 2 打开

    PHP实现类的多态帮助类ClassUtil

    public function __construct() { $args=func_get_args(); ClassUtil::callMethodForArgs($this,$args); } public function construct_() { echo ("0 args function is called "); } public ...

    Game Development with Construct 2: From Design to Realization

    Game Development with Construct 2: From Design to Realization By LEE STEMKOSKI, Evan Leider English | PDF | 2017 | 248 Pages | ISBN : 1484227832 | 9.6 MB Design and create video games using Construct...

    Construct 2 Repository v2 0.2

    Construct2添加插件的一个工具

    Beginning JavaScript with DOM Scripting and Ajax: Second Editon

    Construct good JavaScript syntax following modern coding practices Use JavaScript to communicate with the server and retrieve data Dynamically manipulate markup, validate forms and deal with images ...

    construct-2.00 for python

    construct-2.00 for python 2.5 安装时可直接将construct-2.00这个文件夹里的construct文件夹复制到C:\Python25\Lib\site-packages文件夹下就可以使用(我安装在c盘)

    construct2-r216-setup

    construct2 是一款简单的游戏开发软件。适合初学者制作一款简单的小游戏。

    Beginning JavaScript with DOM Scripting and Ajax (pdf + ePub)

    Construct good JavaScript syntax following modern coding practices Use JavaScript to communicate with the server and retrieve data Dynamically manipulate markup, validate forms and deal with images ...

    Python库 | construct-2.8.3.tar.gz

    资源分类:Python库 所属语言:Python 资源全名:construct-2.8.3.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    construct2中文版HTML5游戏开发工具

    construct2中文版HTML5游戏开发工具 construct2中文版HTML5游戏开发工具

    construct2个人版文件

    construct2 个人版文件 使用时直接将该文件放到安装目录下即可

    塔防 Construct2游戏

    塔防 Construct2游戏 关卡 属性攻击 。 这是一个我做的比较用心的Construct 2游戏了。

    Construct2 迷宫小游戏~

    Construct2 地牢 迷宫 这是我兴趣之余自学做的小游戏

    pax-construct

    通过pax-construct可以轻松创建管理OSGi项目 http://www.ops4j.org/projects/pax/construct/

    construct2 注册机

    construct2注册机,亲测可用,注册机,破解游戏制作软件专用

    淘宝API接口

    public static $Taoapi_Util; /** * @var Taoapi_Config */ public $ApiConfig; /** * @var Taoapi_Cache */ public $Cache; private $_ArrayModeData; public function __construct () { if (self:...

Global site tag (gtag.js) - Google Analytics