javascript优缺点
Like with all programming languages, JavaScript has certain advantages and disadvantages to consider. Many of these are related to the way JavaScript is often executed directly in a client's browser. But there are other ways to use JavaScript now that allow it to have the same benefits of server-side languages.
与所有编程语言一样,JavaScript也要考虑某些优点和缺点。 其中许多与通常直接在客户端浏览器中执行JavaScript的方式有关。 但是,现在还有其他使用JavaScript的方法可以使它具有服务器端语言的相同优点。
JavaScript的优势 (Advantages of JavaScript)
Speed - JavaScript tends to be very fast because it is often run immediately within the client's browser. So long as it doesn't require outside resources, JavaScript isn't slowed down by calls to a backend server. Also, major browsers all support JIT (just in time) compilation for JavaScript, meaning that there's no need to compile the code before running it.
速度 -JavaScript往往非常快,因为它通常在客户端的浏览器中立即运行。 只要不需要外部资源,对后端服务器的调用就不会降低JavaScript的速度。 同样,主要的浏览器都支持JavaScript的JIT(即时)编译,这意味着在运行代码之前无需编译代码。
Simplicity - JavaScript's syntax was inspired by Java's and is relatively easy to learn compared to other popular languages like C++.
简单性 -JavaScript的语法受Java启发,与其他流行语言(如C ++)相比,相对易于学习。
Popularity - JavaScript is everywhere on the web, and with the advent of Node.js, is increasingly used on the backend. There are countless resources to learn JavaScript. Both StackOverflow and GitHub show an increasing amount of projects that use JavaScript, and the traction it's gained in recent years is only expected to increase.
流行 -JavaScript在网络上无处不在,并且随着Node.js的出现,后端越来越多地使用JavaScript。 有无数学习JavaScript的资源。 StackOverflow和GitHub都显示出使用JavaScript的项目数量在增加,并且近年来它的吸引力预计只会增加。
Interoperability - Unlike PHP or other scripting languages, JavaScript can be inserted into any web page. JavaScript can be used in many different kinds of applications because of support in other languages like Pearl and PHP.
互操作性 -与PHP或其他脚本语言不同,可以将JavaScript插入任何网页。 由于对Pearl和PHP等其他语言的支持,JavaScript可用于许多不同类型的应用程序中。
Server Load - JavaScript is client-side, so it reduces the demand on servers overall, and simple applications may not need a server at all.
服务器负载 -JavaScript是客户端的,因此它减少了对服务器的总体需求,简单的应用程序可能根本不需要服务器。
Rich interfaces - JavaScript can be used to create features like drag and drop and components such as sliders, all of which greatly enhance the user interface and experience of a site.
丰富的界面 -JavaScript可用于创建诸如拖放之类的功能以及诸如滑块之类的组件,所有这些都极大地增强了用户界面和网站体验。
Extended Functionality - Developers can extend the functionality of web pages by writing snippets of JavaScript for third party add-ons like Greasemonkey.
扩展功能 -开发人员可以通过为第三方插件(如Greasemonkey)编写JavaScript片段来扩展网页的功能。
Versatility - There are many ways to use JavaScript through Node.js servers. If you were to bootstrap Node.js with Express, use a document database like MongoDB, and use JavaScript on the frontend for clients, it is possible to develop an entire JavaScript app from front to back using only JavaScript.
多功能性 -通过Node.js服务器使用JavaScript的方式有很多种。 如果要使用Express引导Node.js,使用MongoDB之类的文档数据库,并在客户端的前端使用JavaScript,则可以仅使用JavaScript从头到尾开发整个JavaScript应用。
Updates - Since the advent of ECMAScript 5 (the scripting specification that JavaScript relies on), ECMA International has been dedicated to updating JavaScript annually. So far, we have received browser support for ES6 in 2017 and look forward to ES7 being supported in the future.
更新 -自ECMAScript 5(JavaScript所依赖的脚本规范)问世以来,ECMA International一直致力于每年更新JavaScript。 到目前为止,我们已经在2017年获得了对ES6的浏览器支持,并希望将来能够支持ES7。
JavaScript的缺点 (Disadvantages of JavaScript)
Client-Side Security - Since JavaScript code is executed on the client-side, bugs and oversights can sometimes be exploited for malicious purposes. Because of this, some people choose to disable JavaScript entirely.
客户端安全性 -由于JavaScript代码是在客户端执行的,因此有时可能会出于恶意目的利用漏洞和疏忽。 因此,有些人选择完全禁用JavaScript。
Browser Support - While server-side scripts always produce the same output, different browsers sometimes interpret JavaScript code differently. These days the differences are minimal, and you shouldn't have to worry about it as long as you test your script in all major browsers.
浏览器支持 -尽管服务器端脚本始终会产生相同的输出,但不同的浏览器有时会以不同的方式解释JavaScript代码。 如今,差异很小,只要您在所有主要浏览器中测试脚本,就不必担心。
翻译自: https://www.freecodecamp.org/news/the-advantages-and-disadvantages-of-javascript/
javascript优缺点