Introduction

M2-R5.1 · Chapter 6: JavaScript and Angular JS · 3 min read

Introduction to JavaScript 

  • JavaScript is an object-oriented program scripting language which is used to create webpages and applications .
  • Javascript is called JS in programming language. It uses ‘.js’ filename extension.
  • JavaScript is a client-side scripting language.
  • The source code of which is processed by the server instated of client’s web.
  • JavaScript is referred as unique because of the its full integration with HTML/CSS.
  • JavaScript was invented in 1995 by a Netscape communication corporation programmer named Brendan Eich.
  • The language is becoming an international standard approved by the European standard body ECMA(European Computer Manufactures Association) in 1997 and later by the ISO in 1998 .
  • JavaScript’s former name was Mocha Live Script,but later its name was changed to JavaScript by Netscape.
  • Nowadays almost all big websites even Google,Facebook use JavaScript.

Features of Java script –

  • It is case-sensitive language.
  • All popular web browse support JavaScript as they provide in-built execution Environments.
  • JavaScript is executed line by line in the browser making it an interpreted language.
  • It Can be used for both front-end and back-end development (e.g., using Node.js).

Application of JavaScript –

  • Web Development : Create dynamic and interactive web pages by manipulating HTML and CSS.
  • Form Validation: Validate user input before sending it to the server.
  • Game Development: Develop games that run directly in the web browser
  • Mobile App Development: React Native: Develop cross-platform mobile apps using JavaScript.

Note- Java and JavaScript are two completely different languages in both concept and design!

How to add JavaScript in Html File: -

JavaScript code can be placed inside <script>.......</script> tags.

<script> tag can be placed anywhere between <head> tag or <body> tag or both of Html page.

We can place JavaScript code by following methods-

  • Inside body tag
  • Inside head tag
  • External JavaScript file


1. Inside body tag –

<html>
<head>
<title>JavaScript</title>
</head>
<body>
<script>
Document.write(“Hello world”);
</script>
</body></html>

2. Inside head tag-


<html>
<head>
<title>JavaScript</title>
<script>
Document.write(“Hello World ”);
</script>
</head>
<body>
</body></html>

3. External JavaScript file –


<html>
<head>
<title>JavaScript</title>
<script src=”file.js” type=”text/javascript”>
document.write(“Hello everyone”) ;
</script>
</head>
<body>
</body></html>

NOTE:-
src:-It’s an attribute of script tag. It defines source/location script file.
file.js:-This is our script file .where “file” is file name and “.js” is extension.
type:-It’s an attribute of script tag which tells the browser it is a javascript. This is optional now a days.