if (typeof value === 'object' && value !== null) {
// ...
}
Since typeof of an Array is an object in Javascript (see here) the solution for removing Array in this condition is to use Array.isArray(), as follows:
if (typeof value === 'object' && !Array.isArray(value) && value !== null) {
// ..
}
This PR fixes https://github.com/elastic/elasticsearch-js/issues/2128 issue. The issue was related to the conversion of property array into object due to this check:
Since
typeof
of an Array is anobject
in Javascript (see here) the solution for removing Array in this condition is to useArray.isArray()
, as follows: