JavaScript难学吗?

The degree of difficulty in learning JavaScript depends on the level of knowledge you bring to it. Because the most common way to run JavaScript is as part of a web page, you must first understand HTML. In addition, a familiarity with CSS is also useful because CSS (Cascading Style Sheets) provides the formatting engine behind the HTML.

学习JavaScript的难度取决于您所掌握的知识水平。 因为运行JavaScript的最常见方法是作为网页的一部分,所以您必须首先了解HTML。 此外,熟悉CSS也很有用,因为CSS(层叠样式表)提供了HTML背后的格式设置引擎。

比较JavaScript和HTML ( Comparing JavaScript to HTML )

HTML is a markup language, meaning that it annotates text for a particular purpose and it's human-readable. HTML is a fairly straightforward and simple language to learn. 

HTML是一种标记语言,这意味着它可以为特定目的注释文本,并且易于阅读。 HTML是一种相当简单易学的语言。

Each piece of content is wrapped inside HTML tags that identify what that content is. Typical HTML tags wrap paragraphs, headings, lists and graphics, for example. An HTML tag encloses the content within angle brackets, with the tag name appearing first followed by a series of attributes. The closing tag to match an opening tag is identified by placing a slash in front of the tag name. For example, here's a paragraph element:

每段内容都包装在HTML标记内,这些标记标识该内容是什么。 例如,典型HTML标签包含段落,标题,列表和图形。 HTML标签将内容括在尖括号中,标签名称首先出现,然后是一系列属性。 与开始标签匹配的结束标签是通过在标签名称前面放置斜杠来标识的。 例如,这是一个段落元素:

And here is the same paragraph element with an attribute title:

这是具有属性标题的同一段落元素:

JavaScript, however, is not a markup language; rather, it is a programming language. That by itself is enough to make learning JavaScript a lot more difficult than HTML. While a markup language describes what something is, a programming language defines a series of actions to be performed. Each command written in JavaScript defines an individual action — which can be anything from copying a value from one place to another, performing calculations on something, testing a condition, or even providing a list of values to be used in running a long series of commands that have been previously defined.

但是,JavaScript不是标记语言。 而是一种编程语言。 这本身就足以使学习JavaScript比HTML困难得多。 标记语言描述了什么,而编程语言定义了一系列要执行的动作 。 每个用JavaScript编写的命令都定义了一个单独的动作-可以是将一个值从一个地方复制到另一个地方,对某物进行计算,测试条件,甚至提供要用于运行一系列命令的值列表之类的任何操作之前已经定义的

As there are lots of different actions that can be performed and those actions can be combined in many different ways, learning any programming language is going to be more difficult than learning a markup language.

由于可以执行许多不同的动作,并且可以用许多不同的方式组合这些动作,因此学习任何一种编程语言都比学习标记语言要困难得多。

However, there's a caveat: To be able to properly use a markup language, you need to learn the entire language. Knowing part of a markup language without knowing the rest means that you cannot mark up all of the page content correctly. But knowing a part of a programming language means that you can write programs that use the part of the language that you know to create programs.

但是,有一个警告:要正确使用标记语言,您需要学习整个语言。 不了解标记语言的其余部分而知道标记语言的一部分意味着您无法正确标记所有页面内容。 但是,了解一部分编程语言意味着您可以编写使用一部分已知语言来创建程序的程序。

While JavaScript is more complex than HTML, you can start writing useful JavaScript far more quickly than you might take to learn how to correctly mark up web pages with HTML. It will, however, take you a lot longer to learn everything that can be done with JavaScript compared to HTML.

尽管JavaScript比HTML更复杂,但是您可以比学习如何正确地用HTML标记网页更快地开始编写有用JavaScript。 但是,与HTML相比,它需要花费更多的时间来学习JavaScript可以完成的所有工作。

将JavaScript与其他编程语言进行比较 ( Comparing JavaScript to Other Programming Languages )

If you already know another programming language, then learning JavaScript will be much easier for you than it was to learn that other language. Learning your first programming language is always the hardest, because when you learn a second and subsequent language that uses a similar programming style, you already understand the programming style and just need to learn how the new language sets out its specific command syntax.

如果您已经知道另一种编程语言,那么学习JavaScript比学习另一种语言要容易得多。 学习第一种编程语言总是最困难的,因为当您学习使用类似编程风格的第二种及后续语言时,您已经了解了该编程风格,只需要学习新语言如何设置其特定的命令语法即可。

