And underline the difference between lodash [Close]

This translation from: Differences and the BETWEEN lodash Underscore [Closed]

Would someone the prefer either at The Why lodash.js or underscore.js Utility Library over at The OTHER? Why do some people prefer lodash.js or underscore.js utility library rather than another?

Seems to BE A drop Lodash-in Replacement for Underscore, at The Latter the HAVING been around longer. Lodash seems to underscore alternatives, which have existed for a longer time.

I think both are brilliant, but I do not know enough about how they work to make an educated comparison, and I would like to know more about the differences. I think both are wonderful, but I have based on how their efforts the comparison does not understand, I would like to know more about these differences.


#1st Floor

Reference: The difference between https://stackoom.com/question/vrJC/lodash and underscores - closed


#2nd Floor

Inspired by Dash IS-Lo Underscore, But Nowadays IS Superior Solution. Lo-Dash was inspired by an underscore, but now is an excellent solution. The make your CAN by You Custom builds , have have A IN AREAS OF COMMUNICAITIONS Performance , Support and AMD have have Great Extra Features . You can create a custom version , with higher performance , support for AMD and has a powerful additional functionality . The this the Check Lo-Dash vs Underscore Benchmarks ON jsperf and the this .. Awesome POST the About lo-dash : check this on jsperf of Lo-Dash VS Underscore Benchmarks and ... on lo-dash of this post great :

One of the most useful feature when you work with collections, is the shorthand syntax: one when using a collection of the most useful features is shorthand syntax:

var characters = [
  { 'name': 'barney', 'age': 36, 'blocked': false },
  { 'name': 'fred',   'age': 40, 'blocked': true }
];

// using "_.filter" callback shorthand
_.filter(characters, { 'age': 36 });

// using underscore
_.filter(characters, function(character) { return character.age === 36; } );

// → [{ 'name': 'barney', 'age': 36, 'blocked': false }]

(taken from lodash docs ) (摘自lodash docs


#3rd floor

Dash-Lo to the Created the I the Provide More consistent Cross-Environment Support for the Iteration Arrays, strings, Objects, and argumentsObjects 1 . I created a Lo-Dash, an array of strings, and objects, argumentsobjects 1 to provide a more consistent environment across iteration support . IT has Operating since Become A a superset of Underscore, PROVIDING More consistent the API behavior, More Features (like the AMD Support, Deep clone, and Deep Merge), More Thorough Documentation and Unit Tests (Tests Which RUN in the Node, Ringo, Rhino, Narwhal, PhantomJS , and browsers), and optimizations of better Overall Performance for Large Arrays / Object the Iteration, and more Flexibility with Custom builds and pre-Template Compilation Utilities. it has become Underscore superset provide a more consistent API behavior, more features(Such as AMD support, the depth and the depth of cloning merger), more comprehensive documentation and unit tests (in Node, Ringo, Rhino, Narwhal, PhantomJS test run) and the browser), better overall performance and a large array / object iterative optimization, as well as custom build greater flexibility and utility of pre-compiled templates.

Lo-Dash IS Updated Because More Frequently Within last Underscore, A lodash underscoreBuild IS Provided to stable of Ensure Compatibility with Latest Version of at The Underscore. Since Lo-Dash ratio lodash underscorefrequently updated, thus providing the lodash underscorebuilding , in order to ensure that the latest stable version lodash underscorecompatible.

AT One Point the I WAS the even GIVEN the Push Access to Underscore, in Part Because Lo-Dash IS Responsible for Raising More Within last 30 AND DELINQUENCY; Once, I even get a pair Underscore the push , in part because Lo-Dash responsible for raising more than 30 question; . landing bug fixes, new new features, & Perf Gains, in Underscore v1.4.x comes in + Underscore + v1.4.x comes in the landing bug fixes, new features and performance improvements.

An In Addition there are AT Least 3 Backbone boilerplates that the include Lo-Dash by default and Lo-Dash IS now Mentioned in Backbone's Official Documentation . In addition, at least by default 3 Backbone templates contain Lo-Dash, now Backbone of official documents He referred to the Lo-Dash.

The Check OUT Kit Cambridge's POST, Say "the Hello" to Lo-Dash , for A Deeper Breakdown ON at The Differences the BETWEEN Lo-Dash and Underscore. View Kit Cambridge posts, the Lo-Dash said, "Hello" , for a more in-depth analysis the difference between the Lo-Dash and Underscore.

Footnotes: Footnotes:

  1. Inconsistent Support for Arrays has Underscore, strings, Objects, and argumentsObjects. Underscore the array, strings, objects and argumentssupport objects inconsistent. The In newer browsers, Underscore Methods the ignore Holes in Arrays , "Objects" Methods the iterate argumentsObjects, strings are Treated AS Array-like, and Methods correctly & the iterate Functions (Ignoring Their "the prototype" Property) and Objects (for iterating through the Shadowed Properties like "toString" and "valueOf"), while in older browsers they will not. in newer browsers, Underscore method ignores the array of vulnerabilities , "objects" iterative argumentsobjects, strings are treated in a similar array, the correct method iterative function (ignored their "prototype" property) and the object (iteration shadow attributes, such as "toString") and "valueOf"), and in older browsers they will not. Also, Underscore Methods like _.clonepreserve Holes in Arrays, like the while Others _.flattendo not. _.cloneThis _.clonemethod _.cloneretains an array of vulnerabilities, and as _.flattensuch other _.flattendoes not.

