DEV Community

Cover image for My most used javascript methods.

My most used javascript methods.

Martín Mato on March 28, 2020

Being my first post, I want to share something handy but useful, especially if you are in the first steps with Javascript. I read a lot of posts a...
Collapse
 
karataev profile image
Eugene Karataev •

They really helpful methods indeed. But I'd not throw away libraries like lodash completely, because they have a lot of useful functions.
Btw, the post's cover image with old-style jQuery carousel code is not in sync with the post content - React's mentions and relatively new es2015 Object.assign, .some, .every methods 😀

Collapse
 
otamnitram profile image
Martín Mato •

Yes, you are right. I didn't take the time to select the right cover image; I will choose another later.
Regarding Lodash, in my opinion, since nowadays we have ES6 and Babel to compile ES6 in ES5, I think that most of the time, there is no need to sacrifice speed and add complexity using Lodash when you can use pure ES6 functions. But, again, it is just an opinion. Lodash is still very popular and useful in a lot of cases.

Collapse
 
alistaiiiir profile image
alistair smith •

Fantastic article, Martín, and I would have to agree with you on ES6 versus Lodash, especially since the new integrations would be faster (being native). Babel is a life saver!!

Collapse
 
appurist profile image
Paul / Appurist •

Psst. The third example, the .some example, is likely to confuse a few folks due to the <= 18 that should read >= 18 (like the .every example).

That one typo aside, this is a great list and if I did such an article, my list would probably match this.

Collapse
 
otamnitram profile image
Martín Mato •

Thanks. Just noticed and made the change.

Collapse
 
hiteshgupta9193 profile image
Hitesh Gupta •

This is about Object.assign Example 2 -

const source1 = { "propA": 1 };
const source2 = { "propB": 2 };
const source3 = { "propC": 3 };
const target = Object.assign(source1, source2, source);

After execution of the above lines,
// target = { "propA": 1, "propB": 2, "propC": 3 };

also, it will update source1.
// source1 = { "propA": 1, "propB": 2, "propC": 3 };

if we don't want to update any of our existing sources, the correct way to write is
const target = Object.assign({}, source1, source2, source);

Collapse
 
andrew_shtyka profile image
Andrew Shtyka •

That's a great mention! Especially since article is dedicated to methods that don't mutate original objects.

Collapse
 
iakashpatel profile image
Akash P. •

that's awesome, as JS developer, what you mentioned is relative for me as well. I am also using the same methods as every day. great sharing. thanks, Martin.

Collapse
 
harper0478 profile image
harper0478 •

Great Article! I m a beginner and though it's necessary to know many things in JavaScript, very nice to know what you should get use to using right away. thanks for the article.

Collapse
 
otamnitram profile image
Martín Mato •

Thanks!!