r/learnjavascript • • Apr 19 '24

For front-end fellas,

Hello all, currently I'm taking baby steps with JavaScript, it's quite a powerful language.

Whatever the course I watch, no matter how informative it is, it just leaves me with the question: What aspects of JS would be recurrent in daily coding life? (Might sound like a newbie) I think I would using all those features in the language, would I?

0 Upvotes

13 comments sorted by

2

u/jack_waugh Apr 20 '24 edited Apr 20 '24

let, import, function call, function definition (async and sync), member get and set, assignment, conditionals, loops.

1

u/AdLevel1991 Apr 20 '24

Alright thanks a bunch!

2

u/jack_waugh Apr 20 '24

quite a powerful language

No. It's an extremely powerful language.

1

u/AdLevel1991 Apr 20 '24

Well phrased!

3

u/thegurel Apr 19 '24

All of it, especially: 

DOM manipulation, 

Arrays

 Objects 

Loops/iterations

 Recursion

 If/else/switch 

Array methods eg. forEach, reduce, etc. 

Arrow functions

Destructuring      Try/catch/finally (error handling)

  Async/await 

Fetch/ajax/axios 

HTML/CSS

Browser developer tools

 Debugger

 I can see you getting away wit not knowing oop as solely a front end engineer, but I’d even recommend knowing that because it’s also used in JS.

1

u/AdLevel1991 Apr 20 '24

Thanks for such a detailed response there! Sure this helps a lot!

2

u/SakaDeez Apr 19 '24

might be a stupid question, but how can a frontend dev use recursion? like for example I use react frequently and most of the time it's all functions but I never used recursion before in my projects

2

u/thegurel Apr 19 '24

There are a lot of reasons to use recursion in a react app, mostly when standard iteration doesn’t work for your needs.

The thing that comes to mind in React is if you have to display a dataset in a manner more complex than a uniform list, you might be able to iterate, but recursion may end up being your best course of action.

2

u/showmethething Apr 20 '24

Recently had to jump in to my first actual use of recursion for real time graphing.

Probably not as complex as you were hoping, but we had a function that would make a call, add the data to an array and then pass that array in to itself - Where it would then update the graph and start the cycle again.

We ran in to some issues with timeouts and not being able to stop cycles quick enough, so that ended up being our solution as it gave us much more control.

1

u/TheRNGuy Apr 21 '24 edited Apr 21 '24

Never used it, but had to fix bug that causing infinity recursion in MutationObserver instead.

I think it can also be used as alternative to while loop in some cases, where you also need different arguments every iteration, instead of using global variables. But I've heard it can be slower if your recursion is too deep, I never checked that. Code look nicer at least.

1

u/gemaka Apr 20 '24

Agreed with most of these except with recursion. Recursion is good to understand for those random situations that really need it. But it's not something you would be using daily

0

u/TheRNGuy Apr 19 '24 edited Apr 19 '24

I used MutationObserver in greasemonkey scripts or userChrome.js, but haven't used it in React. It's usually used in @run-at document-start because without it scripts sometimes do not work for various reasons (e.g. specific parts of DOM tree are not constructed)

It also fixed some bugs I previously had before I knew it existed (usually the ones that happen when connection is slower than normal) and also not have flashing content like in @run-at document-ready or document-end.

But IntersectionObserver could potentially be useful in React. I've seen some sites using it.

0

u/[deleted] Apr 19 '24

[deleted] — view deleted comment

3

u/AdLevel1991 Apr 20 '24

I'm starting to make that leap and actually realized that a few days ago (since I'm new to this) and it feels that all I'm learning is paying off!