Test if an array contains a specific number/string.

This commit is contained in:
ChenL
2017-03-16 10:05:50 +08:00
parent f1d68409b1
commit e4056a79ee
2 changed files with 9 additions and 1 deletions
+7 -1
View File
@@ -5,7 +5,13 @@ var operators = {
'<': (l, r) => l < r,
'>=': (l, r) => l >= r,
'<=': (l, r) => l <= r,
'contains': (l, r) => typeof l === 'string' ? l.indexOf(r) > -1 : false,
'contains': (l, r) => {
return typeof l !== 'undefined'
? typeof l.indexOf === 'function'
? l.indexOf(r) > -1
: false
: false;
},
'and': (l, r) => l && r,
'or': (l, r) => l || r
};