Home  >  Article  >  Web Front-end  >  What type of language is javascript?

What type of language is javascript?

青灯夜游
青灯夜游Original
2021-04-19 17:13:495525browse

Javascript is a dynamically typed and weakly typed language. It is a scripting language that is based on objects and events and is relatively safe and widely used in client web development. It is also a widely used scripting language. Scripting language for client-side web development.

What type of language is javascript?

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

JavaScript, also known as ECMAScript, is an object- and event-driven scripting language that is relatively safe and widely used in client-side web development. It is also a script widely used in client-side web development. language.

was first used in HTML to add dynamic functions to HTML web pages. It is a prototype-inherited object-oriented dynamic type case-sensitive client script language developed from Netscape's LiveScript. The main purpose is to solve the speed problems left by server-side languages, such as Perl, and respond to various user operations, providing customers with a smoother browsing effect. Because the server needed to verify the data at that time, because the network speed was quite slow, only 28.8kbps, the verification step wasted too much time. So Netscape's browser Navigator added Javascript to provide basic functions of data verification. However, JavaScript can now also be used in web servers such as Node.js.

1. The composition of javascript

A complete JavaScript implementation is composed of the following 3 different parts:

  • ECMAScript: describes the syntax and basic objects of the language;

  • Document Object Model (DOM)): describes the methods and interfaces for processing web content;

  • Browser Object Model (BOM): describes the methods and interfaces for interacting with the browser.

2. Basic characteristics of javascript

  • is an interpreted scripting language (the code is not pre-compiled) .

  • Mainly used to add interactive behaviors to HTML pages.

  • It can be directly embedded in HTML pages, but writing it as a separate js file is beneficial to the separation of structure and behavior.

3. Characteristics of JavaScript

Different from server-side scripting languages, such as PHP and ASP, JavaScript is mainly used as a client-side scripting language. Runs on the user's browser and does not require server support. Therefore, in the early days, programmers preferred JavaScript to reduce the burden on the server, but at the same time it also brought about another problem: security.

As servers become more powerful, although today's programmers prefer scripts running on the server to ensure security, JavaScript is still popular for its cross-platform and easy-to-use advantages. At the same time, some special functions (such as AJAX) must rely on Javascript to be supported on the client side. With the development of engines such as V8 and frameworks such as Node.js, and their features such as event-driven and asynchronous IO, JavaScript is gradually used to write server-side programs.

[Recommended learning: javascript advanced tutorial]

4. The historical background of the development of JavaScript

1. Nombas and ScriptEase

About 1992, a company called Nombas developed an embedded scripting language called C-minus-minus (Cmm for short). The idea behind Cmm is simple: a scripting language powerful enough to replace macros, while remaining similar enough to C (and C++) that developers can learn it quickly. The scripting language was bundled in a shareware called CEnvi, which for the first time showed developers the power of the language.

Nombas eventually changed the name of Cmm to ScriptEase because the last part (mm) sounded too negative and the letter C was "scary".

Now ScriptEase has become the main driving force behind Nombas products.

2. Netscape invented JavaScript

When Netscape Navigator came to prominence, Nombas developed a version of CEnvi that could be embedded in web pages. These early experiments were called Espresso Pages, and they represented the first client-side languages ​​used on the World Wide Web. Nombas had no idea that its concept would become an important cornerstone of the World Wide Web.

As Internet surfing becomes more and more popular, the need for developing client-side scripts also increases. At this time, most Internet users were connected to the network only through 28.8 kbit/s modems, even as web pages continued to become larger and more complex. What makes the user even more miserable is that just for simple form validity verification, it requires multiple round-trip interactions with the server. Imagine that the user fills out a form, clicks the submit button, waits for 30 seconds for processing, and then sees a message telling you that you forgot to fill in a necessary field.

Netscape, which was at the forefront of technological innovation at that time, began to seriously consider developing a client-side scripting language to solve simple processing problems.

Brendan Eich, who was working at Netscape at the time, began to develop a scripting language called LiveScript for Netscape Navigator 2.0, which was to be released in 1995. The purpose at that time was to use it on the browser and server (it was originally going to be called LiveWire). use it. Netscape and Sun completed LiveScript implementation in time.

Just before Netscape Navigator 2.0 was officially released, Netscape changed its name to JavaScript. Although Netscape originally named its scripting language LiveScript, Netscape later changed its name to JavaScript after working with Sun. JavaScript was originally inspired by Java and was designed. One of the purposes is to "look like Java", so there are similarities in syntax, and some names and naming conventions are also borrowed from Java. But the main design principles of JavaScript are derived from Self and Scheme.

