Results 1 to 4 of 4

Thread: object.hasOwnProperty usage

Threaded View

Previous Post Previous Post   Next Post Next Post
    You found a bug! We've classified it as EXTJS-7491 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha Premium User
    Join Date
    Nov 2010
    Vote Rating

    Default object.hasOwnProperty usage

    I think the way the hasOwnProperty method is used in Ext JS is not very efficient.

    See my modification below. The new code avoids long property lookups all the way to Object by caching the hasOwnProperty method in a local variable. This should improve performance.

    Ext.define('Ext.util.Observable', {
        removeManagedListener : function(item, ename, fn, scope) {
            var me = this,
                hasOwn = Object.prototype.hasOwnProperty; // <-- added
            if (typeof ename !== 'string') {
                options = ename;
                for (ename in options) {
                    // if (options.hasOwnProperty(ename)) {
                    if (, ename)) {     
                        config = options[ename];
                        if (!me.eventOptionsRe.test(ename)) {
                            me.removeManagedListener(item, ename, config.fn || config, config.scope || options.scope);
    Performance improvement is minor, but it still might be worth it because it's a simple change.
    Last edited by LesJ; 8 Oct 2012 at 2:33 PM. Reason: Add test link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts