Home  >  Article  >  Web Front-end  >  9 common mistakes in javascript

9 common mistakes in javascript

小云云
小云云Original
2018-02-09 13:11:501261browse

This article mainly introduces and analyzes 9 common errors in JavaScript that hinder your progress. I hope this article can help you. Friends in need can refer to it. I hope it can help everyone.

Analyze 9 common mistakes in JavaScript that hinder your progress

Many people try to learn JavaScript, but give up soon. Then they tell themselves, "JavaScript is too complicated," or even worse, "I'm not a front-end developer."

This situation is quite sad. In fact, you don’t have to give up at all, all you have to do is change to a different learning method.

In this article, we’ll cover some of the most common learning mistakes and learn how to avoid them. Many of the techniques apply not only to JavaScript, but even to web development, so that’s a bonus.

Let’s do it!

Mistake #1: Overanalyzing before you start learning

You can find a lot of relevant information before you start learning JavaScript. If you look, you'll find some information about which JavaScript is the best or the worst, and whether you need this framework or that framework. You may also hear that you need to write JavaScript a certain way or you'll never become a "real" developer, etc.

Whether this is true or not, there is nothing worse than wasting six months to a year without getting started.

Start typing code, it may not be perfect, it may be terrible. But if you get started, you've passed one of the hurdles that holds many people back.

Mistake #2: Learning native JavaScript before learning frameworks

JavaScript frameworks are built on top of native JavaScript, so if you understand JavaScript, you will naturally understand it. Basic principles of how to use any JavaScript framework.

However, if you learn a framework directly, you will end up just memorizing its syntax but not understanding its principles. It's like making sentences without knowing the meaning of the words. You end up memorizing some words randomly without knowing their meaning and not organizing the words to use them.

If you jump directly into a framework, it will be harder to learn, and when you need another framework you will have a harder time adapting. If you learn basic JavaScript first, you will have a solid foundation to understand all frameworks.

Mistake #3: Aiming Too High

One of the most common mistakes is taking action immediately after understanding a concept.

I've been struggling with this because once you understand something, you want to take it further.

It's helpful to treat each concept like a new toy; this means taking some time to enjoy what you've just learned. Play, experiment, see if you can do something new. You'll learn a lot and you'll remember better.

When you feel that you can use it with your eyes closed, continue learning. It may take you a little more time before you get to this point, but it will make the rest of your learning faster.

On the other hand, if you are too impatient, you won’t pay much attention to details. But the frustrating thing is that this will greatly increase your subsequent learning costs. In fact, this is one of the common reasons why people often give up learning JavaScript.

Mistake #4: Not understanding the concept thoroughly

Learning is like climbing stairs: if you can take one step, you can keep taking more steps until you Achieve goals. When something is hard to understand, it's often because you want to take a leap rather than take it one step at a time. Of course this is wishful thinking!

In actual scenarios, when I see people don’t understand a certain piece of code, I will ask them to explain it, and they will try to explain the entire problem at once. Then I would ask them to explain it again line by line, so it makes sense.

If something is confusing, it's often because something was skipped, and this will also help you pay attention to the details until you figure out the crux. If a concept still doesn't make sense after breaking it down, you'll also have an easier time finding relevant solutions because it's easier to look up a specific topic than to search randomly.

Mistake #5: Trying complex projects too early

People who just start learning JavaScript often say, "I'll just set a small goal, like writing a Facebook website,” not realizing the depth involved in the project. As the project gets deeper, they give up on learning JavaScript.

I go into more detail about the project, but when learning, it's easier to start with some basic concepts. When you start working on a project, you can add some build tools to your toolkit.

To be more clear, I am not looking for a longer-lasting project. I've just discovered that if I do the easy parts first, like displaying some text in the browser or responding to a button, it makes it easier to get the project off the ground.

Mistake #6: Not practicing in a real environment

When you learn JavaScript, you may practice in situations that are not realistic. For example, you might type in the site's built-in code editor, or you might rely on pasting files from a tutorial.

These methods may be great for learning, but you can also try to build your own environment. This means using your own text editor and writing the project from scratch.

If you don't practice each concept independently, you will be dependent on the training environment. You end up in a situation where you've spent a lot of time learning, but you can't master any of them.

Mistake #7: Comparing Yourself to the Great Ones

One of the easiest ways to make yourself more frustrated is to compare yourself to the Great Ones. Because you always look at where they are, not how they got there.

For example, people see my tutorials and ask me how I write such clean code. They say they can't write clean code like this, so maybe they're just not that good at JavaScript after all.

The truth is my process is a mess. I experimented, made mistakes, looked up resources, wrote ugly code, and finally refined everything into a presentable tutorial. People see the good version and assume that's what the process is all about. I also made these assumptions about tutorial authors until I started writing my own tutorials.

The key point is, take what you are learning seriously and you will make progress. Keep repeating this process and soon others will be wondering how you reached those heights.

Mistake #8: Watching tutorials without writing code

You will naturally spend a lot of time watching videos and tutorials, but unless you write code yourself, Otherwise you can't really learn.

It is very dangerous to just watch without taking actual action. You will have the illusion that you are learning. After six months, you realize you haven’t learned anything.

Writing 15 minutes of code is much more useful than just watching an hour-long tutorial.

Mistake #9: Blindly following tutorials without first understanding or trying them yourself

When reading tutorials, it’s easy to fall into copycat situations. This kind of tutorial does not teach you how to solve a problem, such as what kind of tests need to be performed, and how to explore the possible directions of the problem step by step. Therefore, people who only follow tutorials often fail to learn real knowledge.

So what is the solution?

Don’t just follow the tutorial step by step, but take some time to implement it yourself. For example, if you're following a slideshow tutorial, try showing and hiding p, then try timing, and then try another small section. Rather than following a step-by-step tutorial, you'll learn more by trying it out and expanding on it, and likely apply it better.

Tips

After you read this article, if you ask me what I most want you to remember, it is by taking the smallest steps Make the most progress.

No matter what you are studying, you must learn its essence. Try what you learn and have fun doing it.

It may be difficult sometimes, but that’s okay. Challenge means you are improving your personal abilities, which will make you progress. If things always come too easy, it might mean you need to make some changes.

I hope this article was helpful to you. If there are any other methods that have helped you learn JavaScript, please feel free to share them in the comments!

Related recommendations:

js dynamically add click event common errors detailed explanation

php security configuration records and common errors detailed Summary introduction

Some common mistakes when using ajax in PHP

The above is the detailed content of 9 common mistakes in javascript. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn