`
izuoyan
  • 浏览: 9223977 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

About Bind in Prototype JavaScript Language.

 
阅读更多
This is the first article on JavaScript, more will be put here in Chinese maybe.
Some reference is from the Prototype website, and some from JavaScript the definitive guide 5th edition, rest is my comment. hope this helps.

/*
“Binding” basically determines the meaning, when a function runs, of the this keyword.
While there usually is a proper default binding (this refers to whichever object the method is called on),
this can be “lost” sometimes, for instance when passing a function reference as an argument.

the execution scope is the object from which the function was called,
or (more precisely) the object that holds a reference to the function.
*/
bind: function() {
if (arguments.length < 2 && arguments[0] === undefined) return this; // if nothing to bind in arguments
/* following has a $A function call, basically reference the current argument or copy current argument into a newly created array. which maintain the value of the arguments for the binding function ^^ */
var __method = this, args = $A(arguments), object = args.shift(); // object set to the first element in the arguments
/*
The Array.concat() method creates and returns a new array that contains the elements of the original
array on which concat() was invoked, followed by each of the arguments to concat(). If any of these
arguments is itself an array, it is flattened, and its elements are added to the returned array. Note,
however, that concat() does not recursively flatten arrays of arrays.
*/
/*
Functions are objects in JavaScript, and apply allows you to apply the method of one object
in another object, which basically means your controlling the execution scope.
*/
return function() {
return __method.apply(object, args.concat($A(arguments))); // arguments here is newly passed in arguments, not the one above!
}
},
分享到:
评论

相关推荐

    bind安装包bind-9.8.4.tar.gz

    BIND,全称Berkeley Internet Name Domain,是互联网上最广泛使用的域名系统(DNS)服务器软件。这个"bind-9.8.4.tar.gz"安装包是用于在Linux操作系统上搭建DNS服务器的关键组件。以下是关于BIND及其安装过程的详细...

    jakarta.xml.bind-api-2.3.3-API文档-中文版.zip

    赠送jar包:jakarta.xml.bind-api-2.3.3.jar; 赠送原API文档:jakarta.xml.bind-api-2.3.3-javadoc.jar; 赠送源代码:jakarta.xml.bind-api-2.3.3-sources.jar; 赠送Maven依赖信息文件:jakarta.xml.bind-api-...

    bind-9.6.2.P2.tar.gz

    《深入理解DNS服务器:以bind-9.6.2.P2为例》 DNS(Domain Name System)域名系统是互联网的一项核心服务,它将人类可读的域名转换为计算机可识别的IP地址。bind(Berkeley Internet Name Domain)是全球最广泛使用...

    bind-9.9.4-29.el7.x86_64.rpm

    bind-9.9.4-29.el7.x86_64.rpm rhel-server-7.2-x86_64 丢失文件的小伙伴可以下载来补全。。

    bind-9.11.2-P1.tar.gz

    DNS服务器搭建的bind安装包,该安装包为源码压缩包,适用于linux操作系统 DNS服务器搭建的bind安装包,该安装包为源码压缩包,适用于linux操作系统DNS服务器搭建的bind安装包,该安装包为源码压缩包,适用于linux...

    jakarta.xml.bind-api-2.3.2-API文档-中文版.zip

    赠送jar包:jakarta.xml.bind-api-2.3.2.jar; 赠送原API文档:jakarta.xml.bind-api-2.3.2-javadoc.jar; 赠送源代码:jakarta.xml.bind-api-2.3.2-sources.jar; 赠送Maven依赖信息文件:jakarta.xml.bind-api-...

    jakarta.xml.bind-api-2.3.3-API文档-中英对照版.zip

    赠送jar包:jakarta.xml.bind-api-2.3.3.jar; 赠送原API文档:jakarta.xml.bind-api-2.3.3-javadoc.jar; 赠送源代码:jakarta.xml.bind-api-2.3.3-sources.jar; 赠送Maven依赖信息文件:jakarta.xml.bind-api-...

    bind-8.2.1.tar.gz_BIND 8.2.1 download_bind_bind-9.5.0.tar.gz_dns

    BIND,全称Berkeley Internet Name Domain,是互联网上最广泛使用的域名系统(DNS)服务器软件之一。这个软件包包括了两个版本的BIND:8.2.1和9.5.0,分别以"bind-8.2.1.tar.gz"和"bind-9.5.0.tar.gz"的形式提供。...

    jakarta.xml.bind-api-2.3.2.jar

    java运行依赖jar包

    bind-9.3.6-20.P1.el5_8.6.x86_64.rpm

    linux补丁包bind-9.3.6-20.P1.el5_8.6.x86_64.rpm

    bind-9.2.3.tar.gz

    《bind-9.2.3 DNS服务器安装与配置详解》 在互联网的基础设施中,DNS(Domain Name System)系统扮演着至关重要的角色,它将人类可读的域名转化为机器可识别的IP地址,使得网络通信得以顺利进行。本文将详细阐述...

    bind-9.8.0-P2.tar.gz

    DNS 最新版源代码 bind-9.8.0-P2.tar.gz

    system-config-bind-4.0.3-4.el5.noarch.rpm

    Linux redhat5_4 DNs服务器配置安装包 system-config-bind-4.0.3-4.el5.noarch.rpm

    bind-9.3.0.tar.gz

    BIND(Berkeley Internet Name Domain)是互联网上广泛使用的域名系统(DNS)服务器软件,由Internet Systems Consortium(ISC)开发和维护。此版本“bind-9.3.0.tar.gz”是一个压缩包,包含了BIND 9.3.0的源代码,...

    bind-9.11.4-26.P2.el7_9.7.x86_64.rpm

    官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装

    bind-9.11.4-26.P2.el7_9.4.x86_64.rpm

    官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装

    jakarta.xml.bind-api-2.3.2-API文档-中英对照版.zip

    赠送jar包:jakarta.xml.bind-api-2.3.2.jar; 赠送原API文档:jakarta.xml.bind-api-2.3.2-javadoc.jar; 赠送源代码:jakarta.xml.bind-api-2.3.2-sources.jar; 赠送Maven依赖信息文件:jakarta.xml.bind-api-...

    prototype-1.6.0.2.js.rar

    2. **Function.prototype.bind**:让函数拥有指定的上下文(this值),解决了JavaScript中this动态绑定的问题。 3. **Element**和**$$**:提供了一套强大的DOM操作接口,Element对象可以对HTML元素进行各种操作,$$...

    bind-9.11.4-26.P2.el7_9.8.x86_64.rpm

    官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装

    bind-9.3.6-4.P1.el5_4.2.x86_64.rpm

    bind-9.3.6-4.P1.el5_4.2.x86_64.rpm oracle安装过程中可能会提示你需要安装的依赖包

Global site tag (gtag.js) - Google Analytics