Javascript – Introduction

Javascript:

–> JavaScript is the world’s most popular programming language.

–> JavaScript is the programming language of the Web.

–> JavaScript is easy to learn.

–> Dynamically typed programming language.

–> JavaScrip…


This content originally appeared on DEV Community and was authored by Guru prasanna

Javascript:

--> JavaScript is the world's most popular programming language.

--> JavaScript is the programming language of the Web.

--> JavaScript is easy to learn.

--> Dynamically typed programming language.

--> JavaScript (JS) is a cross-platform, object-oriented programming language used by developers to make web pages interactive.

Image description

Why should we Study JavaScript?

--> JavaScript is one of the 3 languages all web developers must learn:

  1. HTML to define the content of web pages (Structure)

  2. CSS to specify the layout of web pages (style)

  3. JavaScript to program the behavior of web pages (Functionality)

--> JavaScript is supported by almost all browsers.

Refer:https://www.w3schools.com/js/

How to use javascript?

a) Internal javascript
b) External javascript

Internal and External JavaScript are the two ways of adding JavaScript code to an HTML document.

a) Internal JavaScript

Internal JavaScript refers to embedding JavaScript code directly within the HTML file using <script> tag, either inside the <head> or <body> tag. This method is useful for small scripts specific to a single page.

b) External javascript

External JavaScript is when the JavaScript code written in another file having an extension .js is linked to the HMTL with the src attribute of script tag.

Syntax:
<script src="url_of_js_file"> </script>

JavaScript Functions and Events:

--> Function is a block of JavaScript code, that can be executed when it is "called" for.

--> Function is a set of instructions or block of reusable code to perform specific task with a name.

--> Function is defined using function keyword.

For example, a function can be called when an event occurs, like when the user clicks a button.

Event: An event is an action or occurrence that happens in the browser.

Example:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Javascript</title>
    <script>
        function payilagam(){
            document.getElementById("welcome").innerHTML = "Welcome to Payilagam";
        }
    </script>
</head>
<body>
    <h1 id="welcome"></h1>
    <button onclick="payilagam()">Click Me</button>
</body>
</html>

Output:

Image description


This content originally appeared on DEV Community and was authored by Guru prasanna


Print Share Comment Cite Upload Translate Updates
APA

Guru prasanna | Sciencx (2025-01-21T05:35:11+00:00) Javascript – Introduction. Retrieved from https://www.scien.cx/2025/01/21/javascript-introduction-4/

MLA
" » Javascript – Introduction." Guru prasanna | Sciencx - Tuesday January 21, 2025, https://www.scien.cx/2025/01/21/javascript-introduction-4/
HARVARD
Guru prasanna | Sciencx Tuesday January 21, 2025 » Javascript – Introduction., viewed ,<https://www.scien.cx/2025/01/21/javascript-introduction-4/>
VANCOUVER
Guru prasanna | Sciencx - » Javascript – Introduction. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/01/21/javascript-introduction-4/
CHICAGO
" » Javascript – Introduction." Guru prasanna | Sciencx - Accessed . https://www.scien.cx/2025/01/21/javascript-introduction-4/
IEEE
" » Javascript – Introduction." Guru prasanna | Sciencx [Online]. Available: https://www.scien.cx/2025/01/21/javascript-introduction-4/. [Accessed: ]
rf:citation
» Javascript – Introduction | Guru prasanna | Sciencx | https://www.scien.cx/2025/01/21/javascript-introduction-4/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.