Search Anything Related to Library and Information Science

JavaScript (JS)

1. Introduction: JavaScript (JS) is a dynamic computer programming language commonly used as part of Web browsers, whose implementations allow client-side scripts to interact with the user, control the browser, communicate asynchronously, and alter the document content that is displayed. JavaScript was originally developed by Brendan Eich, while working for Netscape Communications Corporation and it is a trademark of Oracle Corporation and is officially managed by Mozilla Foundation. As of 2016, the latest version of the language is JavaScript 1.8.5.

2. Usefulness of JavaScript: The most common use of JavaScript is to add client-side behavior to HTML pages, a.k.a. Dynamic HTML (DHTML). Because JavaScript code can run locally in a user’s browser rather than on a remote server, the browser can respond to user actions quickly, making an application more responsive. Furthermore, JavaScript code can detect user actions that HTML alone cannot, such as individual keystrokes. Some common uses of JavaScript are as follows
a) Loading New Page Content: Loading new page content or submitting data to the server via Asynchronous JavaScript and XML (AJAX) without reloading the page. For example, a social network might allow the user to post status updates without leaving the page.
b) Animation of Page Elements: Animation of page elements, fading them in and out, resizing them, moving them, etc. can be achieved through JavaScript.
c) Interactive Content: Interactive content, for example games, and playing audio and video can be done through JavaScript.
d) Validating input in Web Form: JavaScript can be used in validating input values of a Web form to make sure that they are acceptable before being submitted to the server.
e) Web Analytics: Transmitting information about the user’s reading habits and browsing activities to various websites can be done by using JavaScript. Web pages frequently do this for Web analytics, ad tracking, personalization or other purposes.

3. Problems in Using JavaScript: JavaScript provide the potential for malicious authors to deliver scripts to run on a client computer via the Web. In general, the following disadvantages can be found in implementing the JavaScript-
a) Security Issue: JavaScript executes on the users’ computer, in some cases it can be exploited for malicious purposes. This is one reason some people choose to disable JavaScript.
b) Behave Differently in the End User End: Sometimes JavaScript is interpreted differently by different browsers.

4. Basic Syntax of JavaScript: JavaScript is case sensitive. In JavaScript, when we surround a word with quotes it’s called a string, and when we’re done with a line of code we finish it with a semicolon. It is common to start the name of a constructor with a capitalised letter, and the name of a function or variable with a lower-case letter. Spaces, tabs and newlines used outside of string constants are called whitespace. Whitespace in JavaScript source can directly impact semantics. Because of a technique called Automatic Semicolon Insertion (ASI), some statements that are well formed when a newline is parsed will be considered complete as if a semicolon were inserted just prior to the newline. Some authorities advise supplying statement-terminating semicolons explicitly because it may lessen unintended effects of the automatic semicolon insertion.
            For writing a comment within a JavaScript, the following syntax can be used.
// a short, one-line comment
/* a long, multi-line comment */
Example: The following JavaScript will display the date and time from your local computer
<button type="button"
onclick="document.getElementById('demo').innerHTML = Date()">
Click here to display Date and Time</button>

<p id="demo"></p>
<noscript>Your browser either does not support JavaScript, or has it turned off.</noscript>

Example: The following JavaScript will change the content of the webpage
<button type="button"
onclick="document.getElementById('demo').innerHTML = 'Hello JavaScript'">
Click Me!</button>

<p id="demo">JavaScript can change HTML content.</p>
<noscript>Your browser either does not support JavaScript, or has it turned off.</noscript>

5. How to Use JavaScript: JavaScript can be inserted at the following positions
b) JavaScript in <body>: JavaScript function can also be placed in the <body> section of an HTML page as per the need.
b) JavaScript in <head>:  JavaScript function can also be placed in the <head> section of an HTML page with the script tag intake.
c) JavaScript in an External File: JavaScript can be placed in external files when the same code is used in many different web pages. JavaScript files have the file extension .js. While using external file, the JavaScript files (.js) should not include the <script> tag. They should only contain HTML commenting and JavaScript code - nothing more. Like HTML and CSS, the JS code need to be entered in text editor such as notepad, and save it as an file with the extension .js. To use an external script, putting the name of the script file in the src (source) attribute of the <script> tag will do the rest.

Example: <script src="myScript.js"></script>

6. Conclusion: The page design by using basic HTML tag is widely compatible, easy for subsequent maintenance, it also provide fast access, so if one can fulfill his/her need through it then it is best. But if one cannot do it through basic HTML tag, then he/she can think of going to Java applets and other advanced stuff.
A common misconception about JavaScript is that JavaScript is similar or closely related to Java. But in reality, the differences between the two languages are more prominent than their similarities. It is true that both have a C-like syntax - the C language being their most immediate common ancestor language. JavaScript was designed with Java’s syntax and standard library in mind. JavaScript’s standard library follows Java’s naming conventions, and JavaScript’s Math and Date objects are based on classes from Java 1.0, but the similarities end here. Java has static typing, while JavaScript’s typing is dynamic. Java is loaded from compiled bytecode, while JavaScript is loaded as human-readable source code. Java’s objects are class-based, while JavaScript's are prototype-based.

How to Cite this Article?
APA Citation, 7th Ed.:  Barman, B. (2020). A comprehensive book on Library and Information Science. New Publications.
Chicago 16th Ed.:  Barman, Badan. A Comprehensive Book on Library and Information Science. Guwahati: New Publications, 2020.
MLA Citation 8th Ed:  Barman, Badan. A Comprehensive Book on Library and Information Science. New Publications, 2020.

Badan BarmanDr. Badan Barman at present working as an Assistant Professor in the Department of Library and Information Science, Gauhati University, Guwahati-781014, Assam, India. He is the creator of the LIS Links ( - India’s most popular social networking website for Library and Information Science professionals. He also created the Open Access Journals Search Engine (OAJSE) (, UGC NET Guide (, Assam Archive ( and LIS Study ( website.

No comments:

Post a Comment

Website Pageviews