0

I have been struggling with something that is bugging me in Javascript. I'm using .split() to get the value off an input field which has numbers separated by commas, then I use split() to create a new variable with this values as an array, all well there. I have been using console to output the value of the array and I've tried it in two different scenarios and these are the outputs:

1) In an "isolated" website: ["46", "43", "44", "41", "47", "42", "45"]

2) In the production website: ["46", "43", "44", "41", "47", "42", "45", sum: function, max: function, min: function]

What could be changing the array to this? I'm suspecting that underscore.js is the culprit, as it is loaded in web #2 and not in #1.

I only ask because I don't know what else to look for!

Thanks in advance.

UPDATE: You can try it here and open console: http://www.cdc-bike.com/tienda | this is the other website: http://www.cdc-bike.com/stage/wordpress/?page_id=732

Some of the code used:

Field:

<input type="hidden" name="selected-brands" id="selected-brands" value="47,42">

Selecting values:

var selected_brands = $('input#selected-brands').val();

Split values:

var splitted_brands = brands.split(',');

That's all.

4

1 に答える 1

1

all.js問題が配列を使用してループしている場合、これらのプロトタイプはで宣言されています

for(var i = 0; i < array.length...

それ以外の

for(var i in array) { ....

于 2013-04-04T12:03:17.133 に答える