This repository was archived by the owner on Jun 2, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
$.isIn()
Arthur Guiot edited this page Jul 13, 2017
·
1 revision
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.
Let's take a simple example:
If 5 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
}Don't hesitate to ask your questions
- Home
- The Core Languages
- Getting Started: Installation
- The Basics (
$.var()+$.target()) - Developing for DisplayJS
-
$.select()- Text related
- If...else
$.xss()$.repeat()$.custom()$.live()$.load()$.on()$.onEvent()$.ready()- Scroll API
$.all()$.clone()$.is()$.valEmpty()$.remove()$.show()&$.hide()$.ajax()- Class Related
$.css()$.getStyle()- Fade effects
$.extend()$.dynamic()$.parent()- Elements-Nodes
$.component()$.time_ago()$.copy()$.then()$.sleep()$.getProp()