Monday, January 28, 2019
Most efficient way to check if a variable is an array in JavaScript?
Answer
I was reading this question about how to check if a variable is an Array
in Javascript, and this answer proposes several solutions:
1. variable.constructor === Array
2. Array.isArray(variable)
3. variable instanceof Array
The post has several updates and they touch on the efficiency of the different solutions, but between the post and its comments it isn't entirely clear which solution is the most efficient. I'm hoping to clarify which of these solutions provides the most efficient check for whether or not a variable is an Array
in JavaScript.
Edit: I'd like to note that this question is about the performance of checking whether or not a variable is an Array
and not how to check if a variable is an Array
. Considering all the noise in the linked question, I believe there is value to the question.
plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV
In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...
-
I need to do the following: My current address looks like: https://www.domain.com I want to redirect with htaccess: www.domain.com TO https:...
-
This question attempts to collect the few pearls among the dozens of bad C++ books that are published every year. Unlike many other programm...
-
using namespace std; So far in my computer science courses, this is all we have been told to do. Not only that, but it's all tha...
No comments:
Post a Comment