bind( fn, [scope], [args], [appendArgs] ) : Function
Create a new function from the provided fn, change this to the provided scope, optionally overrides arguments for the call. (Defaults to the arguments passed by the caller)

从提供的fn中创建一个新的函数,改变this到提供的scope,可选的重写调用参数。(默认为由调用方传递的参数)。

Ext.bind is alias for Ext.Function.bind
Ext.bind是Ext.Function.bind的别名

Parameters
fn : Function
The function to delegate.
去代理的函数

scope : Object (optional)
The scope (this reference) in which the function is executed.
If omitted, defaults to the default global environment object (usually the browser window).
函数执行的scope(this引用)
如果忽略了,默认是默认的全局环境变量(通常浏览器window)

args : Array (optional)
Overrides arguments for the call. (Defaults to the arguments passed by the caller)
重写调用参数(默认为由调用者传递的参数)

appendArgs : Boolean/Number (optional)
if True args are appended to call args instead of overriding, if a number the args are inserted at the specified position
如果true,args被追加到调用参数而不是重写;如果一个数字,args被插入在指定的位置。

appendArgs:
不指定或者false:重写参数
true:追加参数
数字:指定位置插入参数
下面是使用例子:

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="UTF-8">
<title>定义</title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="js/ext4/resources/css/ext-all.css">
<link rel="stylesheet" type="text/css" href="css/icon.css">
<!-- <script type="text/javascript" src="js/ext4/bootstrap.js"></script> -->
<script type="text/javascript" src="js/ext4/ext-all-dev.js"></script> <script type="text/javascript" src="js/ext4/locale/ext-lang-zh_CN.js"></script>
<script type="text/javascript">
//设置命名空间路径
Ext.Loader.setPath('org', './js/org');
Ext.onReady(initFn); /**
* 初始化函数
*/
function initFn(){
console.info('Ext准备完毕~~~');
var doAdd = Ext.bind(function(x,y){
var self = this;
console.info('self:',self);
console.info('self==window:',self==window);
return x+y;
}); var result0 = doAdd(5,6);
console.info('result0:',result0); var doSubtract = Ext.bind(function(x,y){
var self = this;
console.info('self:',self);
console.info('self==window:',self==window);
return x-y;
},{fullName:'张泰松',age:28,address:'杭州市西湖区'}); var result1 = doSubtract(15,9);
console.info('result1:',result1); var doMultiply = Ext.bind(function(x,y){
var self = this;
console.info('self:',self);
console.info('self==window:',self==window);
console.info("arguments:",arguments);
return x*y;
},{fullName:'李超军',age:30,email:'1032160369@qq.com'},[18,8],false); var result2 = doMultiply(16,6);
console.info('result2:',result2); var doDivide = Ext.bind(function(x,y){
var self = this;
console.info('self:',self);
console.info('self==window:',self==window);
console.info("arguments:",arguments);
return x/y;
},{fullName:'武利丹',age:29,email:'1175173151@qq.com'},[4,8],1); var result3 = doDivide(16,2);
console.info('result3:',result3);
/*
appendArgs:
不指定或者false:重写参数
true:追加参数
数字:指定位置插入参数
*/
}
</script>
</head>
<body> </body>
</html>

Ext.bind函数说明的更多相关文章

  1. (十一)socket、connect、bind函数详解

    一.socket函数 1.头文件: #include <sys/types.h> /* See NOTES */ #include <sys/socket.h> 2.函数原型: ...

  2. Javascript中call、apply、bind函数

    javascript在函数创建的时候除了自己定义的参数外还会自动新增this和arguments两个参数 javascript中函数也是对象,call.apply.bind函数就是函数中的三个函数,这 ...

  3. angular.bind() 函数

    angular.bind bind 函数有三个参数, 参一:是一个对象 参二:是一个 function 参三:是用来给参二传参数的,可写可不写,看你心情 参数也可以在调用函数的时候传,也可以当做第三个 ...

  4. jQuery.bind() 函数详解

    bind()函数用于为每个匹配元素的一个或多个事件绑定事件处理函数. 此外,你还可以额外传递给事件处理函数一些所需的数据. 执行bind()时,事件处理函数会绑定到每个匹配元素上.因此你使用bind( ...

  5. call,apply,bind函数

    一.call函数 a.call(b); 简单的理解:把a对象的方法应用到b对象上(a里如果有this,会指向b) call()的用法:用在函数上面 var Dog=function(){ this.n ...

  6. C++ Primer : 第十章 : 泛型算法 之 lambda表达式和bind函数

    一.lambda表达式 lambda表达式原型: [capture list] (parameter list) -> retrue type { function body } 一个lambd ...

  7. 模拟实现兼容低版本IE浏览器的原生bind()函数功能

    模拟实现兼容低版本IE浏览器的原生bind()函数功能: 代码如下: if(!Function.prototype.bind){   Function.prototype.bind=function( ...

  8. bind函数

    bind函数把一个本地协议地址赋予一个套接字 对于网际协议,协议地址是32位的IPv4地址或128位的IPv6与16位的TCP或UDP端口号的组合 int bind ( int sockfd, con ...

  9. js 中的bind函数

    bind是Function.prototype中内置函数 作用是指定函数作用域 代码参考 http://blog.csdn.net/load_life/article/details/7200381 ...

随机推荐

  1. 05-C#笔记-基本变量

    1. 不支持括号初始化: 2. 支持强制类型转化: 3.运算规则同C++ 参考: http://www.runoob.com/csharp/csharp-variables.html

  2. USACO Superprime Rib

    洛谷 P1218 [USACO1.5]特殊的质数肋骨 Superprime Rib 洛谷传送门 JDOJ 1673: Superprime Rib JDOJ传送门 题目描述 农民约翰的母牛总是产生最好 ...

  3. Lotus words

    We are going to memorize a lot of words in the fourth grade of primary school. It's very difficult f ...

  4. vue工具 - vue/cli@3.xx 安装使用流程

    mac安装记得npm前边加sudo 安装脚手架,用于生成目录 npm install -g @vue/cli 安装用于编译单个的.vue文件 npm install -g @vue/cli-servi ...

  5. Java判断文件类型

    通常,在WEB系统中,上传文件时都需要做文件的类型校验,大致有如下几种方法: 1. 通过后缀名,如exe,jpg,bmp,rar,zip等等. 2. 通过读取文件,获取文件的Content-type来 ...

  6. 【Gamma】Scrum Meeting 6

    前言 会议定点:大运村公寓 会议时间:2019/6/4 会议目的:明确测试中出现的bug 一.任务进度 组员 上周任务进度 下阶段任务 大娃 优化代码注释质量 修复后端bug 二娃 撰写会议博客 撰写 ...

  7. 学Redis这篇就够了!

    学Redis这篇就够了!   作者:王爷科技 https://www.toutiao.com/i6713520017595433485 Redis 简介 & 优势 Redis 数据类型 发布订 ...

  8. 【C/C++开发】emplace_back() 和 push_back 的区别

    在引入右值引用,转移构造函数,转移复制运算符之前,通常使用push_back()向容器中加入一个右值元素(临时对象)的时候,首先会调用构造函数构造这个临时对象,然后需要调用拷贝构造函数将这个临时对象放 ...

  9. Windows进程间各种通信方式浅谈(转)

    转自 https://blog.csdn.net/microzone/article/details/7044266 权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原 ...

  10. mapreduce 函数入门 一

    MapReduce 程序的业务编码分为两个大部分,一部分配置程序的运行信息,一部分 编写该 MapReduce 程序的业务逻辑,并且业务逻辑的 map 阶段和 reduce 阶段的代码分别继 承 Ma ...