This project is archived and is in readonly mode.

#715 ✓invalid

$A returning array of nulls in IE and Opera

Reported by cime | July 24th, 2009 @ 08:07 PM | in 2.0 (closed)

$A function is not working correctly in IE8 (didn't tested in 6 and 7) and Opera 10b2 MooTools version: 1.2.3


Internet Explorer 8 and Opera 10b2 returns: ,,,

Firefox 3.5 and Chrome 3 returns: t,e,s,t

The solutions was: "test".split("")

Comments and changes to this ticket

  • cime

    cime July 24th, 2009 @ 08:09 PM

    • no changes were found...
  • Scott Kyle

    Scott Kyle July 24th, 2009 @ 08:19 PM

    $A is not intended to be run on strings, only on iterables. In IE 6-8 and Opera it'll return an array of undefined values whereas in Firefox it'll split the string by character. This is because of $A is using the Array.prototype.slice method, whose implementation at the lowest level differs between each browser.

    You might want to be using these instead:

    $splat('test'); // ['test']
    'test'.split(''); // ['t','e','s','t']
  • Sebastian Markbåge

    Sebastian Markbåge July 28th, 2009 @ 09:16 PM

    • State changed from “new” to “invalid”

    The purpose of $A() is not to convert a non-array to Array per say. It's useful to convert array-like objects like HTMLCollection and arguments which can't have their prototypes extended. Example: $A(arguments)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket