Looks like a pretty slick way to achieve what you are looking for...
I'm not sure how cross-browser it is...
http://laurens.vd.oever.nl/weblog/items2005/setsinjavascript/
On 1/10/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
In python we have the handy in operator:
if 3 in [1,2,3]: ...
JavaScript does have an in operator.
The in operator expects a lefthand operand that is or can be
converted to a string. It expects a righthand operand that is an
object (or array). It evaluates to true if the lefthand value is the
name of a property of the righthand object. For example:
Those are two completely different animals though. I am looking for something
like:
isIn(5, [1, 3, 4]) - false
isIn(3, [1, 3, 4]) - true
Maybe since JS has two types of equality, there could be an isIn and
isInExact function.
We could also allow iterators instead of arrays. It would