Lodash - understanding the real functionality/use

Hey all

I have problemes understanding what Lodash really is. I have no problems using it, nor making the exercise. But I don’t really understand why I am doing this, or how I could use this in the future.

Following the explanation given, I first assumed Lodash was a library with that could give you extra built in methods. But doing the project, I rather assume it is to help you see errors when you use their methods?

Also, I don’t really understand the syntax: const _ = {};
So everyting we do has to be within this object. Why? Do you have to put al your JS within this object and than remove it after you checked everything with the lodash check functionnality? Because if you would write al you’r code within that object, it stops working.

I think I am misunderstanding this. Can someone try to explain me what Lodash is and does. Please don’t use the standard explanation you find when you google because that is the one I assume I am misunderstanding.

Thank you for your feedback!

Kind regards,

Yannick

4 Likes

Makes it a lot easier to import all methods in one go (by importing the object), rather then having to import each method individually.

I think there are two things which need to be distinguished here:

  1. Lodash can help speed up development of your project because these extra useful functions are available.
  2. codecademy wants to teach you to implement some of these methods yourself by replicating them. I assume as a teaching experience for algorithms/writing re-usable functions

I can understand why these two points look conflicting.

But you are still in a learning process now, so having some understanding how Lodash implements these methods can be useful. Makes usage in real-world projects later easier

1 Like

Hey

Thank you for your feedback Stetim. So am I understanding correctly than that these exercises do not really explain how to make usage of Lodash? For instance if I would like to use one of the very functional codes of Lodash in my code, I will need to make a script link or something?

That const _ = {}; and module.exports = _; are only for this specific exercises, and that I normally would not use them in my code?

Kr,

Yannick

no, the focus for these exercises is to implement/replicate some of the functionality found in Lodash library. “Normally”, you would import the library and use these function to speed up development.

you could import Lodash, and you could use the functions/methods you just imported.

Or you could write your own functions/methods, that is also a possibility of course.

See, this is why things are confusing. The exercise is doing the exact opposite. Normally, you would import Lodash, so someone else already created (const _ = {};) and exported the object (module.exports = _;). You would merely import Lodash

5 Likes

Okay thanks!

Its much clearer like this!

kr,

Yannick

you’re welcome :slight_smile:

but I also understand the exercise, implementing some of these ideas are great for learning.

1 Like

Hi @stetim94 would be so kind to as to explain me in detail how to import Lodash?

  • What exactly do I need to download?
  • Where do I need to save the downloaded content? In every project’s folder I want to use Lodash in or is there some kind of “root folder” where I download it to and then can access it on all my .js files? I use VS Code btw.
  • What exactly do I need to do to import? Is it some line of code I need to write at the beginning of every .js file I want to use Lodash in?

Many thanks!

its on there websites:

https://lodash.com/

and there are several ways to install or use this library.

The general advise is to have lodash per project. Lets say you build a project (project x) and 6 months later you start a new project (project y), you want to have the latest version of lodash, but without breaking something in project x

again, several ways to go about this. Also depends on the project and setup you want to use. Codecademy sometimes keeps you away from this, because it introduces a lot of complexity, but normally JavaScript is used within the browser (as a front-end scripting language), so you would simple include the lodash library in html, and then in other javascript files you have access to the methods of lodash.

Thank goodness, I had the same question but thinking about this as replicating methods which already exist in a library really helps. Thanks for the explanation!