How does it work?
If you worked a bit with arrays, you probably have experienced a problem. This problem is that you need to know if an array contains a specific value. And because I'm part of the lazy developers that don't want to remember how to do it in Vanilla JavaScript, I created this function.
So, this function will require 2 arguments which are:
array
val
, the value of the item you want to test if it is in the array.How to use it?
Let's take a simple example:
If5
is in[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
, display an alert 🚨.
JS:
var testArray = $.range(10) // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
if ($.isIn(testArray, 5)) {
alert("🚨 5 is in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]") // will be displayed
}
⚠️ Questions?
Don't hesitate to ask your questions ⁉️ in the issue part 😁