Make compatible with ExtJS framework: Object function has no method 'match'

Created on 27 May 2011, over 14 years ago
Updated 4 September 2025, 10 days ago

I'm using Ext JSCross-browser JavaScript framework and on the search page I've following error:

Uncaught TypeError: Object function (B){var A=this.indexOf(B);if(A!=-1){this.splice(A,1)}return this} has no method 'match'

Affected code is:

    for (var n in userFlags) {
      var flagInfo = userFlags[n].match(/(\w+)_(\d+)/);
      var flagName = flagInfo[1];
      var contentId = flagInfo[2];
...
    }

The reason of this error is misuse of the Array class.

See screenshots:

See following link:
http://www.sencha.com/forum/showthread.php?6005-Problem-with-Array.index...

The bug isn't in Ext, it's in the misuse of the Array class. If you look at the functions on the Array object they all work with indexes. Arrays themselves do not support string keys. When you add string key'ed properties, do you notice the length doesn't change? You can't slice or pop or splice them?

However, every object in JavaScript supports dynamic expando properties. When you make a call like this:

arrayX['key1'] = 'foo';

you are not doing anything with the Array class, which is why the Array functions don't work on that value. You are simply assigning an expando to that JavaScript object. In fact, arrayX.key1 = 'foo'; does exactly the same thing.

If all you want is a JavaScript object to add expandos to, the syntax is almost identical:

arrayX = {};
arrayX['key1'] = 'foo';
arrayX['key2'] = 'bar';

Lastly, why is this in BUGS?? If you want to discuss something that Ext is doing that you don't agree with, put it in the general discussion forum. That doesn't mean it's a bug.
Jack Slocum
Founder and original developer of Ext JS

πŸ“Œ Task
Status

Postponed

Version

3.0

Component

Flag core

Created by

πŸ‡¬πŸ‡§United Kingdom kenorb

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024