Callable Objects
We learned in 7.11 that there are "array-like" objects that are not true arrays but can be treated like arrays for most purposes. A similar situation exists for functions. A callable object is any object that can be invoked in a function invocation expression. All function are callable, but not all callable objects are functions.
Callable objects that are not functions are encounted in two situations in today's JavaScript implementations. First, the IE web browser (version 8 and before) implements client-side methods such as Window.alert() and Document.getElementById() using callable host objects rather than native Function objects. The method work the same in IE as they do in other browsers, but they are not actually Function objects. IE9 switches to using true functions, so this kind of callable object will gradually become less common.
The other common form of callable objects are RegExp object directly as a shortcut for invoking its exec() method. This is a completely nonstandard feature of JavaScript that was introduced by Netscope and copied by other vendors for compatibility. Do not write code that relies on the callability of RegExp objects: this feature is likely to be deprecated and removed in the futrue. The typeof operator is not interoperable for callable RegExps. In some browsers it returns "function" and in others it returns "object".
If you want to determine whether an object is a true function object (and has function methods) you can test its class attribute using the technique shown in Example 6-4:
function isFunction(x) {
return Object.prototype.toString.call(x) === "[object Function]";
}
Note that this isFunction() function is quite similar to the isArray() function shown in 7.10.
Callable Objects的更多相关文章
- [c++] Callable Objects
Five kinds of callable objects: Functions Pointers to functions Objects of a class that overloads () ...
- c++11 Using Callable Objects, std::thread, std::bind, std::async, std::call_once
- is_callable Callbacks / Callables What is a “callable”? 可调用 回调函数
PHP: Callback / Callable 类型 - Manual https://www.php.net/manual/zh/language.types.callable.php Callb ...
- C++11语法糖
1.constexpr变量:声明为constexpr的变量一定是一个常量,新标准允许定义一种特殊的constexpr函数使得编译时就可计算结果,这样就能用constexpr函数去初始化constexp ...
- 【翻译十九】-java之执行器
Executors In all of the previous examples, there's a close connection between the task being done by ...
- [Code::Blocks] Install wxWidgets & openCV
The open source, cross platform, free C++ IDE. Code::Blocks is a free C++ IDE built to meet the most ...
- C++11lambda表达式
[C++11lambda表达式] mutable 修饰符,用于修改[]中以值传递的变量,无mutable修饰符的话则不行. 使用示例: #include <vector> #include ...
- 在 tornado 中异步无阻塞的执行耗时任务
在 tornado 中异步无阻塞的执行耗时任务 在 linux 上 tornado 是基于 epoll 的事件驱动框架,在网络事件上是无阻塞的.但是因为 tornado 自身是单线程的,所以如果我们在 ...
- Java Concurrency - 线程执行器
Usually, when you develop a simple, concurrent-programming application in Java, you create some Runn ...
随机推荐
- Python之常用模块1
1.time datetime模块 #_*_coding:utf-8_*_ __author__ = 'Alex Li' import time # print(time.clock()) #返回处理 ...
- 【JZOJ4755】【NOIP2016提高A组模拟9.4】快速荷叶叶变换
题目描述 输入 一行,包含两个整数N,M. 输出 1个整数,FHT(N,M) mod 1000000007的值. 样例输入 3 4 样例输出 1 数据范围 对于 40% 的数据,1 ≤ N,M ≤ 1 ...
- Ceph 之Multisite 下的bucket reshard
目录 一.背景和问题 二.bucket reshard 过程 主集群信息汇总 Multisite 下手动reshard References 一.背景和问题 默认情况下只有当单个bucket承载的ob ...
- jQuery迷你帮助查找功能
在线演示 本地下载
- CC-Debugger 最小调试接法
CC-Debugger 最小调试接法 以 CC2541 为例,最少需要四根 DD DC RST GND. 一般 VCC 目标调试板都有,所以这里你需要将 CC-Debugger 的 PIN 2 和 P ...
- QPS 提升60%,揭秘阿里巴巴轻量级开源 Web 服务器 Tengine 负载均衡算法
前言 在阿里七层流量入口接入层(Application Gateway)场景下, Nginx 官方的Smooth Weighted Round-Robin( SWRR )负载均衡算法已经无法再完美施展 ...
- HZOJ Permutation
输出原序列有45分…… 字典序最小可以和拓扑序联系起来. 根据原来的题意不是很可做,于是对原序列求逆,令q[p[i]]=i; 那么就成功将题意转化:相邻元素值的差大于等于k时可以交换,使序列字典序最小 ...
- 进入BIOS中,设置U盘启动
进入BIOS中,一般有system,boot,main,advanced,security等几个选项,main是主设置界面,譬如BIOS时间等等.boot是启动项的设置,我们今天就是要用到它. 找到b ...
- oracle函数 VSIZE(X)
[功能]返回X的大小(字节)数 [参数]x select vsize(user),user from dual; 返回:6 asdied select length('adfad合理') " ...
- 全文索引——CONTAINS 语法
Like直接在数据据中查找可以查到所有所需记录但是会扫描整个表会影响性能CONTAINS是基于全文索引进行查询,查询结果受系统全文索引分词的方法影响查询结果会不全.Select * FROM A Wh ...