jList 1.5.0: Two new functions added

Even though I wrote the original, rather messy, version of jList over five years ago I’ve never had the need for a listContains function i.e. one that searches a list looking for an item which at least partially matches a string. Until now, that is.

Yesterday I pushed jList 1.5.0 to GitHub. This version of the library, which brings ColdFusion-style list handling to Javascript, adds two new functions, bringing the total to twenty-two:

  • listContains
    Determines the index of the first list element that contains a specified substring.. The search is case-sensitive.
  • listContainsNoCase
    Determines the index of the first list element that contains a specified substring. The search is not case-sensitive.

These functions look at each individual element of a list for a specific value.  Where the value being searched for is wholly or partially contained within an element  then the position of that element in the list is returned. Where no match is found, zero is returned.

For example:


jList.listContains("cat,dog,mouse,rabbit,lion", "bit")

would return 4 even though the value itself is not in the list.

All documentation is updated so full details of the new functionality is on the jList GitHub page.

The two new functions have also been added to jsFiddle should you wish to try them out first – listContainslistContainsNoCase.

jList 1.5.o can be downloaded for free from GitHub.

More:

Previously:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s