What is the “authoritative” way to determine if _ loaded using lodash or underscore?
I use lodash for a project in an environment where underscore can sometimes be downloaded as well.
Currently, I have come up with the following:
if ( typeof( _.PLACEHOLDER ) == 'undefined' || _.PLACEHOLDER.indexOf( 'lodash' ) < 0 ) {
Important update: The above code does NOT work!
Is there an "authoritative" way to determine if _ lodash or underscore is?
Notes:
This is a specific query to find a way to determine if lodash or underscore is loaded in _ variable:
1. I am out of control whether the underline is loaded or not. (lodash is inside my control and will always be loaded).
2. You cannot rely on the boot order of lodash / underscore.
3. The underline version that is loading is likely to change (this is part of the CMS environment that can be updated).
4. Lodash 4.17.x has over 300 functions. My code uses many functions in lodash.
5. Lodash contains many features that emphasize. 6. Some of the functions that exist in both libraries have different implementations.
cale_b
source share