Ext.bind函数说明
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函数说明的更多相关文章
- (十一)socket、connect、bind函数详解
		
一.socket函数 1.头文件: #include <sys/types.h> /* See NOTES */ #include <sys/socket.h> 2.函数原型: ...
 - Javascript中call、apply、bind函数
		
javascript在函数创建的时候除了自己定义的参数外还会自动新增this和arguments两个参数 javascript中函数也是对象,call.apply.bind函数就是函数中的三个函数,这 ...
 - angular.bind() 函数
		
angular.bind bind 函数有三个参数, 参一:是一个对象 参二:是一个 function 参三:是用来给参二传参数的,可写可不写,看你心情 参数也可以在调用函数的时候传,也可以当做第三个 ...
 - jQuery.bind() 函数详解
		
bind()函数用于为每个匹配元素的一个或多个事件绑定事件处理函数. 此外,你还可以额外传递给事件处理函数一些所需的数据. 执行bind()时,事件处理函数会绑定到每个匹配元素上.因此你使用bind( ...
 - call,apply,bind函数
		
一.call函数 a.call(b); 简单的理解:把a对象的方法应用到b对象上(a里如果有this,会指向b) call()的用法:用在函数上面 var Dog=function(){ this.n ...
 - C++ Primer : 第十章 : 泛型算法 之 lambda表达式和bind函数
		
一.lambda表达式 lambda表达式原型: [capture list] (parameter list) -> retrue type { function body } 一个lambd ...
 - 模拟实现兼容低版本IE浏览器的原生bind()函数功能
		
模拟实现兼容低版本IE浏览器的原生bind()函数功能: 代码如下: if(!Function.prototype.bind){ Function.prototype.bind=function( ...
 - bind函数
		
bind函数把一个本地协议地址赋予一个套接字 对于网际协议,协议地址是32位的IPv4地址或128位的IPv6与16位的TCP或UDP端口号的组合 int bind ( int sockfd, con ...
 - js 中的bind函数
		
bind是Function.prototype中内置函数 作用是指定函数作用域 代码参考 http://blog.csdn.net/load_life/article/details/7200381 ...
 
随机推荐
- MAC上配置idea环境时排查问题
			
现象:没有使用走公司maven仓库的setting.xml文件时,只有公司内部依赖 没有找到在idea的maven配置中指定 公司setting.xml后,所有的文件都提示找不到 解决办法:把公司se ...
 - 【神奇性质】【P5523】D [yLOI2019] 珍珠
			
D [yLOI2019] 珍珠 Description 给定一个 deque,要求支持 push_back 和 push_front 操作,并且查询前缀与非和以及后缀与非和. deque中只会有 \( ...
 - springboot事务
			
参考: 1.https://www.cnblogs.com/kesimin/p/9546225.html https://www.cnblogs.com/east7/p/10585724.html
 - 团队作业第五次—项目冲刺-Day1
			
Day1 项目相关 作业相关 具体描述 所属班级 2019秋福大软件工程实践Z班 作业要求 团队作业第五次-项目冲刺 作业正文 hunter--冲刺集合 团队名称 hunter小组 作业目标 最终做出 ...
 - MHA+keepalived集群环境搭建
			
整个MHA+keepalived集群环境搭建 1.1. 环境简介1.1.1.vmvare虚拟机,系统版本CentOS6.5 x86_64位最小化安装,mysql的版本5.7.21,1.1.2.虚拟机器 ...
 - AKKA Inbox收件箱
			
起因 得到ActorRef就可以给actor发送消息,但无法接收多回复,也不知道actor是否停止 Inbox收件箱出现就是解决这两个问题 示例 package akka.demo.actor imp ...
 - centos7下vs code编辑器字体与windows版本同步设置-安装中文字体,美化vscode
			
"editor.fontFamily": "Consolas, 'Courier New', monospace" 从window10系统中复制出以上字体,到C ...
 - Hyper-V虚拟机安装Ubuntu,启动的时候会出现:Please remove the installation medium,then press ENTER
			
Hyper-V虚拟机安装Ubuntu成功以后,重启的时候页面会一直卡在下面,并报Please remove the installation medium,then press ENTER,这是因为启 ...
 - 红米note7几个问题处理
			
1.听筒声音很小,外放正常,试了很多种方法,最终可行的是吧听筒网灰尘弄一下. 2.SAICLink车机互联:需要打开USB调试.USB安装.USB调试(安全设置)(不开启这个的话会连接后就断开).默认 ...
 - Kafka session.timeout.ms  heartbeat.interval.ms参数的区别以及对数据存储的一些思考
			
Kafka session.timeout.ms heartbeat.interval.ms参数的区别以及对数据存储的一些思考 在计算机世界中经常需要与数据打交道,这也是我们戏称CURD工程师的原因之 ...