ExtJS类成员-判断数据类型功能

更新记录
2022年7月6日 发布。
2022年7月2日 从笔记迁移到博客。

ExtJS教程汇总:https://www.cnblogs.com/cqpanda/p/16328016.html

获得数据类型

Ext.typeOf ( value ) : String 

返回类型对应关系:

undefined: 			If the given value is undefined
null: 				If the given value is null
string: 			If the given value is a string
number: 			If the given value is a number
boolean: 			If the given value is a boolean value
date: 				If the given value is a Date object
function: 			If the given value is a function reference
object:			 	If the given value is an object
array: 				If the given value is an array
regexp: 			If the given value is a regular expression
element: 			If the given value is a DOM Element
whitespace: 			If the given value is a DOM text node and contains only whitespace
textnode: 			If the given value is a DOM text node
and contains something other than whitespace

判断是否数组类型

Ext.isArray ( target ) : Boolean

实例:

console.log(Ext.isArray([]));//true
console.log(Ext.isArray([0]));//true
console.log(Ext.isArray([1]));//true
console.log(Ext.isArray([""]));//true
console.log(Ext.isArray(['abc']));//true
console.log(Ext.isArray(new Array()));//true
console.log(Ext.isArray(new Array(0)));//true
console.log(Ext.isArray(new Array(1)));//true

判断是否字符串类型

Ext.isString ( value ) : Boolean

实例:

console.log(Ext.isString(''));//true
console.log(Ext.isString(""));//true
console.log(Ext.isString('0'));//true
console.log(Ext.isString(0));//false
console.log(Ext.isString('abc'));//true
console.log(Ext.isString(new String()));//false
console.log(Ext.isString(new String('')));//false

判断是否布尔类型

Ext.isBoolean ( value ) : Boolean

实例:

console.log(Ext.isBoolean(0));//false
console.log(Ext.isBoolean(0.0));//false
console.log(Ext.isBoolean(1));//false
console.log(Ext.isBoolean(true));//true
console.log(Ext.isBoolean(false));//true
console.log(Ext.isBoolean('true'));//false
console.log(Ext.isBoolean('false'));//false
console.log(Ext.isBoolean(new Boolean()));//false

判断是否函数类型

Ext.isFunction ( value ) : Boolean

实例:

console.log(Ext.isFunction(new Function()));//true
console.log(Ext.isFunction(function(){}));//true
console.log(Ext.isFunction(Array.prototype.concat));//true

判断是否日期类型

Ext.isDate ( obj ) : Boolean

实例:

console.log(Ext.isDate('2021-1-11'));//false
console.log(Ext.isDate(new Date()));//true
console.log(Ext.isDate(Date.UTC));//false

判断是否日期(MS) 类型

Ext.isMSDate ( value ) : Boolean

实例:

console.log(Ext.isMSDate('2021-1-11'));//false
console.log(Ext.isMSDate(new Date()));//false
console.log(Ext.isMSDate(Date.UTC));//false

判断是否数值类型

Ext.isNumber ( value ) : Boolean

实例:

console.log(Ext.isNumber(0));//true
console.log(Ext.isNumber(1));//true
console.log(Ext.isNumber('1.1'));//false
console.log(Ext.isNumber(new Number()));//false
console.log(Ext.isNumber((new Number()).valueOf()));//true

判断是否泛数字类型

Ext.isNumeric ( value ) : Boolean

实例:

console.log(Ext.isNumeric(0));//true
console.log(Ext.isNumeric(1));//true
console.log(Ext.isNumeric('1.1'));//true
console.log(Ext.isNumeric(new Number()));//true
console.log(Ext.isNumeric((new Number()).valueOf()));//true

判断是否对象类型

Ext.isObject ( value ) : Boolean

实例:

console.log(Ext.isObject([])); //false
console.log(Ext.isObject({})); //true
console.log(Ext.isObject(new Object())); //true
console.log(Ext.isObject(Ext.create('Ext.button.Button'))); //true
console.log(Ext.isObject(Ext.getWin())); //true

判断是否可迭代类型

Ext.isIterable ( value ) : Boolean