编程语言样式的差异 ( Differences in Programming Language Styles )

Programming languages have different styles. If the language you already know has the same style, or paradigm, than does JavaScript, learning JavaScript will be fairly easy. JavaScript supports two styles: procedural, or object oriented. If you already know a procedural or object-oriented language, you will find learning to write JavaScript the same way relatively easy.

编程语言具有不同的样式。 如果您已经知道的语言与JavaScript具有相同的样式或范例,那么学习JavaScript将会非常容易。 JavaScript支持两种样式: 过程式面向对象 。 如果您已经知道一种过程语言或面向对象的语言,就会发现学习以相同的方式编写JavaScript相对容易。

Another way in which programming languages differ is that some are compiled while others are interpreted:

编程语言与众不同的另一种方式是,有些被编译而另一些被解释:

  • A compiled language is fed through a compiler which converts the entire code into something that the computer can understand. The compiled version is what gets run; if you need to make changes to the program, you must recompile the program before running it again.

    编译语言通过编译器提供,编译器将整个代码转换为计算机可以理解的内容。 编译后的版本将运行。 如果需要更改程序,则必须在重新运行该程序之前重新编译该程序。

  • An interpreted language converts the code into something the computer can understand at the time the individual commands are run; this kind of language is not compiled in advance. JavaScript is an interpreted language, which means that you can make changes to your code and run it again straight away to see the effect of your change without having to recompile the code.

    解释语言将代码转换为计算机在运行各个命令时可以理解的内容。 这种语言不是预先编译的。 JavaScript是一种解释型语言,这意味着您可以对代码进行更改,然后立即再次运行它以查看更改的效果,而无需重新编译代码。

各种语言的测试要求 ( Testing Requirements for Various Languages )

Another difference between programming languages is where they can be run. For example, programs that are intended to run on a web page require a web server that is running the appropriate language.

编程语言之间的另一个区别是可以在哪里运行它们。 例如,要在网页上运行的程序需要运行适当语言的Web服务器。

JavaScript is similar to several other programming languages, so knowing JavaScript will make it fairly easy to learn the similar languages. Where JavaScript has the advantage is that support for the language is built into web browsers — all you need to test your programs as you write them is a web browser to run the code in — and just about everyone has a browser already installed on their computer. To test your JavaScript programs, you don't need to install a server environment, upload the files to a server elsewhere, or compile the code. This makes JavaScript an ideal choice as a first programming language.

JavaScript与其他几种编程语言相似,因此了解JavaScript将使学习类似语言变得相当容易。 JavaScript的优势在于Web浏览器中内置了对该语言的支持-编写程序时只需测试一下程序,即可在其中运行代码的Web浏览器-几乎每个人的计算机上都已经安装了浏览器。 要测试JavaScript程序,无需安装服务器环境,将文件上传到其他地方的服务器或编译代码。 这使JavaScript成为第一种编程语言的理想选择。

Web浏览器的差异及其对JavaScript的影响 ( Differences in Web Browsers and Their Effect on JavaScript )

The one area in which learning JavaScript is harder than other programming languages is that different web browsers interpret some JavaScript code slightly differently. This introduces an extra task into JavaScript coding that several other programming languages don't need — that of testing how a given browser expects to perform certain tasks.

学习JavaScript其他编程语言更难的一个方面是,不同的Web浏览器对某些JavaScript代码的解释略有不同。 这在JavaScript编码中引入了额外的任务,而这是其他几种编程语言所不需要的—测试给定浏览器如何执行某些任务。

结论 ( Conclusions )

In many ways, JavaScript is one of the easiest programming language to learn as your first language. The way that it functions as an interpreted language within the web browser means that you can easily write even the most complex code by writing it a small piece at a time and testing it in the web browser as you go. Even small pieces of JavaScript can be useful enhancements to a web page, and so you can become productive almost immediately.

在许多方面,JavaScript是作为您的第一门语言学习的最简单的编程语言之一。 它在Web浏览器中充当解释语言的方式意味着您可以一次编写一小段代码,然后在Web浏览器中对其进行测试,从而轻松编写甚至是最复杂的代码。 即使是很小JavaScript片段也可以是对网页的有用增强 ,因此您几乎可以立即提高工作效率。

翻译自: https://www.thoughtco.com/how-hard-is-javascript-to-learn-2037676

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值