JavaScript 有什么用

发布于 2024-09-14 10:18:29 字数 1435 浏览 3 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

魂ガ小子 2024-09-21 10:18:30

Javascript 的主要用途是它允许您在用户的浏览器中进行操作,而无需向服务器来回发送消息。您可能想要这样做的原因有多种。

例如,向服务器发送消息并获得回复是一个相对较长的过程:它几乎总是明显的时间滞后,并且可能需要很多秒。直接在浏览器中执行某些操作可能会快得多。因此,例如,如果您想向用户提供某种“无效数据”消息,如果它来自 Javascript,那么速度会快得多。

同样,使用 Javascript,您可以逐个字段进行验证,而不是等到用户完全填写屏幕并单击提交按钮。例如,假设您向用户显示一个屏幕,他应该在其中输入交易日期和金额。用户输入一个充满这些交易的整个屏幕——可能是 20 或 30 笔交易——然后点击提交。如果用户尝试以您无法识别的格式输入日期,例如在您期望年月日时输入日/月/年,那么使用 Javascript,您可能会在第一个无法识别的日期时给他一个错误。通过往返服务器,在你告诉他他做错了之前,他会输入整个屏幕的无效日期。

同样,尝试通过往返服务器来制作动画不太可能起作用,它会太慢。一种方法是使用 Javascript。 (当然还有其他方法。)

The main use of Javascript is that it allows you to make things happen in the user's browser without sending messages back and forth to the server. There are a variety of reasons why you might want to do this.

For example, sending a message to the server and getting a reply is a relatively long process: it is almost always a noticable time lag, and can take many seconds. Doing something directly in the browser can be much faster. So if, for example, you want to give the user an "invalid data" message of some sort, it can be much faster if it comes from Javascript.

In the same vein, with Javascript you can validate field-by-field rather than waiting until the user has completely filled out the screen and clicked a submit button. For example, suppose you present the user with a screen where he's supposed to enter transaction dates and monetary amounts. The user enters a whole screen full of these -- maybe 20 or 30 transactions -- and then clicks submit. If the user attempts to type dates in a format that you don't recognize, say typing day/month/year when you expected year-month-day, then with Javascript you could give him an error on the first unrecognizable date. With a round trip to the server, he'd have typed in a whole screen-full of invalid dates before you tell him he's doing it wrong.

Similarly, trying to do animation with round trips to the server would be unlikely to work, it would be way too slow. One way to do it would be with Javascript. (There are other ways, of course.)

自由范儿 2024-09-21 10:18:30

JavaScript 可以用于多种不同的事情。

当在浏览器中与 HTML 一起使用时,它可以添加一些非常酷的动态和交互功能(与 HTML 历史上的静态性质相比)。

当与 Node.JS 这样的服务器端引擎一起使用时,它几乎可以完成任何其他服务器端语言能够完成的任何事情。

Javascript can be used for a multitude of different things.

When used alongside HTML in the browser, it can add some really cool dynamic and interactive features (compared with the historically static nature of HTML).

When used alongside a server-side engine like Node.JS, it can do just about anything any other server-side language is capable of.

维持三分热 2024-09-21 10:18:30

javascript 使您能够获取静态 html 并在浏览器中实时添加/更改它。使用 javascript 时要考虑的主要事情可能是:不要信任它来验证事物,并将其作为一项功能构建,而不是使您的网站正常运行的要求(换句话说,如果用户已禁用)。

javascript enables you to take your static html and add/make changes to it live on in the browser. Probably the main things to consider with javascript is: do not trust it for validating things, and build it in as a feature, not a requirement for making your site function (In other words, your site should still be able to function if the user has it disabled).

櫻之舞 2024-09-21 10:18:30

http://en.wikipedia.org/wiki/Javascript

  • 公然抄袭他们...

JavaScript 是 ECMAScript 语言标准的实现,通常用于启用对主机环境中的计算对象的编程访问。它可以被描述为一种基于原型的、动态的、弱类型的、具有一流功能的面向对象脚本语言。它也被认为是像Scheme和OCaml一样的函数式编程语言,因为它具有闭包并支持高阶函数。

JavaScript 主要以客户端 JavaScript 的形式使用,作为 Web 浏览器的一部分实现,以提供增强的用户界面和动态网站。然而,它在网页以外的应用程序中的使用也很重要。


还应该注意的是:没有“JavaScript 的主要座右铭”,因为它是一个标准,而不是一个项目。对于项目,请查看jQuery,因为它是该网站上开发人员最常采用的一种。有很多用于使用 JavaScript 的工具包

使用 JavaScript 时的主要考虑因素是了解它通常与 文档对象一起使用模型,因此您会发现大多数人都在提供使用 JavaScript 的方法。然而,它是一种功能齐全的语言,并且有多种方法可以将其编译为本机机器代码。举个例子,大多数浏览器都为 JavaScript 实现了即时编译器。这些 JIT 编译器将 JavaScript 转换为本机字节码,以便在主机系统上执行。