实例:

console.log(Ext.isIterable({}));//false
console.log(Ext.isIterable([])); //true
console.log(Ext.isIterable(Ext.getWin()));//false
console.log(Ext.isIterable(Ext.getBody()));//false

判断是否HTML Element类型

Ext.isElement ( value ) : Boolean

实例:

console.log(Ext.isElement(Ext.getHead()));//false
console.log(Ext.isElement(Ext.getHead().dom));//true
console.log(Ext.isElement(Ext.getBody()));//false
console.log(Ext.isElement(Ext.getBody().dom));//true

判断是否HTML文本节点(TextNode) 类型

Ext.isTextNode ( value ) : Boolean

实例:

console.log(Ext.isTextNode(""));//false
console.log(Ext.isTextNode("Panda"));//false

判断是否标量类型

Ext.isPrimitive ( value ) : Boolean

注意:标量指string/number/boolean类型

实例:

console.log(Ext.isPrimitive(666));//true
console.log(Ext.isPrimitive('Panda'));//true
console.log(Ext.isPrimitive(true));//true
console.log(Ext.isPrimitive([]));//false
console.log(Ext.isPrimitive({}));//false

判断变量是否已经定义

Ext.isDefined ( value ) : Boolean 

实例:

var website = "Panda666.com";
var panda = null;
console.log(Ext.isDefined(panda));//true
console.log(Ext.isDefined([]));//true
console.log(Ext.isDefined(website));//true

判断值是否为空

Ext.isEmpty ( value, [allowEmptyString] ) : Boolean

这些值会判定为空:null、undefined、a zero-length array、a zero-length string(看参数)
实例:

console.log(Ext.isEmpty([]));//true
console.log(Ext.isEmpty(0));//false
console.log(Ext.isEmpty(0.0));//false
console.log(Ext.isEmpty(1));//false
console.log(Ext.isEmpty('0'));//false
console.log(Ext.isEmpty('0.0'));//false
console.log(Ext.isEmpty(null));//true
console.log(Ext.isEmpty(undefined));//true

原文地址:https://www.cnblogs.com/cqpanda/p/16437875.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


