JavaScript
It is a client and server side object based scripting language that is used to make interactive web pages. JavaScript is commonly used scripting language because it is written on the client side executes on the client browser, thereby reducing the load on the server.
It is lightweight programming language.
Javascript is interpreted language, which implies that scripts written in JavaScript are interpreted line by line, which is built in component of web browser.
Javascript is platform independent, means that you need to write the script once and can run it on any platform or browser without affecting the output of the script.
Features of JavaScript
In the example first when javascript is present at top. It is loaded first before the elements of the webpage. While in Example second first element are loaded than javascript.
It's best practice to include css at the top and javascript at the bottom. it saves your loading time.
It is a client and server side object based scripting language that is used to make interactive web pages. JavaScript is commonly used scripting language because it is written on the client side executes on the client browser, thereby reducing the load on the server.
It is lightweight programming language.
Javascript is interpreted language, which implies that scripts written in JavaScript are interpreted line by line, which is built in component of web browser.
Javascript is platform independent, means that you need to write the script once and can run it on any platform or browser without affecting the output of the script.
Features of JavaScript
- Imperative and structured - implies that javascript supports all the syntaxes of the structured programming language C, such as if statement, loops, switch. The only difference in between c and javascript is that, semicolon is not necessary to terminate the statement in javascript while it does in C.
- Dynamic Text - implies that javascript supports dynamic typing. this means that type of variable defined according to the value stored in it.example, after variable declaration we assign it some value that's dynamic typing. Javascript provides some built in objects such as Math, String etc.
- Functional - implies that javascript does not support classes. Instead objects are created from the constructor function. each constructor function represent a unique object type.
- Prototype-based - each javascript function is associated with a prototype object. there are several built in objects that represents constructor functions, like Array(), Date(), Error(), Math(), Number() etc.
- Platform independent - means that you need to write the script once and can run it on any platform or browser without affecting the output of the script.
Example 1: When javascript is present inside head.
<!DOCTYPE html>
<html>
<head>
<title>Css begins</title>
<style>
li {
font-weight:bold;
font-style:italic;
}
</style>
<script>
alert("Javascript Begins");
</script>
</head>
<body>
<ul style="border:double; color:black; font-weight:bold; width:100px">
<li><a class="active" href="#home">Home</a></li>
<li><a href="#news">News</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#about">About</a></li>
</ul>
</body>
</html>
Example 2: Javascript at bottom
<!DOCTYPE html>
<html>
<head>
<title>Css begins</title>
<style>
li {
font-weight:bold;
font-style:italic;
}
</style>
</head>
<body>
<ul style="border:double; color:black; font-weight:bold; width:100px">
<li><a class="active" href="#home">Home</a></li>
<li><a href="#news">News</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#about">About</a></li>
</ul>
<script>
alert("Javascript Begins");
</script>
</body>
</html>
It's best practice to include css at the top and javascript at the bottom. it saves your loading time.
If it's really important like some elements depends on javscript than we need to include that javascript code at the top.
0 comments:
Post a Comment