DEV Community

Cover image for Javascript Hacks
SIDDHANT JOHARI
SIDDHANT JOHARI

Posted on

Javascript Hacks

There are many amazing features in javascript that can make your life much simpler, In this blog, I have added 20 features that every javascript developer should know.

1.Resize the Array using an array. length.

2.Swapping of two Numbers.

3 Concatenating two or more arrays without causing server overload.

4.Use Filter in a different way.

5.Iterate on the map from 0 to n.

6.Replace all occurrences of a word in a string

7.Shortcut for conditions.
Here, I am explaining basic two examples we can implement in multiple ways.

8.String to number / Number to string.

9.Use the console in different ways.

10.Use console.table

11.Get the items near to last index of an array.

12.Get n power of any number.

13.Check the falsy or truly value.

14.Call a function by its name stored in a string using eval function.

15.typeof Operator.

16.yeild keyword

17.function* in javascript.

18.new.target in javascript

19.label statement.

20.Rest parameters Syntax.

Conclusion:
Thanks for reading it, In this blog I have explained some of the most used features of javascript, I will explain more features in next blog,
Please give feedback in responses.

Top comments (8)

Collapse
 
blazerowland profile image
Blaze Rowland

Don’t always learns something from these types of articles, but actually a few useful tricks in here. Thank you!

Collapse
 
siddhant_johari_8fdecc7b7 profile image
SIDDHANT JOHARI

Thanks, I will try to give more detail information from next time.

Collapse
 
planet_cbx profile image
Charlène Bonnardeaux

thanks for this huge javascript blog!
I’m just wondering, for the 3th, why don’t use the spread operator? That’s a bad impact on the memory too?

let array_a = [1, 2, 3]
let array_b = [4, 5, 6]
let array_a = […array_a, …array_b]

Collapse
 
siddhant_johari_8fdecc7b7 profile image
SIDDHANT JOHARI

Yes, Spread operator created a deep copy of object and shallow copy of its child in case of hierarchical objects.

I will create a separate blog for spread operator.

Collapse
 
enriquesource profile image
EnriqueSource

Good content and well explained. I like this kind of articles as they help the newcomer to learn and the advanced to remember. Thank you.

Collapse
 
siddhant_johari_8fdecc7b7 profile image
SIDDHANT JOHARI • Edited

Welcome 😊.

Collapse
 
pierretsia profile image
Pierre_T • Edited

Suggestion for 5, iterate.js : you can do [...Array(10).keys()].map(i=>i)

To avoid unused param your linter will whine about 😏

Collapse
 
siddhant_johari_8fdecc7b7 profile image
SIDDHANT JOHARI

Yes we can.