I am from PHP Background, Checking for variable empty in PHP is straight forward using empty() function. I am searching for similar function in Sencha Touch 2, finally i got it.
Ext.isEmpty() returns true if the variable is empty, otherwise returns false. The variable is deemed to be empty if it is either:
Example 2: (Using zero-length array check)
Hope, you enjoyed this Post.
Ext.isEmpty() returns true if the variable is empty, otherwise returns false. The variable is deemed to be empty if it is either:
* null
* undefined
* zero-length array
* zero-length string (Unless the allowEmptyString parameter is set to true)
This method accept 2 parameters
1) value : the value/variable to test
2) allowEmptyString : true to allow empty strings (defaults to false)
Example 1: (Using null check)
* undefined
* zero-length array
* zero-length string (Unless the allowEmptyString parameter is set to true)
This method accept 2 parameters
1) value : the value/variable to test
2) allowEmptyString : true to allow empty strings (defaults to false)
Example 1: (Using null check)
var data = null;Output: variable is empty
if(Ext.isEmpty(data)){
console.log('variable is empty');
}else{
console.log('variable is not empty');
}
Example 2: (Using zero-length array check)
var data = [];Output: variable is empty
if(Ext.isEmpty(data)){
console.log('variable is empty');
}else{
console.log('variable is not empty');
}
Example 3: (Using zero-length string check)
var data = '';Output: variable is empty
if(Ext.isEmpty(data)){
console.log('variable is empty');
}else{
console.log('variable is not empty');
}
Hope, you enjoyed this Post.
No comments:
Post a Comment