"JacaScript Definitive Guide (Fifth Edition)" reading notes (Chapter 1) - JavaScript overview

Table of contents

overview

JavaScript is an object-oriented, interpreted programming language.

In terms of syntax , the core language of JavaScript is similar to C, C++, and Java, and all have program structures such as if statements, while loops, and && operators. However, JavaScript's resemblance to these languages ​​is limited to syntactic similarities.

JavaScript is a loosely typed language, which means that its variables don't have to have an explicit type. Objects in JavaScript map property names to arbitrary property values. They're more like hash tables (in Perl) or associative arrays (in Perl) than structures (in C) or objects (in C++ or Java) in this way.

The OO inheritance mechanism in JavaScript is based on prototypes, which is very similar to the lesser-known Self language, but very different from inheritance in C++ and Java.

JavaScript's core language supports numbers, strings, and booleans as primitive data types, and it also has built-in support for arrays, dates, and regular expression objects.

JavaScript is most widely used in web browsers, where the general-purpose core is extended by objects that allow scripts to interact with the user, control the web browser, and modify document content as it appears in the browser window. This embedded version of JavaScript runs scripts embedded in HTML Web pages, and it is often called client-side JavaScript to emphasize that the scripts are run by the client computer rather than by the Web server.

1. What is JavaScript

1. JavaScript is not Java

The most common misconception about JavaScript is that it is a simplified version of Java, Sun Microsystems' programming language. But aside from some similarities in syntax and the ability to serve executable content in a web browser, JavaScript and Java are completely unrelated. The language was originally called LiveScript, but it was only changed to JavaScript at the end . The similarity in the name is purely a marketing strategy of Netscape and Sun. However, JavaScript can actually script Java (see Chapters 12 and 23 for details).

2. JavaScript is not simple

Because JavaScript is an interpreted language rather than a compiled language, it is often considered a scripting language
rather than a true programming language. The subtext of this perception is that scripting languages ​​are relatively simple, and they are programming languages ​​used by
non- programmers.

But beneath the surface of simplicity, JavaScript is a feature-rich programming language that is
as complex as all languages, if not more complex than some. If a programmer does not have
a solid understanding of JavaScript, then when he wants to perform more complex tasks in JavaScript, he will find the whole process
difficult .

Personal comment: With the development of front-end technology, the rise of Node.js, and the continuous update of JavaScript specifications, js programming is no longer the recipe programming that most people know. It even requires programmers to use object-oriented ideas to implement client-side scripts, as well as closure programming specifications to improve function security.

Second, the version of JavaScript

  • According to the ECMA-262 standard, the official name of the JavaScript language is ECMAScript.
  • ECMA-357 standardizes an extension called E4X (or ECMAScript for XML).
  • The proposal for the fourth edition of the ECMA-262 specification, which is the standardized specification of JavaScript 2.0.

3. Client-side JavaScript

Client-side JavaScript combines the standardization capabilities of JavaScript interpreters with the Document Object Model (DOM) defined by web browsers.

4. JavaScript in Other Environments

JavaScript is a general-purpose programming language, and its use is not limited to web browsers. JavaScript is designed to be embedded in any other application and provide scripting capabilities for the application.

  • In fact, from earliest times, Netscape 's web servers included a JavaScript interpreter to enable server-side scripting
    in JavaScript .

  • Similarly, Microsoft uses the JScript interpreter in its IIS Web server and Windows ScriptingHost products, and applies it to Internet Explorer.

  • Adobe uses a language derived from JavaScript to script its own Flash Payer.

  • Sun bundled a JavaScript interpreter with its Java 6.0 to make it easy to add scriptability to any Java application (Chapter 12 shows how to do this).

Both Netscape and Microsoft make JavaScript interpreters available to those who want to embed JavaScript interpreters in their programs. Netscape's interpreter is released as open source and is now available through the Mozi]Ia organization (see http://mozilla.org/js/ ).

Mosdlla actually provides two different versions of the JavaScript 1.5 interpreter.
- One of them is written in C called SpiderMonkey .
- The other is written in Java and is called Rhino .

Five, JavaScript Quest

It's actually very simple to start learning JavaScript, as long as you have a browser and a simple text editor on your computer, you don't need a bulky IDE like learning C++ or Java. You don't even need to use a text editor, open the browser, press F12 to bring up the console of the browser, type in it, and console.log('hello world!')you have already started your JavaScript journey.

Of course, if you want to be proficient in js programming, there are still many things to learn, and the road is long and far away, and I will search up and down. Even when you come into contact with node.js, you will find that it is a new world.

Guess you like

Origin blog.csdn.net/Jason_first/article/details/80162942