5

I'm learning JavaScript and I'm currently trying to figure out why (in Spidermonkey)

[].concat.apply([1], [[2]])

returns the expected [1, 2], but

Array.concat.apply([1], [[2]])

returns [2] instead of [1, 2].

Could someone provide a good explanation?

Esailija
  • 138,174
  • 23
  • 272
  • 326
eljenso
  • 16,789
  • 6
  • 57
  • 63

1 Answers1

8

[].concat is Array.prototype.concat.

Array.concat is a Firefox-only static method that concatenates one or more arrays and ignores its this argument.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964