JavaScript
what is JavaScript?
JavaScript is a scripting or programming language that allows you to implement complex features on web pages which one must learn in order to excel in web development. Every time a web page does more than just sit there and display static information for you to look at you can bet that JavaScript is probably involved. This language is used to make webpages more interactive and to provide timely content updates, interactive maps, animated 2D/3D graphics, scrolling video jukeboxes, etc. also the majority of websites today enjoy it and all the modern web browsers support it without any need for plug-ins by using a built-in JavaScript engine.
Syntax
the syntax of JavaScript is as follows :
Var a=5;
Console.log(a); / / 5
Console.log(A); / / throws a
ReferenceError: A is not defined
Example code
- <html>
- <head>
- <script type="text/javascript">
- function msg(){
- alert("Hello Javatpoint");
- }
- </script>
- </head>
- <body>
- <p>Welcome to JavaScript</p>
- <form>
- <input type="button" value="click" onclick="msg()"/>
- </form>
- </body>
- </html>
Explanation
in the example above an statement which is :
- <script type="text/javascript">
- function msg(){
- alert("Hello Javatpoint");
- }
- </script>
- This statement tells the compiler that we are using Javascript and it is shown by using "text/Javascript" and now the compiler know that we are going to use Javascript in our program so it is ready now and now we write the instructions in between two braces under function msg() and the message which we have to display should be specified that how you want to display it so we wrote alert before the message of our by which compiler prints the statement which is ( " hello javatpoint " ) and now proceeding to the body we have a paragraph in between two p tags ( <p> ). If you are new to tags then go and check out the HTML post there we have explained it in a much broader way. Now returning here we have specified the type of input the user will provide us which is by clicking on the button so we have set all the parameters of that button i.e type, on click, and value, and by clicking on this button the user will get the alert message of welcome to Java script.
No comments
If you have any doubts, please let us Know.