Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

arguments misbehaving, can't enumerate keys #11746

Closed
telamon opened this issue Nov 11, 2013 · 1 comment
Closed

arguments misbehaving, can't enumerate keys #11746

telamon opened this issue Nov 11, 2013 · 1 comment

Comments

@telamon
Copy link

telamon commented Nov 11, 2013

Hi I've ran into this issue where the tests pass on Chromium and Firefox but fail on PhantomJS

Here's the test that fails where expected length should be 3 but turns out to be 0

it('SanityTest',function(){
  var array = [1,2,3];
  array.extraMethod = function(){
    expect(arguments.length).toEqual(3); // Passes
    expect(arguments[0]).toEqual(4); // Passes
    console.log(Object.keys(arguments),arguments);
    expect(Object.keys(arguments).length).toBe(3); // <-- Failing
  };
  array.extraMethod(4,5,6);
});

The console.log line output from all three browsers respectively

PhantomJS 1.9.2 (Linux) LOG: [], Object{}
Chromium 30.0.1599 (Ubuntu) LOG: ['0', '1', '2'], Object{0: 4, 1: 5, 2: 6}
Firefox 25.0.0 (Ubuntu) LOG: ['0', '1', '2'], Object{0: 4, 1: 5, 2: 6}

I'm not sure if what i demonstrate above is bad practice, I can still workaround this by using blind ignorance.

for(i=0;i<arguments.length;i++){ arguments[i]; ....} 

But the inconsistency is giving me the chills.

@ariya
Copy link
Owner

ariya commented Aug 16, 2014

Fixed in Qt5-based master branch.

@ariya ariya closed this as completed Aug 16, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants