Introduction to JavaScript

JavaScript is a powerful, high-level programming language primarily used to make web pages interactive. It’s one of the core technologies of the World Wide Web, alongside HTML and CSS.

What JavaScript Does?
  • Create animations and visual effects.
  • Handle user interactions (e.g., button clicks, form submissions).
  • Dynamically update content on a page.
  • Build web applications:
  • Create complex web applications with features like real-time updates and user interfaces.
  • Server-side development:
  • With Node.js, JavaScript can be used to build server-side applications.
  • Example:
<!DOCTYPE html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<button onclick="showAlert()">Click me</button>
<script>
function showAlert() {
alert("Hello from JavaScript!");
}
</script>
</body>
</html>
In this example:
  • HTML: We have a button with the onclick attribute. This attribute calls the showAlert() function when the button is clicked.
  • JavaScript: The showAlert() function is defined within the <script> tag.
  • ShowAlert() function: displays an alert box with the message “Hello from JavaScript!”.
Scroll to Top