what does "-1" mean in javascript 1

what does “-1” mean in javascript

1) Search/Find functions return a -1 if there is no matching item.
2) -1 is used to mean descending for sort functions.

Here is what the above code is Doing:
1. Create a list of numbers.
2. Sort the list in ascending order.
3. Print the list.
4. Sort the list in descending order.
5. Print the list.
6. Find the index of the number 5.
7. Print the index.
8. Find the index of the number 10.
9. Print the index.

Similar Posts