我有一个问题,我不知道如何解决.我有一个Indy10HTTP服务器.我在许多应用程序中使用过Indy9和Indy10HTTP服务器,从未遇到任何问题.但现在我使用带有ExtJSjavascriptRAI框架的Indy10HTTP服务器.问题是当我提交包含非ansi字符的数据时.例如,当我提交1250代码页中的字母“č”(
我正在使用sdk1.17开发一个Firefox附加组件.它包含一个带有按钮的面板(使用ExtJs开发),我想在用户单击按钮时拍摄当前页面的屏幕截图.在GoogleChrome中,有一个API(chrome.page-capture)就在那里.但我在Firefox中找不到类似的那个.在firefox中如何从main.js完成此任务.解决方法:哦
Ext.define('PhysicsEvaluationSystemV1.view.base.BaseCharts',{extend:'Ext.panel.Panel',xtype:'basecharts',html:'<divid="main"style="width:600px;height:400px;"></div&
默认所有列(假设列3最大3列,动态显示),使用headerRowsEx中的rowspan实现双表头,第一层表头的width也必须要设置正确。使用"grid.getColumnModel().setHidden"即可实现列的隐藏,也不需要动态设置colspan。{xtype:'filtergrid',id:'grid1',cm:newExt.grid.Colu
序言   1.ExtJs是一套很好的后台框架。现在很流行的,我们要会。    2.这是我写ExtJs的第一篇,以后会写很多直到把这框架运用的炉火纯青,走火入魔。ExtJs中的命名空间      我是做.net的,这命名空间名字一样,功能也一样,都是对项目中类进行有效的管理,区分类
我在ExtJs中有这个表单.如果field1不为空,则field2不能为空.但即使听众正在解雇,它也无法正常工作.{xtype:'panel',title:'title1',items:[{xtype:'fieldset',title:'fieldA',items:[{xtype:'t
我可以将HTML元素(如文本和图像)放在面板标题中,如下所示:vargrid=newExt.grid.GridPanel({region:'center',style:'margin:10px',store:newExt.data.Store({data:myData,reader:myReader}),headerCfg:{tag:
解决方案来至于https://www.sencha.com/forum/showthread.php?471410-Bug-in-VS-Code-Plugin-since-VS-Code-Update-(-gt-1-31)在C:\Users\你的用户名\.vscode\extensions\sencha.vscode-extjs-1.0.1\out\src文件下找到Logger.js,打开它。找到代码fs.writeFile(path.join(Platfo
<%@pagelanguage="java"import="java.util.*"pageEncoding="UTF-8"%><!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"><html><head><title>MyJSP'index.jsp'
Ext.isEmpty(str,[allowEmptyString])如果str为nullundefinedazero-lengtharrayazero-lengthstring (UnlesstheallowEmptyStringparameterissettotrue)//意思如果第二个参数设为true,则是允许str对象为空字符串该方法返回true 如果不为上面条件则返回fal
以编程方式关闭ExtJS选项卡的正确方法是什么?我需要在IE6中完成这项工作;虽然从TabPanel删除选项卡有效,但我看到IE警告:此页面包含安全和不安全的项目……当我单击选项卡上的X时,我看不到此警告.所以,当我点击X时,显然会发生一些聪明的事情.注意:当我使用tabPanel.remove(aTab,true
1.链接1.1.零散知识链接https://blog.csdn.net/zhaojianrun/article/details/701410711.2.系统教程http://extjs.org.cn/1.3.视频教程1.4.官方网站 
ExtJS有Ext.each()函数,但是有一个map()也隐藏在某个地方吗?我努力了,但没有找到任何可以填补这个角色的东西.这似乎是一件简单而微不足道的事情,一个像Ext这样庞大的JS库显然必须拥有.或者当Ext真的不包含它时,将它添加到Ext的最佳方法是什么.当然,我可以写:Ext.map=function(
我在一家使用Ext-JS的公司工作.该产品目前过度扩展了Ext-JS组件并覆盖了父功能.这使升级变得困难.我们正在保留Ext-JS,但我们正在考虑以非标准的方式使用它.似乎有两个阵营.在一个阵营中,成员们认为我们应该在Ext-JS之上编写一个抽象,以防我们决定在几年内改变框架,希望这样我们不
我想计算今天和给定日期之间的天数,并检查截至今天剩余的天数或今天过去的天数.vartoday=newDate();vardate_to_reply=newDate('2012-10-15');vartimeinmilisec=today.getTime()-date_to_reply.getTime();console.log(Math.floor(timeinmilisec/(1000*60*
我将JSON格式结果发送回保存$quot符号的客户端.由于某些未知原因,代码中断了.这是来自ext-all-debug的代码:doDecode=function(json){returneval("("+json+")");FAILSHERE},这是我的JSON,因为它离开了服务器(据我所知,我希望服务器没有花时间解码这个&quot的
我创建了Ext.Window,里面有一些Ext.form字段.但是当我调整窗口窗体时,元素仍然具有初始宽度和高度.是否需要在窗口大小调整时显式调整表单字段的大小?或者有一些选项可以自动调整表单字段的大小?示例代码:varf_1=newExt.form.TextField({fieldLabel:'Label1'});varf_2=n
我有一个简单的案例,我有一个附加商店的网格.有2个按钮.一个带有修改所选记录的处理程序.一个具有提交所选记录的处理程序.当我选择一个记录并推送编辑时–>编辑发生选择(看起来丢失)如果你调用grid.geSelectionModel().getSelection()你会看到记录仍然被选中.它只是没有这样显
我有这种ajax代码重复了很多地方.如何将其重构为单个方法,以便在成功或失败时仍允许不同的行为.Ext.Ajax.request({url:'ajax.php',params:{action:'getDate'},method:'GET',success:function(result,request){Ext.MessageBox.alert(
Ext.define('JsApp.com.Util',{  /**   *显示新建视图   *title:新建界面显示的标题   *xtype:新建界面的别名   */  showCreatingView:function(title,xtype){    this.shrink.formType='create';    this.shrink