为什么要使用 JavaScript?您可以将其用于表单元素的客户端验证(最常见的一种)、用户交互(在浏览器窗口中拖放、插入新的表单元素,例如用于向表中添加新记录的文本框)、用户交互通知(Facebook 通知)、从服务器异步检索数据并将其加载到页面中 (AJAX) 或一长串其他可能的操作。在这里列出 JavaScript 可以使用的所有功能将是一项巨大的努力。

由于它是一种原型语言,因此可以用 JavaScript 编写 C 风格的程序。

由于它是一种函数式语言,因此可以用 JavaScript 编写 Lisp 风格的程序。

如果您接受过计算机科学方面的正式培训,那么您可能会熟悉这两种语言。大多数计算机程序都是用这两种风格之一编写的。由于 JavaScript 允许开发人员以他最流利的风格进行编写,因此这可以证明是一个福音,因为开发人员能够在介绍该语言时更快地开始编写代码。

我见过成熟的游戏充满了用 JavaScript 编写的复杂图形。我还看到过带有一些用 JavaScript 编写的基本操作功能的基本视频播放器(依赖于 HTML5)。


然而,JavaScript 最常用于 Web 应用程序,因此请务必记住 JavaScript 被用作客户端语言。不影响服务器上的操作。它可以绕过。不要依赖 JavaScript 来为您的应用程序完成所有操作。


希望这对您有所帮助并为您提供一些指导并回答您的问题?

http://en.wikipedia.org/wiki/Javascript

  • Blatantly ripping them off...

JavaScript is an implementation of the ECMAScript language standard and is typically used to enable programmatic access to computational objects within a host environment. It can be characterized as a prototype-based object-oriented scripting language that is dynamic, weakly typed and has first-class functions. It is also considered a functional programming language like Scheme and OCaml because it has closures and supports higher-order functions.

JavaScript is primarily used in the form of client-side JavaScript, implemented as part of a web browser in order to provide enhanced user interfaces and dynamic websites. However, its use in applications outside web pages is also significant.


It should also be noted: there is no "main motto in JavaScript" as it's a standard, not a project. For projects, check out jQuery as being the one most frequently adopted by developers on this site. There are a great many toolkits for working with JavaScript.

The main consideration when working with JavaScript is to understand that it is usually used hand-in-hand with the Document Object Model and so therefore this is where you will find most people offering ways to use JavaScript. However, it is a fully functional language, and there are ways to compile it to native machine code. An example of how this is possible is by noting that most browsers implement a just-in-time compiler for JavaScript. These JIT compilers convert the JavaScript to native bytecode for execution on the host system.


Why would you use JavaScript? You could use it for such purposes as client-side validation of form elements (one of the most common), user interaction (drag and drop in a browser window, insert new form elements like textboxes for adding new records to a table), user notification (Facebook notifications), asynchronously retrieving data from a server and loading it into the page (AJAX), or a long list of other possible operations. To list every feature of what JavaScript could be used for here would be a heroic effort.

Since it is a prototype language, one can write C style programs in JavaScript.

Since it is a functional language, one can write Lisp style programs in JavaScript.

If you've had any formal training in Computer Science then those two languages may be familiar to you. The majority of computer programs are written in either of those two styles. Since JavaScript allows a developer to write in the style with which he is the most fluent, this can be shown to be a boon as the developer is able to start writing code faster on introduction to the language.

I have seen full fledged games replete with complicated graphics written in JavaScript. I have also seen rudimentary video players (relying on HTML5) with some basic manipulation functionality written in JavaScript.


However, JavaScript being most often used in web applications, it's important to remember that JavaScript is used as a client-side language. It does not affect operations on the server. It can be bypassed. Do not rely on JavaScript to do EVERYTHING for your application.


Hopefully this helps and gives you some guidance and answers your question?

近箐 2024-09-21 10:18:30

Web 开发有 3 个主要组件:HTML、CSS 和 Javascript。

HTML 用于保存网页或网络应用程序的数据、内容和结构。

CSS 用于网页或 Web 应用程序的样式、布局和视觉外观。

Javascript(通常)用于网页或 Web 应用程序的动态或反应方面:动画、表单验证、ajax 等。

In web development there are 3 main components: HTML, CSS, and Javascript.

HTML is for holding the data, the content, the structure of your webpage or webapp.

CSS is for the style, layout, and visual look of your webpage or webapp.

And Javascript is (often) for the dynamic or reactive aspects of your webpage or web app: animations, form validation, ajax, and so forth.

め可乐爱微笑 2024-09-21 10:18:30

您可以使用 javascript 使您的页面更具交互性。您可以在将内容发送到服务器之前检查内容,并为用户节省时间。你可以用它创建很多有趣的东西...有许多 Web 应用程序依赖 javascript 作为其主要引擎。

You can use javascript to make your pages more interactive. You can check stuff before sending it server and save time for the user. You can create a lot of interesting stuff with that... there are many web applications relying on javascript as their main engine.

嘿哥们儿 2024-09-21 10:18:30

您可以使用 Javascript 在应用程序中开发客户端“事物”。这使您无需返回服务器,这有利于:较低的带宽使用、较低的服务器强度使用和更好的客户端用户体验。一个流行的框架是jquery。