#4th floor

The In Addition to John apos answer, and Reading up ON lodash (Which the I HAD hitherto regarded AS A "Me-TOO" to Underscore), and Seeing The Performance Tests, Reading The Source-code, and Blog Posts , The FEW Points Which the make lodash much superior to underscore are these: in addition to John's answer, also read from lodash (I have so far is considered to be "me-too" to emphasize), and see performance testing, source code and read blog posts a few, making the lodash these points more than underlined:

  1. At The Speed's not the About IT, AS IT IS the About Consistency of Speed (?) This is not about speed, but about the speed of consistency (?)

    If you look into underscore's source- code, you'll see in the first few lines that underscore falls-back on the native implementations of many functions. If you look at the source code is underlined, you will see several lines underlined in the previous the machine down to implement many functions. Ideal World in AN although but, Would have have been the this A Better Approach, you look IF AT The Perf some of links in GIVEN THESE the slides , IT IS Not Hard to Draw The Quality of Conclusion The Those that 'Native Implementations' Vary A Lot browser- to-browser. Although in an ideal world, this may be a better way, if you look at these slides in the performance of some links given, not difficult to draw "the native implementation" the quality of these changes are big conclusion - to the browser. Firefox is damn fast in some of the functions, and in some Chrome dominates. Some features of Firefox is very fast, and dominant in some Chrome. (I imagine there would be some scenarios where IE would dominate too). (I think there are some cases IE will dominate). IT's of Better Believe that the I to the prefer A code Whose Performance IS More consistent across browsers. I think the best choice for performance more consistent in the browser code.

    Earlier at The Blog POST the Read the Do, and of believing INSTEAD IT for the ITS Sake, Judge for Yourself by running at The Benchmarks . Please read the blog post, instead of trusting itself, by running to the reference judge for yourself. AM stunned right now the I, Seeing A lodash Performing 100-150% Faster Within last Underscore in the even the Simple , Native Functions SUCH AS Array.everyin Chrome! I am shocked to see a lodash than a simple native functions (such as Chrome is Array.everyfaster 100-150%!

  2. At The Extras in lodash are quite Also Useful. Lodash of additional features are also very useful.

  3. AS for Xananax's Highly upvoted the Comment suggesting contribution to Underscore's code: It's Always of Better to have have GOOD Competition, not only does IT the Keep Innovation going, But Also Drives you to the Keep Yourself (or your Library) in Good the Shape. As Xananax high evaluation comments shows that the contribution of the underlined code: have a good competition is always better, it can not only be innovative, but also to encourage you to keep yourself (or your library) in good condition.

IS A here Wallpaper List of Differences the BETWEEN lodash, and Build-IT's Underscore IS A drop-in Replacement for your Underscore the Projects. The following are among lodash differences in the list , it underlined build your project underlined a direct replacement.


#5th Floor

This is 2014 and a couple of years too late. This is 2014, but it was too late for a few years. Still I think my point holds: I still think my point is:

IMHO this discussion got blown out of proportion quite a bit. IMHO, this discussion is quite out of proportion. At The aforementioned quoting Blog POST : reference to the above blog :

Most JavaScript utility libraries, such as Underscore , Valentine, and wu, rely on the "native-first dual approach." This approach prefers native implementations, falling back to vanilla JavaScript only if the native equivalent is not supported. Most JavaScript utility library (e.g. Underscore, Valentine and Wu) rely on the "priority double native methods." This method is more like the native implementation, only when does not support native will return equivalent to the vanilla JavaScript. But jsPerf revealed an interesting trend: the most efficient way to iterate over an array or array-like collection is to avoid the native implementations entirely, opting for simple loops instead. But jsPerf reveals an interesting trend: the iterative array or array-like the most effective method is to avoid the native implementation, simple cycle selected.

As if "simple loops" and " vanilla Javascript" are more native than Array or Object method implementations. If "simple cycle" and "vanilla Javascript" Array achieve more localized than or Object method. ... Jeez Jeez ......

It certainly would be nice to have a single source of truth, but there is not. Having a single source of truth will certainly be very good, but it is not. Even if you've been told otherwise, there is no Vanilla God, my dear. Even if you have been told, my dear, there is no god vanilla. I'm sorry. I'm sorry. The only assumption that really holds is that we are all writing Javascript code that aims at performing well in all major browsers, knowing that all of them have different implementations of the same things. The only real set up on the assumption that we are all in the preparation aimed at All major browsers have Javascript code to perform well, because they know all these codes have different implementations. It's a bitch to cope with, to put it mildly. Gently say, it's a bitch to deal with. But that's the premise, whether you like it or not. But this is a prerequisite, whether you like it or not.

Y'all are ON Large Working Maybe the Projects that need twitterish Performance Scale SO that for Really See you at The -difference the BETWEEN 850,000 (Underscore) vs. 2,500,000 (lodash) over the Iterations per sec A List right now! Maybe you are undertaking large-scale projects these projects need to panic performance to make you really see between 850,000 per second on the list (underlined) and 2,500,000 (lodash) iteration difference!

I for one am not. I am not a person. I mean, I worked projects where I had to address performance issues, but they were never solved or caused by neither Underscore nor Lo-Dash. I mean, I'm working on my project must address performance issues, but they are never resolved or Underscore caused by and Lo-Dash. And unless I get hold of the real differences in implementation and performance (we're talking C ++ right now) of lets say a loop over an iterable (object or array, sparse or not!), I rather do not get bothered with any ON based at the Results of Claims Benchmark a Platform that iS already opinionated . unless I caught a real difference and achieve performance (we are now talking about C ++), let's say a loop throughout an iterative (object or array, sparse sparse or not!), I'd rather not be based on any problems have been public the results of the baseline platform of claim.

