IT Course JavaScript Basics 035_Hello JavaScript
JavaScript is a high-level, dynamic, object-oriented programming language and one of the most popular programming languages in the world. It is primarily used for web development but is also widely applied in server-side development, game development, mobile development, and other fields.
JavaScript was originally designed and implemented by Brendan Eich at Netscape in 1995. It was initially called “LiveScript” and later renamed to JavaScript.
In 1997, ECMA International (European Computer Manufacturers Association) released the ECMAScript standard, which defines the syntax and semantics of JavaScript. The release of the ECMAScript standard made JavaScript a standardized language and it gained support from all major browsers.
JavaScript is different from Java. Although their names are similar, they are two different programming languages. JavaScript is mainly used for front-end development and executed through browsers, while Java is typically used for back-end development and is an independent programming language.
JavaScript has the following main features:
- Easy to learn and use: JavaScript syntax is relatively simple, and even people without programming experience can get started quickly.
- Dynamic: JavaScript is a dynamic language, and variable types can be dynamically changed at runtime.
- Object-oriented: JavaScript supports object-oriented programming (OOP) concepts, including encapsulation, inheritance, and polymorphism.
- Event-driven: JavaScript typically implements user interaction by handling events, such as button clicks, text input, etc.
- Scripting language: JavaScript is a scripting language that is usually interpreted rather than compiled. This allows it to execute directly in the browser.
Over time, JavaScript has evolved into a general-purpose programming language, used not only for front-end development but also for server-side development (using Node.js), as well as game development, mobile applications, and other program development.
JavaScript applications in other fields include:
- Server-side development: Using platforms like Node.js, JavaScript can be used to develop server-side applications.
- Game development: JavaScript can be used to develop web games and mobile games.
- Mobile development: JavaScript can be used to develop hybrid mobile applications.
How to Use JavaScript
Internal JavaScript
Within an HTML document, JavaScript code is embedded in the <head> or <body> tags using the <script> tag. Such scripts execute when the page loads. It is recommended to include them before the closing </head> or </body> tags.
Example:
<!-- head area --> <script> alert('Hello Internal JavaScript!'); </script> <!-- head area -->Effect:

External JavaScript
Save JavaScript code in a separate file and reference the external file using the src attribute of the <script> tag. This helps with code reuse and maintenance.
Example:
<script src="script.js"></script> alert('Hello External JavaScript!');Effect: 

Inline JavaScript
Inline reference is writing JavaScript code directly in the event attributes of HTML tags, typically used for handling simple, specific interactions or events. Such as: event handling, DOM manipulation.
Example:
<a href="javascript:alert('Hello JavaScript!')">JavaScript Test</a>Effect:
