Skip to content

Commit

Permalink
Use Array.isArray instead of instanceof
Browse files Browse the repository at this point in the history
`instanceof` does not always return true for an array even if `array.isArray()`
return true and `Object.prototype.toString()` returns `[Object Array]`

http://blog.niftysnippets.org/2010/09/say-what.html#instanceof
https://stackoverflow.com/questions/28779255/is-instanceof-array-better-than-isarray-in-javascript

Fixes #124
  • Loading branch information
George Thomas committed Apr 26, 2019
1 parent 5ac00ea commit 1b9968e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/condition.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class Condition {
Object.assign(this, properties)
if (booleanOperator) {
let subConditions = properties[booleanOperator]
if (!(subConditions instanceof Array)) {
if (!(Array.isArray(subConditions))) {
throw new Error(`"${booleanOperator}" must be an array`)
}
this.operator = booleanOperator
Expand Down

0 comments on commit 1b9968e

Please sign in to comment.