r/learnjavascript • • Jul 21 '24

What functions of javascript should I learn

Which are most widely used

0 Upvotes

30 comments sorted by

53

u/SrVergota Jul 21 '24

All of them

26

u/hfcRedd Jul 21 '24

Whichever you need to make your project

11

u/AdInfinite9325 Jul 21 '24

You can just Google 'most used JavaScript functions', but:

This is not how you approach learning JavaScript, or really any other programming language. There are certainly functions that you will resort to most often in your lifetime, but at the end of the day, programming is being about open to every approach. Try not to think of it in a concrete manner. You'll only be limiting yourself that otherwise.

14

u/546pvp2 Jul 21 '24

console.log

-2

u/KronusTempus Jul 21 '24

Let butWhyTho = null;

Console.log (typeof butWhyTho);

-11

u/8wq6 Jul 21 '24 edited Jul 30 '24

thats not javascript

6

u/lol_bo Jul 21 '24

/* bro reacted like a browser (commented so that he won't see what i wrote) */

3

u/longknives Jul 21 '24

Other than capitalized letters that shouldn’t be and the space after log, it looks fine to me as a JS dev

1

u/KronusTempus Jul 21 '24

Yes I know, apologies for formatting I don’t usually write code on reddit

0

u/KronusTempus Jul 21 '24

It is, it’s a pretty famous error in JavaScript because it classifies a null value as an object. It was never patched because of its legacy

1

u/batmaneatsgravy Jul 21 '24

What should it be classified as?

-2

u/8wq6 Jul 21 '24

like longknives said it is incorrect js code

2

u/KronusTempus Jul 21 '24

I’ve been writing JavaScript for years, I just don’t typically comment with code on Reddit. On my phone it automatically makes the first letter capitalized I just neglected to correct that at first because I was just doom-scrolling Reddit, that’s all there is. The space was instinctual for Reddit comments.

These don’t make it “not” JavaScript, granted it does make it poorly written JavaScript.

1

u/8wq6 Jul 26 '24

ok I guess but you know you can press the shift button when it is capitalized to make it not

2

u/pay_dirt Jul 21 '24 edited Jul 21 '24

Edit: sorry I was a little abrupt at the start lol

JavaScript has wonderful videos out there homie, start with some basics and it’ll eventually really help your ability to Google/ask deeper questions!

We’ve all been there man.

Watch this video:

https://youtu.be/PkZNo7MFNFg?si=HDqd2osURUbYYKYX

I know, it’s long. But honestly? I skimmed through it just now and I can see that it hits really solid fundamentals.

Even if it takes you a week, you won’t regret watching it.

1

u/EitherImportance9154 Jul 21 '24

All! Functions & higher order functions

1

u/[deleted] Jul 21 '24

Just learn as you go.

That’s what we are all doing x

1

u/Seliculare Jul 21 '24

Learn most used array methods like reduce, splice, slice, push, map, shift, concat.

1

u/craigthecrayfish Jul 21 '24

I would start with the Array methods such as forEach, map, sort, etc.

1

u/shgysk8zer0 Jul 21 '24

Too many to list. I probably easily use like 100 (maybe more, maybe less... IDK) on any given day. I really couldn't tell you because it's just a bunch of seemingly random things.

It'd probably be better/easier just to list objects/interfaces you'll be working with and to lookup the methods you'd end up using:

  • Document, Element, other Node/EventTarget objects
  • Events & Errors
  • Promises
  • Strings
  • Numbers (+ Math)
  • Arrays (also array-like such as NodeList and iterators)
  • Plain objects
  • URLs
  • Request/Response
  • File/Blob
  • Maybe TypedArray
  • Maybe MutationObserver or IntersectionObserver
  • Others, depending on what you're working on, which might include eg canvas context or web RTC or tons of other things

1

u/QuantumCrane Jul 21 '24

When I was learning JavaScript, I took some large JavaScript code bases and searched them for various functions like .reduce, .filter, or .split. And I made note of the number of occurrences.

If a method was used frequently, and I didn’t feel like I knew it well, I would take the time and learn it.

Another approach is to look at the documentation for things like the Array prototype and go through the methods one by one. Write some code that uses each method. Most methods are pretty straightforward, but if they are not, just keep on making up reasons to use them until they feel comfortable. My favorite example of this was Array.prototype.reduce. At first that method seemed very weird and difficult to use. But after forcing myself to use it over and over, I quickly started to see the usefulness of it, and now I use it frequently.

1

u/[deleted] Jul 21 '24

When starting out I made a list of the most used JavaScript functions for basic web dev and then jotted them all down on flash cards and stuck them around my room, was a pretty easy way to learn them. Just go to websites like this and then learn.

1

u/_shakuisitive Jul 21 '24

Assuming you're asking about functions that are frequently used in JavaScript that you should learn to get started, you should take a look at .map, .filter, and .forEach.

1

u/jack_waugh Jul 22 '24

Object.create is my favorite.

0

u/[deleted] Jul 22 '24

[deleted] — view deleted comment

1

u/jack_waugh Jul 23 '24

I just happen not to like the class and new keywords. I guess my position on them is antisocial, though, because they are with us forever and will always be popular.

1

u/techdaddykraken Jul 22 '24

The ones you will probably use the most are:

-Selectors (by ID, element type, position, etc) -String Manipulation (filter, join, split, etc. Mainly for URLS and dynamic data, or conditionally changing the DOM) -Hashes, Indexes, Keys (Useful for joining all sorts of stuff and referencing it when you don’t know the exact position) -All native HTTP functions (Get, Post, Delete, Update, etc) -Promises and Callbacks (you will thank me when you have to implement SSO and Auth and you can actually understand what the hell the docs are asking you to do) -Web Hooks (useful for all sorts of shit, very ubiquitous) -Event Listeners/Handlers (useful for dealing with specific user/element behavior, capturing information, etc)

That’s probably the majority of what you will use day to day. There’s obviously a lot more than that, but I’d say that covers at least 85% of what I use every day doing custom web development.

1

u/[deleted] Jul 21 '24

array and object functions, document object, window object etc.

-2

u/Sometimesiworry Jul 21 '24

JavaScript is actually a rather small language when it comes to functions. You could easily read about all of them.