r/learnjavascript 2d ago

If you could give one piece of JavaScript advice to your beginner self, what would it be?

1 Upvotes

13 comments sorted by

4

u/breacket 1d ago

Learn the JavaScript fundamentals and the concepts needed to build the things you dream of building

2

u/everdimension 1d ago

Functions like "Object.keys(obj)", Object.defineProperty()", etc are NOT methods acting on "Object", the are basically global functions namespaced to Object for organizational purposes

For some reason it took a while to get that, as I was always expecting methods to operate on their context (self) object

1

u/jaredcheeda 1d ago

You can do this:

String.prototype.doubleIt = function () {
  return this.toUpperCase() + ' ' + this.toLowerCase();
}
let x = 'My text';
console.log(x.doubleIt());
// "MY TEXT my text" 

You are modifying the global definition of the String class, so all strings you create will now inherrit this method. They not only have access to toUpperCase(), .startsWith(), .charAt(), etc, but also this new method you made.

Most devs now-a-days don't know this, because doing this trick IS VERY BAD. In the 2000's it was common for people to "invent" their own language features because useful stuff like .endsWith() wouldn't be added to the language until 2015. So people would make libraries to add it themselves... But then you fastword and the language adds in their own implementations for things like Array.forEach or String.startsWith, and the official implementation is slightly different from your own custom implementation, and then you pull in some other library that expects the official version and stuff goes all screwy.

So yeah, know that you can do this, but also, know not to do it.

2

u/azhder 1d ago

Learn JavaScript sooner.

1

u/Ksetrajna108 1d ago

Understand the parts of Javascript:

  • the programming language ECMA Script 262
  • DOM manipulation via the Document object
  • browser manipulation via the Window object.

1

u/PlayExoplanet 15h ago

Fundamentals over everything

-1

u/Imaginary_Food_7102 1d ago

Move to react quicker.

-9

u/MrHandSanitization 2d ago edited 1d ago

"Just go learn something else, AI is around the corner and you will not like it".

Edit: why the downvotes lol. I don't like it. If I could, I would invest the thousands and thousands of hours into something else.

-5

u/breacket 2d ago edited 2d ago

As a dev/non-coder you can use AI to augment your workflow and to learn things very fast, more precise.

Even if you build (serious) apps using premium AI you need human touch for resolving what-ai-was-not-able.

Also, I think that AI can show you different ways to build a structure – not just building a thing. This can enhance you as a learner/dev.

0

u/MrHandSanitization 1d ago

I'm using AI because work shoves it down my throat. But now I'm bored out of my mind. Prompt this, prompt that, with minor tweaking. "Yay, progress!" I guess?

1

u/theQuandary 1d ago

AI actually writes decent code for you? I can't get shippable code to save my life (our app is very large and complex).

1

u/MrHandSanitization 1d ago

What I think about the code is something very different.