JavaScript is a widely used scripting language that adds functionality and interactivity to a webpage. HTML is the basic skeleton of a webpage and it allows the users to create and generate various sections, add paragraphs and links. CSS helps in styling the webpage. All the user interactions are managed by Javascript.
Where does the Javascript block of code goes in an HTML document? There are 2 ways to do this.
Inline JS means the code is written inside the HTML document while external JS file means we have an external document connected to our HTML. In Inline JS we have the code inside the opening and closing script tag where external Javascript has the script attribute where we give a source reference to an external Javascript file.
<script>
console.log("This is an inline Javascript code block");
</script>
<script src="script.js"></script>
We typically put the Javascript file at the end of the html document and inside the body. Traditionally script is something that we put at the bottom of the page.
First Reference of a Javascript function
console.log ();
Here we are are naming our console to interact with the Javascript console. Log function is used to send a message.
semicolons are optional in Javascript, but it is always a good practice to have them because they indicate the end of statement.
Top comments (0)