Getting Started with JavaScript
To get started with JavaScript, you will need a text editor and a web browser.
You can use any text editor you like, but we recommend using a dedicated code editor such as Visual Studio Code, Atom, or Sublime Text. These editors have features that are specifically designed for coding, such as syntax highlighting, code completion, and debugging tools.
(W-1-1) |
Links to download:
Once you have a code editor set up, you can start writing JavaScript code.
You can include JavaScript code directly in an HTML file using a script tag or you can create a separate JavaScript file and link to it in your HTML file using a script tag.
Here is an example of a simple JavaScript program(W-1-2)
(W-1-2) |
The program in the above example will display a message box with the text "Hello, world!" when the page is loaded in the browser.
Javascript in <body> or <head> section
You can place any number of scripts in an HTML document and Scripts can be placed in the <body> or in the <head> section of an HTML page, or in both.(W-1-3)
(W-1-3) |
External Javascript file
In this example, we've created a new file called "my-script.js" and included it in our HTML document using the <script> tag.
Any code written in this "my-script.js" will be executed by the browser when the web page loads. (W-1-4)
إرسال تعليق