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...
-
How to display something on or after selecting a specific radio button, for example is I have a group of radio button Interest Value o 3% ...
-
I use the code below to update the url link based on user text input: Right now it works pretty fine when someone clicks the submit ...
-
I need to be able to determine when an object is created (not a DOM element -- a javascript object). An answer to this question has some ve...
No comments:
Post a Comment