上一页 1 ··· 5 6 7 8 9
摘要: 特权方法:有权访问私有变量和私有函数的公有方法。在私有作用域中定义私有变量或函数,可以创建特权方法,如下:示例1(function(){ //私有变量和私有函数 var privateVariable = 10; function privateFunction(){ ... 阅读全文
posted @ 2015-12-14 13:41 tianxintian22 阅读(1335) 评论(0) 推荐(0) 编辑
摘要: function outputNumbers(count){ var privateVariable = 10;//私有/局部变量,函数外部不能被访问 publicVariable = 20;//全局变量,能够在函数外部被访问 (function(){ ... 阅读全文
posted @ 2015-12-11 22:54 tianxintian22 阅读(332) 评论(0) 推荐(0) 编辑
摘要: 1、定义函数: (1)函数声明 function 函数名(){}//指定函数名的方式 它的一个重要特征是函数声明提升,在执行代码之前会先读取函数声明。 (2) 函数表达式 var FunctionName = function(arg0, arg1, arg2){}//匿名函数 在使用之前必须先赋值 阅读全文
posted @ 2015-12-10 16:33 tianxintian22 阅读(501) 评论(0) 推荐(0) 编辑
摘要: ECMAScript只支持实现继承(继承实际的方法),主要依靠原型链来实现。1、原型链基本思想是利用原型让一个引用类型继承另一个引用类型的属性和方法。示例: function SuperType(){ this.property = true; //实例属性 } SuperType.protot... 阅读全文
posted @ 2015-12-09 21:17 tianxintian22 阅读(369) 评论(0) 推荐(0) 编辑
摘要: 1、原型模式创建对象(1)第一种function Newperson(){ }var person2 = new Newperson();Newperson.prototype.name = 'tom';Newperson.prototype.age = 22;Newperson.prototype... 阅读全文
posted @ 2015-12-04 15:46 tianxintian22 阅读(207) 评论(0) 推荐(0) 编辑
摘要: jQuery.noConflict()函数用于让出jQuery库对变量$(和变量jQuery)的控制权。一般情况下,在jQuery库中,变量$是变量jQuery的别名,它们之间是等价的,例如jQuery("p")和$("p")是等价的。由于变量$只有一个字符,并且特点鲜明,因此我们更加习惯使用$来操... 阅读全文
posted @ 2015-12-03 11:26 tianxintian22 阅读(168) 评论(0) 推荐(1) 编辑
上一页 1 ··· 5 6 7 8 9