View Full Version : New (simple) functions in Ext
primolan
30 Apr 2010, 3:57 AM
Hello.
Here are my humble suggestions to implement Ext functionalities.
Ext.prototype = {
isObject: function(v) {
return (typeof(v) == 'object' && v.length == undefined);
},
isArray: function(v) {
return (typeof(v) == 'object' && v.length != undefined);
}
};
Thanks!
Don't they already exist in Ext? isObject, isBoolean, isArray?
primolan
30 Apr 2010, 9:24 AM
Unfortunally Ext doesn't have that functions. I made a new one, unifying all types in one function.
Ext.getType(var) will return var's type.
Here's the new code:
Ext.prototype.getType = function(v) {
c = v.constructor;
a = c.toString().split(' ');
r = a[1].toLowerCase();
s = r.replace('()', '');
return s;
}
I hope you all enjoy it!
tryanDLS
30 Apr 2010, 1:03 PM
Those functions all exist in the library all ready
http://www.extjs.com/deploy/dev/docs/?class=Ext
primolan
3 May 2010, 5:14 AM
Ops!
My bad! I didn't see it! But theres a new way to retrieve object's type, using var.getType() instead of using Ext.isX(var).
Object.prototype.getType = function() {
return this.constructor.name.toLowerCase();
}
Cya!
watrboy00
3 May 2010, 1:44 PM
Yea that's in there as well...
http://www.extjs.com/deploy/dev/docs/?class=Ext&member=type
primolan
4 May 2010, 5:43 PM
:P
I should read with more attention!
Ty!
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.