Monday, 28 January 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.
php - file_get_contents shows unexpected output while reading a file
I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print ...
-
I have an app which needs a login and a registration with SQLite. I have the database and a user can login and register. But i would like th...
-
I got an error in my Java program. I think this happens because of the constructor is not intialized properly. My Base class Program public ...
-
I would like to use enhanced REP MOVSB (ERMSB) to get a high bandwidth for a custom memcpy . ERMSB was introduced with the Ivy Bridge micro...
No comments:
Post a Comment