JavaScript is an object-oriented scripting language designed to be embedded in HTML pages for added interactivity and to offer intelligence to web pages. JavaScript provides a set of objects (Array, Date, and Math), and language elements (Operators, Conditional Controls, and Statements). Javascript is primarily used on the client side to control the browser elements and HTML Document Object Model (DOM) to offer interactivity to users.
Many novice webmasters confuse JavaScript with Java and use the term incorrectly. Javascript is NOT the Java Programming Language. Javascript was originally developed by Netscape Communications, while Java was developed by Sun Microsystems. Javascript is a weakly typed "script" language, whereas Java is a strongly typed programming language that compiles a source code to produce a binary byte code. Think of those two as a completely different programming language.
Facets of Javascript
Javascript is a client-side scripting language primarily run on web browsers. Here are important facts, and best practices about using Javascript.
- Javascript is a case-sensitive language.
- Javascript "type" attribute is no longer a required attribute in HTML 5.
- Keep them separate from the web pages, and store them in an external file.
- Placement of javascript matters, and the best practice is to place them at the very bottom of the web page before closing <body>tag unless you need to run them early.
Why use JavaScript?
Before Javascript, adding interactivity to web pages was very difficult. Collecting, processing, and validating user data requires server-side programming, which requires submission of the form each and every time. With JavaScript, user data collection and validation can be done on the client side without the form submission to the web server reducing server resource overheads. JavaScript can also add interactivity to the webpage by manipulating HTML DOM elements.
What can JavaScripts do?
JavaScript is a client-side scripting (or "interpreted") language that runs on the visitor's computer.
- Web Designers can use JavaScript "snippets" to add interactivity to HTML pages. Web Designers are not generally programmers, but a snippet of JavaScript code can be cut and pasted onto HTML pages to offer programmability to web pages.
- With JavaScript, web designers can control and manipulate HTML DOM elements. An ability to control DOM gives web designers full control of HTML objects (elements), and create and modify objects dynamically.
- Web Designers can use JavaScript to make the web react to user-initiated events. Upon user-initiated events such as a click on an HTML element or on submission of a form, a JavaScript code can be executed to perform dynamic action.
- JavaScript can be used to validate a form data before submitting it to a web server.
- JavaScript can be used to detect web browser, and client-side characteristics.
- JavaScript can be used to create cookies on the visitor's computer.
References:
- JavaScript Overview by Mozilla.org.
- Core JavaScript 1.5 Guide: JavaScript Overview by Mozilla Developer Center.
- JavaScript by Wikipedia.
Share this post
Leave a comment
All comments are moderated. Spammy and bot submitted comments are deleted. Please submit the comments that are helpful to others, and we'll approve your comments. A comment that includes outbound link will only be approved if the content is relevant to the topic, and has some value to our readers.
Comments (0)
No comment