Dave's Brain

Browse - Programming Tips - How can I check for membership in an associative array?

Date: 2017aug21
Language: javaScript

Q.  How can I check for membership in an associative array?

A.  Use the `in` keyword:

function isMember(map, key) { return key in map; }
This is better than checking for `null` or `undefined`.

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.