Checking coffeescript if not in an array

Here's something simple to check if the user is in a moderator. But I want to check if the user is a moderator.

if err && user in moderators return 

Intuitively, it will be like this:

 if err && user isnt in moderators return 

But obviously this will not work. What is the best way to do this?

+71
coffeescript
Jun 29 '13 at 0:03
source share
2 answers

isnt is the opposite of is , which is a triple equal sign. Just deny in :

 if err and user not in moderators return 
+102
Jun 29 '13 at 0:08
source share

In CoffeeScript it can NOT be denoted as! Or no

 if err && !(user in moderators) if err && user not in moderators 

both will work.

+10
Jun 29 '13 at 0:08
source share



All Articles