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

1

1 Answer 1

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; });
Sign up to request clarification or add additional context in comments.

2 Comments

This. Maybe explain to him the +e though ;)
that looks sexy! could you explain the +e ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.