Chapter 4 JavaScript Overview

Source: Internet
Author: User

Javascript is an object-oriented and interpreted programming language. Javascript is a loose language, which means that its variables do not have to have a definite type. Objects in Javascript map attribute names to any attribute values.

Javascript is the most widely used in Web browsers. It is usually called client-side Javascript. It emphasizes that scripts are run by client computers rather than by Web servers. Some of the client's JavaScript is formally standardized, some are de facto standards, and some are browser-specific extensions. Cross-browser compatibility is often an important concern for JavaScript programmers on the client.

Javascript is often considered simple because it is an interpreted language rather than a compiled language. However, in a simple appearance, JavaScript is a programming language with rich functions. It is as complex as all other languages, and even more complex than some languages.

The official name of JavaScript is ecmascript. However, this name is only officially used when standards are explicitly referenced. When a javascript interpreter is embedded into a web browser, the client Javascript is formed. Client JavaScript combines the scripting capabilities of the javascript interpreter with the Document Object Model (DOM) defined by the web browser. The client's JavaScript technology is the core of web development technologies such as DHTML and Ajax architecture.

The following is a simple JavaScript code:

In this example, <SCRIPT> and </SCRIPT> are used to embed Javascript code into an HTML file. In this example, we can learnDocument. Write (). When an HTML document is loaded into a browser, this method is used to dynamically output HTML text to an HTML document. In fact, the real strength of JavaScript on the client is that scripts can access the content of HTML documents, which will be further discussed in subsequent articles.

Javascript is a universal programming language, and its purpose is not limited to Web browsers. Javascript is designed to be embedded in any other application and provide scripting capabilities for the application.

Mozilla provides two different versions of javascript1.5 interpreter. One of them is written in C and is called spidermonkey. The other is written in Java, Called Rhino.

If the JavaScript code we wrote is very short, you can useJavascript:The URL pseudo protocol is used to calculate the Javascript expression and return the calculation result. A javascript URL is composed of javascript: Protocol specifiers plus arbitrary JavaScript code (separated by semicolons. When the browser loads such a URL, it will execute the JavaScript code. The value of the last expression in such a URL will be converted to a string, which will be displayed as a new document in the Web browser. For example:

javascript:x=3;(x<5)? "x is less": "x is greater"

In the Firefox Web browser, you can also enter a single line in the Javascript console for testing. You can access the Javascript console through the tool menu, you only need to enter the expression you want to calculate or the statement you want to execute. When using the console instead of the local address bar, you can ignore javascript: prefix.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.