It only needs one single update of lets say Rhino to set its Array method implementations on fire in a fashion that not a single "medieval loop methods perform better and forever and whatnot" priest can argue his / her way around the simple fact that all of a sudden array methods in FF are much faster than his / her opinionated brainfuck. it requires a separate update let's say Rhino in a manner to achieve its Array methods, this approach is not a "medieval cycle method to perform better , but nothing is forever, "the priest can argue about the simple fact that he / FF sudden array approach all the way in her brain much faster than he / she thinks. Man, you just can not cheat your runtime environment by cheating your runtime environment! Man, you can not cheat your run-time environment to trick your runtime environment! Think about that when promoting ... think about in the promotion ......

your utility belt to your utility belt

The Next Time .... ... next time.

So to keep it relevant: it is to remain relevant:

  • Use Underscore if you're into convenience without sacrificing native ish. If you have easy access without sacrificing the native ability, use the Underscore.
  • Use Lo-Dash if you're into convenience and like its extended feature catalogue (deep copy etc.) and if you're in desperate need of instant performance and most importantly do not mind settling for an alternative as soon as native API's outshine opinionated workaurounds. use Lo-Dash, if you are handy, and like its extensions directory (deep copy, etc.), if you desperately need real-time performance, the most important thing is not to mind immediately seek alternatives in the native API appear opinionated work. Which is going to happen soon. What will happen very soon. Period. Period.
  • There's even a third solution. There's even a third solution. DIY! DIY! Know your environments. Know your environment. Know about inconsistencies. Learn inconsistent. Their the Read ( John-David 'S and Jeremy .' S) code reading them ( John - David and Jeremy 's) code. Do not use this or that without being able to explain why a consistency / compatibility layer is really needed and enhances your workflow or improves the performance of your app. If you can not explain why really need consistency / compatibility layer and enhance your work processes or improve the performance of your application, please do not use this or that. It is very likely that your requirements are satisfied with a simple polyfill that you're perfectly able to write yourself. Is likely to meet your requirements in a simple fill you full of yourself to write. Both libraries are just plain vanilla with a little bit of sugar. Both libraries are ordinary vanilla with a little sugar. Fight over both-the Just the WHO They's the Serving at The Sweetest PIE . They were just the sweetest whom pie fight . But believe me, in the end both are only cooking with water. But believe me, the last two are just cooking water. There's no Vanilla God so there can not be no Vanilla pope, right? No vanilla God, it is impossible not to Herb Pope, right?

Choose whatever approach fits your needs the most . Select the most suitable method for your needs. As usual. As usual. I'd prefer fallbacks on actual implementations over opinionated runtime cheats anytime but even that seems to be a matter of taste nowadays. I prefer to cheat rather than stubborn running down on the actual implementation, but even so, it seems now the matter of taste. Like at Quality Resources to Stick http://developer.mozilla.com and http://caniuse.com and you'll BE the Just Fine. Persist as http://developer.mozilla.com and http://caniuse.com so quality resources, you will be good.


#6th floor

http://benmccormick.org/2014/11/12/underscore-vs-lodash/ http://benmccormick.org/2014/11/12/underscore-vs-lodash/

Comparing TWO by Article This article was at The Latest Ben McCormick: Ben McCormick will be the latest article comparing the two:

  1. Dash apos API IS-LO a superset of A Underscore apos. LO-Dash Underscore the API is a superset.

  2. Under the hood [Lo-Dash] has been completely rewritten. Under the hood [Lo-Dash] has been completely rewritten.

  3. IS definitely not Dash-Lo It would help Within last Underscore. Lo-Dash Underscore certainly better than slow.

  4. Lo-Dash has added the What? Lo-Dash add something?

    • Usability Improvements Usability Improvements
    • Extra Functionality additional features
    • Performance Gains business growth
    • Shorthand syntaxes for chaining link shorthand syntax
    • Custom Builds to only use what you need custom built using only what you need
    • Semantic versioning and 100% code coverage semantic version control and code coverage 100%
Original articles published 0 · won praise 136 · views 830 000 +

Guess you like

Origin blog.csdn.net/xfxf996/article/details/105204901