You can use Javascript to development client side "things" in your application. This saves you from going back to the server, which is good for: lower band usage, lower server strength usage and better client user experience. A popular framework is jquery.

杯别 2024-09-21 10:18:30

JavaScript 是一种由网络浏览器执行的语言,通常用于制作动态网页。一个简单的例子是,如果您希望对用户在表单中输入的值执行一些简单的计算(例如运费)。您可以让用户每次需要答案时将数据发布到服务器,或者您可以使用一个按钮来执行 JavaScript 计算并向用户显示答案。当然,还有更复杂的例子。 AJAX是当前流行的JavaScript应用程序。

JavaScript is a language that is executed by web browsers and is often used to make dynamic web pages. A simple example would be if you wish to perform some simple calculations (such as shipping costs) on values that a user puts in a form. You could make the user posts data to the server every time they want an answer, or you could have a button the execute a JavaScript calculation and display the answer to the user. There are more complex examples, of course. AJAX is a currently popular application of JavaScript.

澜川若宁 2024-09-21 10:18:30

如今 JavaScript 就是用来杀死桌面应用程序的!!!
例如 ExtJs 就是完美的库。

Nowadays JavaScript is for killing desktop applications!!!
For example ExtJs is perfect library for it.

2024-09-21 10:18:30

它是一种脚本语言,可用于构建动态页面,但最重要的是,它将运行这些应用程序的一些计算工作从服务器转移到客户端计算机。

JavaScript 非常强大,因此很难列出用它可以完成的所有事情。我不知道如果没有它,Web 2.0 会是什么样子。

如今,JavaScript 正变得非常主流。为了让 V8 JavaScript 引擎<中的 Javascript 变得更快,Google 付出了很多努力/a>.这引起了人们对服务器端 JavaScript 使用的浓厚兴趣。

NodeJs 是服务器端应用程序的一个很好的例子,它现在越来越受欢迎,在用例中有很多前景异步和函数式编程有意义的地方(如网络应用程序)。

其他应用程序,如基于 WebKit 的无头浏览器 PhantomJs 是构建 javascript 测试应用程序或自动网络抓取器时的自然选择。 (CasperJs 是构建在 PhantomJs 之上的项目的一个很好的示例)。

从概念上讲,JavaScript 比人们遇到的其他语言更困难,因为它既是原型的又是函数式的。尽管可以使用多年来构建的一些标准模式来设计应用程序,但是有很多方法可以实现完全相同的模式,并且对于实现这些设计的最佳方法没有最佳实践的标准化或共识。

现在有很多工具 CofeeScriptTypeScript 允许开发人员使用面向对象的语言进行编码,并编译为标准的面向对象的 JavaScript 子集,从而帮助缩小这一差距。

It's a scripting language that can be used to build dynamic pages but most importantly, it shifts some of the computational effort of running these applications from the server to the client machine.

JavaScript is pretty powerful, so it would be difficult to list everything that can be done with it. I wouldn't know what Web 2.0 would look like without it.

JavaScript is becoming very mainstream these days. There has been a lot of effort put in by Google to make Javascript fast in the V8 JavaScript Engine. Which has led to a lot of interest in serverside JavaScript use.

NodeJs is a good example of a server-side application that is now growing in popularity with a lot of promise in use cases where asynchronous and functional programming makes sense (like networking applications).

Other applications like PhantomJs a headless browser based on WebKit are natural choices when building javascript testing applications or automatic web-scrapers. (CasperJs is a great example of a project built on top of PhantomJs).

JavaScript is conceptually more difficult than other languages people come across because it is prototypical as well as functional. Although it is possible to design applications using some of the standard patterns that have been built over the years, there are many ways to implement the exact same patterns and there is no standardization of best practice or consenses on the best way to implement these design.

There are now many tools that CofeeScript and TypeScript that help close that gap by allowing developers to code in an object oriented language that compiles to a standard object oriented subset of JavaScript.

山川志 2024-09-21 10:18:30

Javascript主要用于使网页变得动态和交互。我通常在浏览器中运行,但也有服务器端实现

Javascript is mostly used to make webpage dynamic and interactive. I typically runs in the browser but there are Server Side implementations

我爱人 2024-09-21 10:18:30

java脚本在浏览器中有多种用途,主要用于用户端或客户端,例如在表单中考虑一个文本框,您需要在其中输入整数,但您输入了一些字符串而不是在这种情况下输入的字符串它通知用户输入有效信息,例如弹出窗口或其他内容,这只是一个示例,但 java 脚本有多种用途。

java-script is used in a browser for many uses, used mostly on user side or client side , for example in a form consider a text-box where you need to input a integer but you have entered some string instead of that in that case it notifies the user to enter the valid information like a popup or something, this is just an example but java script is used for many purposes.

贱贱哒 2024-09-21 10:18:30

JavaScript 用于使网页动态/交互
它可用于验证字段、访问和修改 DOM,例如更改 HTML 属性、内容、样式
它也用于 Ajax

Javascript is used to make a webpage dynamic/Interactive
it can be used to validate fields, access and modify DOM such as change HTML attributes, contents, styles
It is also used for Ajax

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文