JavaScript is the world’s most popular programming language. It is a programming language, Which is easy to learn.
Why should you Study JavaScript?
JavaScript is one of the most programming languages which is used by every developer.
Before starting to learn you must know these languages:
- HTML to define the content of web pages
- CSS to specify the layout of web pages
- JavaScript to program the behavior of web pages.
Where To Use JavaScript?
In HTML, JavaScript code is inserted between <script> and </script> tags.
Scripts can be inserted in the <body>, in the <head> section of an HTML page, or in both.
JavaScript is used in <head> section
In this example, the JavaScript function is placed in the <head> section of an HTML page. The function is called when a button is clicked.
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Paragraph changed.";
}
</script>
</head>
<body>
<h2>Demo JavaScript in Head</h2>
<p id="demo">A Paragraph.</p>
<button type="button" onclick="myFunction()">Try it</button>
</body>
</html>
JavaScript is used in <body> section
In this example, a JavaScript function is placed in the <body> section of an HTML page. The function is called when a button is clicked.
Also read, Front-end Developer Skills
<!DOCTYPE html>
<html>
<body>
<h2>Demo JavaScript in Body</h2>
<p id="demo">A Paragraph</p>
<button type="button" onclick="myFunction()">Try it</button>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Paragraph changed.";
}
</script>
</body>
</html>
JavaScript is a versatile programming language that is primarily used for web development. These are just a few examples of where JavaScript can be used. Examples: Web Development, Front–end Development, Back–end Development, Mobile App Development, Game Development, and Desktop Applications.
One thought on “Why should you Study JavaScript?”