jashkenas / underscore

JavaScript's utility _ belt
https://underscorejs.org
MIT License
27.29k stars 5.53k forks source link

Mention _.VERSION in the documentation #2992

Open clanceyp opened 5 months ago

clanceyp commented 5 months ago

Add an alias, or method, for VERSION const e.g. '_.UNDERSCOREVERSION' or .version() ==> "Underscore v.X.XX.X" to allow users to determine if Underscore is being used and if so which version.

jgonggrijp commented 5 months ago

@clanceyp It is already accessible as _.VERSION. I now realize it isn't mentioned in the documentation, though. Will label and retitle accordingly. Thanks for bringing it up!

clanceyp commented 5 months ago

What I want to know is whether it's the Underscore library or a different library using the "_" character alias.

jgonggrijp commented 5 months ago

Are you aware of other libraries than Underscore or Lodash that use _?

If you only need to distinguish between those two, you can use feature detection. Lodash has _.partialRight, Underscore does not. Underscore has _.restArguments, Lodash does not (at least not in version 4+). There are many other differences as well.

Also, if the major version number is 1, you are much more likely dealing with Underscore than Lodash, since Lodash is currently at 4.