ExtJs--15--Ext.is*各种类型推断的方法,简单看源代码就能够明确了
/**
* Returns true if the passed value is empty, false otherwise. The value is deemed to be empty if it is either:
*
* - `null`
* - `undefined`
* - a zero-length array
* - a zero-length string (Unless the `allowEmptyString` parameter is set to `true`)
*
* @param {Object} value The value to test
* @param {Boolean} allowEmptyString (optional) true to allow empty strings (defaults to false)
* @return {Boolean}
* @markdown
*/
isEmpty: function(value, allowEmptyString) {
return (value === null) || (value === undefined) || (!allowEmptyString ? value === '' : false) || (Ext.isArray(value) && value.length === 0);
}, /**
* Returns true if the passed value is a JavaScript Array, false otherwise.
*
* @param {Object} target The target to test
* @return {Boolean}
* @method
*/
isArray: ('isArray' in Array) ? Array.isArray : function(value) {
return toString.call(value) === '[object Array]';
}, /**
* Returns true if the passed value is a JavaScript Date object, false otherwise.
* @param {Object} object The object to test
* @return {Boolean}
*/
isDate: function(value) {
return toString.call(value) === '[object Date]';
}, /**
* Returns true if the passed value is a JavaScript Object, false otherwise.
* @param {Object} value The value to test
* @return {Boolean}
* @method
*/
isObject: (toString.call(null) === '[object Object]') ?
function(value) {
// check ownerDocument here as well to exclude DOM nodes
return value !== null && value !== undefined && toString.call(value) === '[object Object]' && value.ownerDocument === undefined;
} :
function(value) {
return toString.call(value) === '[object Object]';
}, /**
* @private
*/
isSimpleObject: function(value) {
return value instanceof Object && value.constructor === Object;
},
/**
* Returns true if the passed value is a JavaScript 'primitive', a string, number or boolean.
* @param {Object} value The value to test
* @return {Boolean}
*/
isPrimitive: function(value) {
var type = typeof value; return type === 'string' || type === 'number' || type === 'boolean';
}, /**
* Returns true if the passed value is a JavaScript Function, false otherwise.
* @param {Object} value The value to test
* @return {Boolean}
* @method
*/
isFunction:
// Safari 3.x and 4.x returns 'function' for typeof <NodeList>, hence we need to fall back to using
// Object.prototype.toString (slower)
(typeof document !== 'undefined' && typeof document.getElementsByTagName('body') === 'function') ? function(value) {
return toString.call(value) === '[object Function]';
} : function(value) {
return typeof value === 'function';
}, /**
* Returns true if the passed value is a number. Returns false for non-finite numbers.
* @param {Object} value The value to test
* @return {Boolean}
*/
isNumber: function(value) {
return typeof value === 'number' && isFinite(value);
}, /**
* Validates that a value is numeric.
* @param {Object} value Examples: 1, '1', '2.34'
* @return {Boolean} True if numeric, false otherwise
*/
isNumeric: function(value) {
return !isNaN(parseFloat(value)) && isFinite(value);
}, /**
* Returns true if the passed value is a string.
* @param {Object} value The value to test
* @return {Boolean}
*/
isString: function(value) {
return typeof value === 'string';
}, /**
* Returns true if the passed value is a boolean.
*
* @param {Object} value The value to test
* @return {Boolean}
*/
isBoolean: function(value) {
return typeof value === 'boolean';
}, /**
* Returns true if the passed value is an HTMLElement
* @param {Object} value The value to test
* @return {Boolean}
*/
isElement: function(value) {
return value ? value.nodeType === 1 : false;
}, /**
* Returns true if the passed value is a TextNode
* @param {Object} value The value to test
* @return {Boolean}
*/
isTextNode: function(value) {
return value ? value.nodeName === "#text" : false;
}, /**
* Returns true if the passed value is defined.
* @param {Object} value The value to test
* @return {Boolean}
*/
isDefined: function(value) {
return typeof value !== 'undefined';
}, /**
* Returns true if the passed value is iterable, false otherwise
* @param {Object} value The value to test
* @return {Boolean}
*/
isIterable: function(value) {
var type = typeof value,
checkLength = false;
if (value && type != 'string') {
// Functions have a length property, so we need to filter them out
if (type == 'function') {
// In Safari, NodeList/HTMLCollection both return "function" when using typeof, so we need
// to explicitly check them here.
if (Ext.isSafari) {
checkLength = value instanceof NodeList || value instanceof HTMLCollection;
}
} else {
checkLength = true;
}
}
return checkLength ? value.length !== undefined : false;
}
ExtJs--15--Ext.is*各种类型推断的方法,简单看源代码就能够明确了的更多相关文章
- C#的类型推断发展史
前言:随着C#的版本升级,C#编译器的类型推断功能也在不断的升级以适应语言进化过程中的变化,并为这个过程做了相应的优化. 隐式类型的数组 在C#1和C#2中,作为变量声明和初始化的一部分,初始化数组的 ...
- Java 10 实战第 1 篇:局部变量类型推断
现在 Java 9 被遗弃了直接升级到了 Java 10,之前也发过 Java 10 新特性的文章,现在是开始实战 Java 10 的时候了. 今天要实战的是 Java 10 中最重要的特性:局部变量 ...
- 译:Java局部变量类型推断(Var类型)的26条细则
原文链接:https://dzone.com/articles/var-work-in-progress 作者:Anghel Leonard 译者:沈歌 Java局部变量类型推断(LVTI),简称va ...
- JDK11 | 第三篇 : 局部变量类型推断
文章首发于公众号<程序员果果> 地址 : https://mp.weixin.qq.com/s/PB0Mw4bzjDML7nto2M8x2w 一.简介 Java局部变量类型推断(LVTI) ...
- C++11特性——变量部分(using类型别名、constexpr常量表达式、auto类型推断、nullptr空指针等)
#include <iostream> using namespace std; int main() { using cullptr = const unsigned long long ...
- TypeScript Type Innference(类型推断)
在这一节,我们将介绍TypeScript中的类型推断.我们将会讨论类型推断需要在何处用到以及如何推断. 基础 在TypeScript中,在几个没有明确指定类型注释的地方将会使用类型推断来提供类型信息. ...
- C++11新特性:自动类型推断和类型获取
声明:本文是在Alex Allain的文章http://www.cprogramming.com/c++11/c++11-auto-decltype-return-value-after-functi ...
- WebKit Web Inspector增加覆盖率分析和类型推断功能
WebKit中的Web Inspector(Web检查器)主要用于查看页面源代码.实时DOM层次结构.脚本调试.数据收集等,日前增加了两个十分有用的新功能:覆盖率分析和类型推断.覆盖率分析工具能够可视 ...
- [Effective Modern C++] Item 2. Understand auto type deduction - 了解auto类型推断
条款二 了解auto类型推断 基础知识 除了一处例外,auto的类型推断与template一样.存在一个直接的从template类型推断到auto类型推断的映射 三类情况下的推断如下所示: // ca ...
随机推荐
- SDUT 2894-C(最短spfa)
C Time Limit: 7000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描写叙述 给出一个带权无向图.包括n个点,m条边.求出s,e的最短路.保证最短路存在 ...
- JS达到Web指定保存的和打印功能的内容
背景 首先,说说文章的背景.近期手中的一个项目,因为需求中要求提供Web界面的打印功能.当然假设没有打印机,还能够提供保存到本地.项目组长把这个"小任务"分给了我.本着努力为组长分 ...
- cocos2d-x v3.2环境配置(现在3.x版本号可以配置该)
这里介绍的是Windows环境下的cocos2d-x配置. 前提: •Windows 7+ •cocos2d-x v3.2版本号(能够在http://www.cocos2d-x.org/down ...
- x264 - open gop and closed gop
GOP - Group of picture(影像集团),它指的是两个I帧之间的距离. Reference(基准期). 它指的是两个P帧之间的距离. 简而言之, 跨参考gop的,变open gop: ...
- Serializable Clonable
序列化机制有一种很有趣的用法:可以方便的克隆对象,只要对应的类是可序列化的即可.操作流程:直接将对象序列化到输出流中,然后将其读回.这样产生的新对象是对现有对象的一个深拷贝(deep copy).在此 ...
- POJ1251 Jungle Roads 【最小生成树Prim】
Jungle Roads Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 19536 Accepted: 8970 Des ...
- iOS kvc
kvc在我的脑海里用来更改属性的实例变量值. 今天,他们遇到了kvc第二次去学习它,在网上看了很多博客,这似乎不符合我的口味,为了提取一些以下的.总结自己的. http://www.cnblogs.c ...
- IOS经典的书籍推荐
基础 objective-c基础教程 iphone 开发秘籍 进阶篇 iOS 6编程实战 Objective-C 高级编程:iOS与OS X多线程和内存管理 Effective Objective-C ...
- 【MySQL笔记】mysql来源安装/配置步骤和支持中国gbk/gb2312编码配置
不久的学习笔记.分享.我想有很大的帮助谁刚开始学习其他人的 备注:该票据于mysql-5.1.73版本号例如 1. mysql源代码编译/安装步骤 1) 官网下载mysql源代码并解压 2) cd至源 ...
- 华夏互联与逐浪CMS旗下三款软件获著作权登记
北京时间2014年7月24日消息: 上海逐一软件科技公司长下三款软件通过中国知识产权局登记,当中包含全新的CMS2 x2.0主产品.移动门户管理系统.云台管理系统. 除主产品CMS2 x2.0( ...