-2

I want to use the _.zip function of Underscore.js to create pairs from two arrays.

var a = ["alpha", "beta", "gamma"];
var b = ["one", "two", "three"];
var pairs = _.zip(a, b);
alert("pairs = " + pairs);

This seems to work fine when done with integers however when using strings the result is confusing:

pairs = 3,3,3,3,3,3

Instead I expect the following result:

pairs = [["alpha", "one"], ["beta", "two"], ["gamma","three"]]

Update:
Thanks to the comments I discovered that the described behavior does apply to Chromium running on Ubuntu. However the expected result is return when I run the same script in Firefox on Ubuntu.

Community
  • 1
  • 1
JJD
  • 50,076
  • 60
  • 203
  • 339
  • 2
    It's definitely confusing, because [this code does not produce that result](http://jsfiddle.net/t3XvH/1/). – Jon May 07 '13 at 18:45
  • 1
    It worked for me. (Edited the above to use strings, still works fine: http://jsfiddle.net/nmR7b/1/) – Brandon Buck May 07 '13 at 18:46
  • Works fine under XUbuntu 13.04, Chromium Version 25.0.1364.160 Ubuntu 13.04 (25.0.1364.160-0ubuntu3). The jsFiddle that izuriel posted alerts with `(alpha, one),(beta, two),(gamma, three)`. – icyrock.com May 12 '13 at 22:20

1 Answers1

0

I filed a bug for the problem.

JJD
  • 50,076
  • 60
  • 203
  • 339