问题:
This question already has an answer here: 这个问题在这里已有答案:
- How to check if an object is an array? 如何检查对象是否是数组? 46 answers 46个答案
I would like to check whether a variable is either an array or a single value in JavaScript. 我想检查变量是JavaScript中的数组还是单个值。
I have found a possible solution... 我找到了一个可能的解决方案......
if (variable.constructor == Array)...
Is this the best way this can be done? 这是最好的办法吗?
解决方案:
参考一: https://stackoom.com/question/3Deo/如何检查变量是否是JavaScript中的数组-重复参考二: https://oldbug.net/q/3Deo/How-do-you-check-if-a-variable-is-an-array-in-JavaScript-duplicate
来源:oschina
链接:https://my.oschina.net/u/4438370/blog/4301418