"All-station engineer Practice Notes" Web front-end Custom JS object object_list

Source: Internet
Author: User

    functionobject_list () {return Newobject_list.fn.init (arguments); } Object_list.fn= Object_list.prototype ={constructor:object_list, init:function(args) { This. usedefaultlist =true;  This. Object = {}; return  This;    }    }; Object_list.fn.init.prototype=Object_list.fn; Object_list.prototype.clear=function(){        varK = Arguments[0]; if(k && This. has (k)) {Delete  This. Object[k];} Else{ This. Object = {};} } Object_list.prototype.push=function(k,v) {if( This. Usedefaultlist) {            if(! This. Object[k]) {                 This. object[k] =NewArray (); }             This. Object[k].push (v); }Else{            if(! This. Object[k]) {                 This. object[k] =v; }Else{                varL = This. Object[k]; vararr =NewArray ();                Arr.push (l);                Arr.push (v);  This. object[k] =arr; }        }        return  This;    }; Object_list.prototype.has=function(k) {return  This. object[k]! =undefined;}; Object_list.prototype.get=function(k) {return  This. Object[k];    }; Object_list.prototype.safe_get_call=function(k,target,_func_) {if( This. has (k)) {_func_.call ( ThisK This. Get (k));    }    }; Object_list.prototype.get_with_default=function(k,d) {return  This. has (k)? This. Get (k):d;    }; Object_list.prototype. for=function () {        varf = arguments[0]; varRstr= arguments[1]! = Undefined?arguments[1]: ""; varR = (R.tolowercase (). IndexOf ("r")! =-1)?true:false;  for(varKinch  This. Object) {            if(!R) {f (k,0, This. Object[k]); }Else{                if(Is_array ( This. Object[k])) {                     for(varJinch  This. Object[k]) {f (k,j, This. Object[k][j]); }                }Else{f (k,0, This. Object[k]);    }            }        }    }; Object_list.prototype.for_with_target=function () {        varf = arguments[0]; vartarget = arguments[1]; varRstr= arguments[2]! = undefined?arguments[2]: ""; varR = (R.tolowercase (). IndexOf ("r")! =-1)?true:false;  for(varKinch  This. Object) {            if(!R) {f (k,0, This. Object[k]); }Else{                if(Is_array ( This. Object[k])) {                     for(varJinch  This. Object[k]) {F.call (target,k,j, This. Object[k][j]); }                }Else{f.call (target,k,0, This. Object[k]);    }            }        }    }; Win.object_list= Object_list;

"All-station engineer Practice Notes" Web front-end Custom JS object object_list

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.