JavaScript overview
History of JavaScript
- In 1992, Nombas developed the C-minus-minus (C--) embedded scripting language (initially bound in CEnvi software), and later renamed it ScriptEase (client-side execution language).
- Netscape (Netscape) accepted the idea of Nombas, ( Brendan Eich) developed a set of livescript scripting language in its Netscape Navigator 2.0 product. Sun and Netscape jointly completed, later renamed JavaScript.
- Microsoft then imitated a JavaScript clone called Jscript in its IE 3.0 product.
- In order to unify the three, ECMA ( European Computer Manufacturing Association) defines the ECMA-262 specification. The International Organization for Standardization and the International Electrotechnical Commission (ISO/IEC) also adopt ECMAScript as a standard (ISO/IEC-16262). Since then, Web browsers have made efforts (albeit with varying degrees of success and failure) to use ECMAScript as the basis for JavaScript implementations.
- ECMA-262 is the official name of the JavaScript standard.
Note: ES6 refers to ECMAScript 6.
While ECMAScript is an important standard, it's not the only part of JavaScript, and certainly not the only part that's been standardized. In fact, a complete JavaScript implementation consists of 3 distinct parts:
- Core (ECMAScript)
- Document Object Model (DOM) Document object model (integrating js, css, html)
- Browser object model (BOM) Browser object model (integrating js and browser)
Simply put, ECMAScript describes the JavaScript language itself.
JavaScript is a scripting language
JavaScript is a lightweight programming language.
JavaScript is programming code that can be inserted into an HTML page.
Once JavaScript is inserted into an HTML page, it can be executed by all modern browsers.
JavaScript is easy to learn.
How to import JavaScript
Write code in Script tag
<script> // Write your JS code here </script>
Introduce additional JS files
<script src="myscript.js"></script>
JavaScript Language Specification
Comments (Comments are the mother of code)
// this is a single line comment /* This is multi-line comment */
terminator
Statements in JavaScript are terminated with a semicolon (;).
JavaScript language basics
variable declaration
- JavaScript variable names can be composed of _, numbers, letters, and $, and cannot start with numbers.
- Declare variables using the format var variable name;
var name = "Alex"; var age = 18;
Notice:
Variable names are case-sensitive.
CamelCase is recommended.
Reserved words cannot be used as variable names.
abstract boolean byte char class const debugger double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile
JavaScript data types
JavaScript has dynamic typing
A strongly typed language (statically typed language) refers to a language that requires variable/object type declaration, and generally requires compilation and execution. For example, C/C++/Java/C#
weakly typed languages (dynamically typed languages) refer to languages that do not require variable/object type declarations, and generally do not require compilation (but there are also compiled ones).
For example PHP/ASP/Ruby/Python/Perl/ABAP/SQL/JavaScript/Unix Shell etc.