Page 179 - Web_Application_v2.0_C12_Fb
P. 179

Some of the advantages of JavaScript are given below:
                   Easy to Learn and Use: JavaScript has a simple syntax, making it beginner-friendly and easy to understand.

                   Versatile Usage: It can be used on both the client-side (front-end) and server-side (back-end), making it
                    suitable for full-stack development.
                   Enhances Interactivity: JavaScript brings websites to life by enabling dynamic and interactive features.

                   Cross-Platform Compatibility: It runs seamlessly on various devices and platforms and is supported by
                    all major web browsers.
                   Rich Ecosystem: A wide range of libraries, frameworks, and APIs are available, simplifying development
                    and adding powerful functionalities.
                   Creates Engaging Interfaces:  JavaScript  enables  the  creation  of  visually appealing  elements such  as
                    sliders, drag-and-drop components, and other interactive features that enhance the professional look and
                    feel of websites.


                   2.1 BASIC STRUCTURE OF A JAVASCRIPT PROGRAM

                 JavaScript can run on its own outside of an HTML file. While it is commonly used within web pages and
                 embedded in HTML, JavaScript can also be executed independently using environments like:
                   Node.js: A runtime environment that allows JavaScript to run outside a web browser.

                   Deno: A modern runtime for JavaScript and TypeScript.
                   JavaScript engines: JavaScript can execute code independently using.
                 Also JavaScript program is written within an HTML document. The basic structure is as follows:

                    <!DOCTYPE HTML>

                    <HTML>
                    <HEAD>
                    <TITLE>...</TITLE>

                    </HEAD>
                    <BODY>

                    <SCRIPT TYPE="text/javascript">
                    ...
                    Write JavaScript code here

                    ...
                    </SCRIPT>
                    </BODY>

                    </HTML>
                 The TYPE attribute of the <SCRIPT> tag is used to specify the language of the script. In this case, we have
                 used the "text/ javascript" value. Some other values of the TYPE attribute are "text/css" and "text/vbscript".
                 However, it is optional to use the TYPE attribute in the case of JavaScript as "text/javascript" is the default
                 value of it.
                 In HTML, we can use JavaScript in two ways internally and externally.



                                                                                                  JavaScript Part 2  177
   174   175   176   177   178   179   180   181   182   183   184