网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

JavascriptStudyMemo

Javascript basic concept.....

我们提供的服务有:网站制作、做网站、微信公众号开发、网站优化、网站认证、黄岛ssl等。为上1000+企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的黄岛网站制作公司

[@more@]
  • Instance property: property defined in constructor:
    function Circle(radius) {
    	this.radius = radius;	
    }
    
  • Class property: property belongs to class. all instances share the only copy of class property:
    Circle.PI = 3.141592;
    Circle.UNIT = new Circle(1);
    	
    	
  • Instance method:An instance method can be invoked for any instance of a class, but this does not mean that each object contains its own private copy of the method, as it does with instance properties.Instead, instance method is defined by prototype property:
    Circle.prototype.area() { // notes: must explicitly specify thiskeyword to property
    	return Circle.PI * this.radius * this.radius;
    }
    	
  • Class method: method associated with a class rather than an instance of a class:
    Circle.max = function (a,b) {
    	if (a.r > b.r) {
    		return a;
    	}else {
    		return b;
    	}
    }
    

Function execute & Call Object Concept

When Invoke a function, the function scope is set to scope chain, and then add a new object known as call object to the front of the scope chain. the call object is initialized with parameters, local variable. If a nested function is invoked, the scope chain includes three objects: its own call object, the call object of outer object , and the global object.
uniqueID = function(){ // user can set id back to 0 by: uniqueID.id = 0
    if (!arguments.callee.id) 
        arguments.callee.id = 0;
    return arguments.callee.id++;
};

uid = (function(){ // closure, id is persistent and private
    var id = 0;
    return function(){
        return id++;
    };
})();

var ret = "";
var i = 10;

while (i--) {
    ret += uniqueID() + "t";
    uniqueID.id = 0;
}
alert(ret);

i = 10;
ret = "";
while (i--) {
    ret += uid() + "t";
}
alert(ret);


当前标题:JavascriptStudyMemo
当前URL:http://bjjierui.cn/article/ggsgdo.html

其他资讯