Top Ad unit 728 × 90

Libreoffice

Libreoffice Writer

Introduction of JavaScript

 



JavaScript


JavaScript


JavaScript is a popular, high-level, dynamic programming language that is used

 primarily to create interactive web applications and dynamic user interfaces. It is a

 client-side scripting language that is executed in the browser, enabling developers to add

 interactivity and dynamic behavior to web pages.

 

History of JavaScript

 

It was created in 1995 by Brendan Eich while he was an engineer at Netscape. It was

 originally going to be named LiveScript but was renamed. Unlike most programming

 languages, JavaScript language has no concept of input or output. It is designed to run

 as a scripting language in a host environment, and it is up to the host environment to

 provide mechanisms for communicating with the outside world.




Advantages of JavaScript


Less server interaction –


You can validate user input before sending the page off to the server. This saves server

 traffic, which means fewer loads on your server.


Immediate feedback to the visitors –

 

They don't have to wait for a page reload to see if they have forgotten to enter

 something.


Increased interactivity –


 You can create interfaces that react when the user hovers over them with a mouse or

 activates them via the keyboard.


Richer interfaces –


You can use JavaScript to include such items as drag-and-drop components and sliders to

 give a Rich Interface to your site visitors.


Applications of JavaScript


1) Web Development


2) Web Applications


3) Server Applications


4) Games


5) Smart watches


6) Art


7) Machine Learning


8) Mobile Applications

 

How to Link JavaScript File in HTML?

 

JavaScript can be added to HTML file in two ways:


Internal JS: 


We can add JavaScript directly to our HTML file by writing the code inside the <script>

 tag. The <script> tag can either be placed inside the <head> or the <body> tag

 according to the requirement.


External JS:


 We can write JavaScript code in another file having an extension.js and then link this

 file inside the <head> tag of the HTML file in which we want to add this code.

 

Client-Side JavaScript


Client-side JavaScript is the most common form of the language. The script should be

 included in or referenced by an HTML document for the code to be interpreted by the

 browser.


It means that a web page need not be a static HTML, but can include programs that

 interact with the user, control the browser, and dynamically create HTML content.


Server-side


It supplies objects relevant to running JavaScript on a server. For if the server-side

 extensions allow an application to communicate with a database, and provide continuity

 of information from one invocation to another of the application, or perform file

 manipulations on a server. 


Imperative language


 In this type of language we are mostly concerned about how it is to be done. It simply

 controls the flow of computation. The procedural programming approach, object,

 oriented approach comes under this as a sync await we are thinking about what is to be

 done further after the sync call.


Declarative programming


In this type of language we are concerned about how it is to be done, basically here

 logical computation requires. Her main goal is to describe the desired result without

 direct dictation on how to get it as the arrow function does.


JavaScript - Syntax


JavaScript can be implemented using JavaScript statements that are placed within

 the <script>... </script> HTML tags in a web page.


You can place the <script> tags, containing your JavaScript, anywhere within your web

 page, but it is normally recommended that you should keep it within the <head> tags.


Syntax


<script>


    // JavaScript Code


</script>


The script tag takes two important attributes −


Language 


 

This attribute specifies what scripting language you are using. Typically, its value will be


 JavaScript. Although recent versions of HTML (and XHTML, its successor) have phased


 out the use of this attribute.

 

Type 


This attribute is what is now recommended to indicate the scripting language in use and


 its value should be set to "text/javascript".


Case Sensitivity


JavaScript is a case-sensitive language. This means that the language keywords,


variables, function names, and any other identifiers must always be typed with a


consistent capitalization of letters.


So the identifiers Time and TIME will convey different meanings in JavaScript.

NOTE − Care should be taken while writing variable and function names in JavaScript.

 

Your First JavaScript Code


<html>

   <body>  

      <script language = "javascript" type = "text/javascript">

         <!--

            document.write("Hello World!")

         //-->

      </script>     

   </body>

</html>


Output−


Hello World!


Introduction of JavaScript Reviewed by ADcomputercampus on February 23, 2024 Rating: 5

No comments:

Contact Form

Name

Email *

Message *

Powered by Blogger.