The similarity in names between JavaScript and Java was the result of an agreement between Netscape and Sun Microsystems for marketing considerations at that time. In order to gain a technical advantage, Microsoft launched JScript to compete with JavaScript's scripting language. For interoperability, Ecma International (formerly the European Computer Manufacturers Association) created the ECMA-262 standard (ECMAScript). Both are now implementations of ECMAScript. Although JavaScript is promoted and advertised as a scripting language for non-programmers rather than as a scripting language for programmers, JavaScript is very rich in features. JavaScript has since become an essential component of the Internet.

3. Three pillars

Because JavaScript 1.0 was so successful, Netscape released version 1.1 in Netscape Navigator 3.0. It just so happened that Microsoft decided to get into browsers at that time, releasing IE 3.0 with a clone of JavaScript called JScript (so named to avoid potential licensing disputes with Netscape). Microsoft's entry into the world of web browsers, while infamous, was also an important step in the evolution of the JavaScript language.

After Microsoft entered, there were three different versions of JavaScript existing at the same time: JavaScript in Netscape Navigator 3.0, JScript in IE, and ScriptEase in CEnvi. Unlike C and other programming languages, JavaScript does not have a standard that unifies its syntax or features, and these 3 different versions highlight this problem. As concerns in the industry increase, it is clear that standardization of this language is imperative.

4. Standardization

In 1997, JavaScript 1.1 was submitted as a draft to the European Computer Manufacturers Association (ECMA). Technical Committee 39 (TC39) was appointed to "standardize the syntax and semantics of a general-purpose, cross-platform, vendor-neutral scripting language." Composed of programmers from Netscape, Sun, Microsoft, Borland, and other companies interested in scripting, TC39 hammered out ECMA-262, a standard that defined a new scripting language called ECMAScript.

The current implementations that comply with the ECMA-262 3rd Edition standard are:

  • Microsoft’s JScript

  • Mozilla’s JavaScript- C (C language implementation), now named SpiderMonkey

  • Mozilla’s Rhino (Java implementation)

  • Digital Mars Company DMDScript

  • Google's V8

What type of language is javascript?
(Click to view larger image)

In the following years, the International Organization for Standardization and the International Electrotechnical Commission (ISO/IEC) also adopted ECMAScript as a standard (ISO/IEC-16262). Since then, web browsers have worked hard (albeit with varying degrees of success and failure) to use ECMAScript as the basis for JavaScript implementations.

5. JavaScript is commonly used to complete the following tasks

1. Embed dynamic text in HTML pages

2. Respond to browser events

3. Read and write HTML elements

4. Verify the data before it is submitted to the server

5. Detect the visitor’s browser information

6. Control Cookies, including creation and modification, etc.

6. How to use Javascript

There are two ways to add Javascript to a web page: direct method and reference method.

1. Direct method

This is the most commonly used method. Most web pages containing Javascript use this method, for example:

<html>
     <head>
     <title>简单的JavaScript Hello World</title>
        <script type="text/javascript">
            document.write("Hello, 马海祥博客!");   // 在浏览器视窗内直接显示
            alert("Hello, 马海祥博客!");            //  弹窗显示
            console.log("Hello, 马海祥博客!");      // 在控制台(console)里显示,需要先开启开发工具控制台
        </script>
     </head>
     <body>
  HTML页面内容……
     </body>
  </html>

In this example, we You can see a new tag: <script>...</script>, and

Note that when inserting script tags in non-xhtml documents, if they are not referencing external files, they should be added within the script cdata statement to avoid browser parsing errors caused by the greater than and less than operators

2. Reference method

If there is already a Javascript source file (usually with js as the extension), you can Use this reference method to improve the utilization of program code. Its basic format is as follows:

<script src=“url” type="text/javascript"></script>

其中的Url就是程序文件的地址。同样的,这样的语句可以放在HTML文档头部或主体的任何部分。如果要实现“直接插入方式”中所举例子的效果,可以首先创建一个Javascript源代码文件“Script.js”,其内容如下:

document.write("这是Javascript!采用直接插入的方法!");

在网页中可以这样调用程序:

也可以同时在导入文件时制定javascript的版本,例如:

注意:凡是指定了src属性的script标签里的内容都会被忽略。

更多编程相关知识,请访问:编程视频!!

The above is the detailed content of What type of language is javascript?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to hide input in cssNext article:How to hide input in css