3

I have ToothSequence array which contains all integer type values

Whenever i want to compare the element or add integer i have to parseInt is as shown parseInt(ToothSequence[i]) + 1

 var ToothSequence = $("#hndBridge").val().split("|");
for (i = 1; i <= ToothSequence.length; i++) {
  if (parseInt(ToothSequence[i]) + 1 == parseInt(ToothSequence[i + 1]))
  {

Is it possible to make integer array in jquery? if not please suggest me

Somnath Kharat
  • 3,570
  • 2
  • 27
  • 51
  • Duplicate of http://stackoverflow.com/questions/4291447/convert-string-into-array-of-integers – Zac Aug 28 '13 at 09:45

1 Answers1

6

You could do like this:

var ToothSequence = $("#hndBridge").val().split("|").map(function(e) { return +e; });

+e will convert e to a number.

--for old browser which Array doesn't have map method, use $.map instead--

var ToothSequence = $.map($("#hndBridge").val().split("|"), function(e) { return +e; });
xdazz
  • 158,678
  • 38
  • 247
  • 274