学习javascript
For both newbie developers and veterans crossing over from another language, learning JavaScript is an uphill battle.
F或两者新手开发人员和退伍军人从另一种语言的交叉,学习JavaScript是一场艰苦的战斗。
Don’t be fooled by the lies. It takes time, effort, and monumental resilience on your part to push past its brutal starting gates and get to the point where you can build something of value.
不要被谎言骗了。 您需要花费时间,精力和巨大的韧性,才能克服其残酷的出发点,并达到可以建立有价值的东西的地步。
But it’s worth it. It’s a powerful, flexible language that can make you a lot of money. And it’s been, and will continue to be, a persistent fixture of the internet. So learning it is of long-term value for you and those that depend on you.
但这是值得的。 这是一种强大而灵活的语言,可以使您赚很多钱 。 过去一直并将继续是互联网的持久固定装置。 因此,学习它对于您和依赖您的人具有长期价值。
Here are four of the most challenging stumbling blocks to learn JavaScript and how to overcome them.
这是学习JavaScript及其克服方法的四个最具挑战性的绊脚石。
1.梦m语法 (1. Nightmare Syntax)
The first JavaScript hurdle you need to overcome is its nightmare syntax. Some languages are smothered in Syntactic Sugar and are elegantly constructed so they are as humanly readable as possible.
您需要克服的第一个JavaScript障碍是它的噩梦语法。 一些语言在语法糖中令人窒息,并且结构优雅,因此它们尽可能地被人类阅读。
And then there’s JavaScript:
然后是JavaScript:
![Image for post](https://i-blog.csdnimg.cn/blog_migrate/66f94d001f47d0c802ed6801e952a602.png)
I come from a technical writing background, so to me JavaScript is like the world’s worst run-on sentence. Bracket, [content], bracket, [content], comma, [content], semi-colon, semi-colon…it’s a damned challenge to read.
我来自技术写作背景,所以对我来说JavaScript就像是世界上最糟糕的连续句子 。 方括号,[内容],方括号,[内容],逗号,[内容],分号,分号... 这是一个该死的挑战 。
() => { If (you can’t easily {(and naturally;)} read a language), {then you are going to have a => hell of a time learning it;}}.
}); });
如何克服 (How to overcome)
All programming languages have this challenge, but JavaScript is extra special with the way it’s constructed. It uses a hell of a lot of punctuation ({},:.’’;()), which your brain is trained to understand as pauses in thought, emphasis, breaks, and so on. But they don’t mean the same in JavaScript. So it’s a jarring, confusing experience reading JavaScript for the first time.
所有编程语言都面临这一挑战,但是JavaScript的构造方式特别特殊。 它使用了很多标点符号( {},:。'';;() )的地狱,您的大脑经过训练后可以理解为思想的停顿,强调,休息等。 但是它们在JavaScript中的含义并不相同。 因此,这是第一次阅读JavaScript的经历,令人感到困惑。
There is no way around this, you just have to get used to it. But knowing that just reading the code is part of the battle can give you comfort. It’s not you — it’s JS — and it will take time.
无法解决此问题,您只需要习惯即可。 但是,知道只是阅读代码是战斗的一部分,这会让您感到舒适。 不是您,而是JS,这需要时间。
![Image for post](https://i-blog.csdnimg.cn/blog_migrate/058a05f3faf7a689f070838c630c985f.png)
One way I bridged this gap was to copy all the tutorial code into my IDE and add spaces, indentation, code comments, and so on to make it more legible.
我弥合这种差距的一种方法是将所有教程代码复制到我的IDE中,并添加空格,缩进,代码注释等,以使其更清晰。
Obviously, because it’s a tutorial the code should have been written this way in the first place, but it’s not. It never is. You have to do it yourself. People would think I was crazy and would laugh when they saw me in class formatting all the code samples. But honestly, this was the only way I could actually read this stuff.
显然,因为它是教程,所以代码应该首先以这种方式编写,但事实并非如此。 从来没有。 你必须自己做。 人们会以为我疯了,当他们看到我格式化所有代码示例的类时会笑。 但老实说,这是我真正阅读这些东西的唯一方法。
Eventually, your brain retrains itself to understand the punctuation differently and you can actually read it. But you have to hang in there for quite some time until it becomes secondary nature.
最终,您的大脑会重新训练自己,以不同的方式理解标点符号,并且您可以实际阅读它。 但是你必须在那儿呆上一段时间,直到它成为第二天性 。
2.集群F * ck代码 (2. Cluster F*ck Code)
Some languages force you to sensibly organize your code, but with JavaScript anything goes. Often, lazy developers dump everything into a single JavaScript file, which makes it a nightmare to read and understand. An impenetrable mess of Spaghetti Code!
某些语言会迫使您明智地组织代码,但是使用JavaScript可以解决任何问题。 通常,懒惰的开发人员会将所有内容都转储到一个JavaScript文件中,这使其成为阅读和理解的噩梦。 难以理解的意大利面条代码 !
![Image for post](https://i-blog.csdnimg.cn/blog_migrate/261c5818a3fc96039403da204bdc945a.png)
如何克服 (How to Overcome)
I don’t put up with this sh*t anymore and just move onto another tutorial.
我不再忍受这个麻烦了,只是继续学习另一个教程。
The internet is stuffed with getting starteds, learn to code in 10 minutes, bootcamps, books, and so on. If you run into a tutorial that has code like this, dump it and move on to one that doesn’t.
互联网上充斥着起步,在10分钟内学习编码,训练营,书籍等。 如果您遇到的教程包含这样的代码,请将其转储并转到没有的代码。
That’s right! Don’t waste your time parsing through spaghetti to find a single strand of meaning. I recommend that before you even begin a tutorial, look through its code and see how spaghetti-like it is. If it’s a mess, then move on to the next one.
那就对了! 不要浪费您的时间在意大利面条上进行解析,以找到单一含义。 我建议您甚至在开始教程之前,都要仔细阅读其代码,并了解其与意大利面条的相似程度。 如果是一团糟,请继续进行下一个。
3.教程由专家制作 (3. Tutorials Are Made By Experts)
Experts are the worst teachers. They don’t know what it is to not know — if you know what I mean — and often do more damage than good.
专家是最糟糕的老师。 他们不知道不知道是什么-如果您知道我的意思-常常造成的伤害大于好处。
My first intro to JavaScript course had this in one of the code samples: $(“#myDiv”)
. Supposedly, according to the class notes, this is the most simplistic JavaScript code to understand. All it does is scoop up a myDiv
element.
我JavaScript课程的第一篇入门文章中有一个代码示例: $(“#myDiv”)
。 据说,根据类说明,这是要理解的最简单JavaScript代码。 它所做的只是挖出myDiv
元素。
So I try to run the code locally and I can’t. This keeps popping up:
因此,我尝试在本地运行代码,但不能。 这一直弹出:
Uncaught ReferenceError: $ is not defined
Uncaught ReferenceError: $ is not defined
JavaScript developers will laugh because what’s wrong here is. But to a newbie, this is a Grand-Canyon-like gap in understanding.
JavaScript开发人员会笑,因为这里有问题。 但是对于新手来说,这是一种类似大峡谷的理解差距。
The problem is this ain’t JavaScript, it’s JQuery. And so many tutorial creators use frameworks and helper libraries to explain JavaScript basics. This is like teaching somebody English by first teaching them shorthand. It’s insane.
问题是这不是JavaScript,而是JQuery 。 因此,许多教程创建者使用框架和帮助程序库来解释JavaScript基础。 这就像先教速记员来教别人英语一样。 太疯狂了
如何克服 (How to Overcome)
You need to evaluate the sample code before you begin the course, book, blog, or whatever your starting. Look at what’s imported and required in the JavaScript file.
在开始学习课程,书籍,博客或任何其他内容之前,您需要评估示例代码。 查看JavaScript文件中导入的内容和必需的内容。
If you are seeing something like this at the top of the JavaScript file:
如果您在JavaScript文件顶部看到这样的内容:
![Image for post](https://i-blog.csdnimg.cn/blog_migrate/31de775a1879bc476c5f10ad439462b7.png)
…then stay away. Clearly, this person knows how to code but doesn’t know how to teach. Those are two very different things.
……然后远离。 显然,这个人知道如何编码,却不知道如何教学。 那是两件事。
Also, knowing the differences between JavaScript and its libraries and frameworks can help you differentiate the two which all the ‘expert’ instructors blend together:
同样,了解JavaScript及其库和框架之间的差异可以帮助您区分所有“专家”讲师融合在一起的两种情况:
Differences between JavaScript and helper libraries: https://bsscommerce.com/blog/javascript-jquery-ajax-are-they-the-same-or-different/
JavaScript库和帮助程序库之间的区别: https : //bsscommerce.com/blog/javascript-jquery-ajax-are-they-the-same-or-different/
Know the frameworks: https://blog.newrelic.com/engineering/best-javascript-libraries-frameworks/ && https://en.wikipedia.org/wiki/JavaScript_framework
了解框架: https : //blog.newrelic.com/engineering/best-javascript-libraries-frameworks/ && https://en.wikipedia.org/wiki/JavaScript_framework
4.跑步之前要跑步 (4. Running Before You Can Walk)
Everybody wants to build something amazing from the get-go, so they fire up a React, Angular, etc, tutorial to get started (cause those things look amazing). Resist this temptation ! You will fall straight on your face because learning this way is impossibly complicated.
每个人都想从一开始就构建出惊人的东西,因此他们启动了React , Angular等教程来上手(因为这些东西看起来很棒)。 抵制这种诱惑! 您将直奔您的脸,因为学习这种方式是不可能的。
You should never learn a framework first and a language second. It’s rediculous, but a Aalot of developers try this, get frustrated, cold feet, and then quit. Then they blame JavaScript for their failure. Nuts to them!
您永远不应首先学习框架,然后再学习语言。 这很繁琐,但是Aalot的开发人员尝试了此操作,感到沮丧,冷漠,然后退出。 然后,他们将失败归咎于JavaScript。 给他们坚果!
如何克服 (How to Overcome)
![Image for post](https://i-blog.csdnimg.cn/blog_migrate/2697089962671c387951ce4601015f3d.png)
Learn to walk before you can run. Start your JavaScript adventure with VanillaJS (plain JavaScript) and learn the basics before you leap into advanced realms. Even if you are an awesome Java, PHP, C++, or whatever, you need to learn the basics before moving onto advanced tasks.
跑步之前,请学会走路。 从VanillaJS(普通JavaScript)开始您JavaScript冒险,并在跳入高级领域之前学习基础知识。 即使您是精湛的Java,PHP,C ++或其他工具,也需要先学习基础知识,然后再进行高级任务。
VanillaJS started as a kind of backlash joke against all the overwrought JavaScript frameworks that were choking the internet. Now it’s becoming an actual back-to-basics movement, which is a fantastic way to learn JavaScript.
VanillaJS最初是对所有阻塞互联网的过度使用JavaScript框架的嘲笑。 现在,它已成为一种真正的从基础开始的运动,这是学习JavaScript的绝妙方式。
Great VanillaJS learning resources:
很棒的VanillaJS学习资源:
Also, if you are going to buy a book, this is a fantastic soup to nuts VanillaJS resource:
最后的想法 (Final Thoughts)
Often, in life and learning, it’s not the complexities of the task that cause us to stumble, it’s the stupid little things that knock us off course. And the journey to learn JavaScript is filled with many stupid little things.
通常,在生活和学习中,不是让任务失败的复杂性,而是使我们步履蹒跚的愚蠢小事情。 学习JavaScript的旅程充满了许多愚蠢的小事情。
Hopefully, I’ve captured the key 🤦♂ to help you streamline your learning.
希望我已经掌握了关键的🤦♂,以帮助您简化学习。
Remember too, that everybody lies. People who say they got started with JavaScript and were banking bucks in 4 months time are all lying. It took them years to learn these skills. Trust me. Don’t feel bad if you don’t get it in 4 months or even 6 or even longer. Everybody learns at their own pace and nothing is wrong with what.
还要记住,每个人都在说谎。 那些说开始使用JavaScript并在4个月内赚钱的人都在撒谎。 他们花了多年的时间来学习这些技能。 相信我。 如果您在4个月甚至6甚至更长的时间内没有得到它,就不会感到难过。 每个人都按照自己的步调学习,什么都没有错。
And remember: the hardest part of any journey are the first steps. Once you surmount those, the going gets easier and easier.
请记住:任何旅程中最困难的部分是第一步。 一旦克服了这些困难,事情就会变得越来越容易。
Good luck, good learning, and good programming.
祝你好运,学习和编程很好。
翻译自: https://medium.com/illumination/why-cant-i-learn-javascript-2ae4f693141b
学习javascript