What is JavaScript?

JavaScript is a high-level, weakly typed, multi-paradigm programming language and is most commonly used in web development.

What is JavaScript?

JavaScript is a  high-level, weakly typed,  multi-paradigm programming language and is most commonly used in web development.

Initially, JavaScript was used only on the client side. Although JavaScript and Java are similar in many ways, they are entirely different.

Limitations of JavaScript

  • Doesn’t have any multi-threading capabilities.
  • Limitation on file handling.
  • There have been differences in “error handling” by varying browsers.

JavaScript in HTML

In an HTML document, you can use any number of HTML documents. You can either specify the script in the head or body of the document. Javascript is specified in an HTML document within <script> tag.

<html>
<head>
<script>
function clicked()
{
    alert("Hello World!");
}
</script>
</head>
<body>
    <button onclick="clicked()">Click Me</button>
</body>
</html>

Including Javascript from an external source

You can either write the entire JavaScript code in the same HTML document or you can save it as a separate file. If you are writing JavaScript in a different file, the file should have .js extension. One advantage of saving JavaScript as a separate file is that the code can be reused.

<script src="myjavascriptfile.js"></script>


Share Tweet Send
0 Comments
Loading...