Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to have integer array in jquery

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

like image 448
Somnath Kharat Avatar asked May 01 '26 17:05

Somnath Kharat


1 Answers

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; });
like image 75
xdazz Avatar answered May 04 '26 08:05

xdazz