Introduction to JavaScript By: Franciscus Agnew
Introduction
JavaScript is one of the most popular programming languages on the web. It is used in millions of web pages to add functionality, validate forms, detect browsers, and much more. This will be a multi-part series where I share my knowledge with you about the many aspects of the JavaScript programming language. So, let's get started by covering the basics.
What is JavaScript?
JavaScript is...
- a scripting language
- (lightweight programming language)
- an interpreted language (not compiled)
- an Object Oriented Programming (OOP) language
- usually embedded directly into HTML pages
- available in all major browsers, such as Firefox, Internet Explorer, Chrome, Opera, and Safari
- not Java
JavaScript can be used to make web pages dynamic, react to events, validate data, create cookies, and detect browser information.
Tips & Guidelines
The following are important things to know when coding with JavaScript.
Case Sensitivity
JavaScript is case sensitive - therefore ensure the capitalization is correct for variable and function names. A variable named "myIndex" is not the same as "myindex".
Semicolons
Although the JavaScript interpreter automatically adds semicolons to the end of most lines, it is a best practice to add them when writing JavaScript to avoid strange side effects when the interpreter does it automatically.
Whitespace and New Lines
Most whitespace such as spaces, tabs, and empty lines is ignored by the JavaScript interpreter. In general, it is best to use whitespace when coding JavaScript to aid readability.
Breaking a Line of Code
Long lines of code can be broken up with a backslash character as long it is within a text string.
Reserved Words
JavaScript reserves certain words for specific uses. The following lists the JavaScript reserved words:
The following lists the reserved words for future keywords by the ECMAScript specification:
In addition to the ECMAScript reserved words, certain JavaScript-specific words implemented in most browsers are considered reserved by implementation. The following lists these reserved keywords:
JavaScript Statistics
- JavaScript was originally created by Brendan Eich of Netscape in 1995
- JavaScript's formal name is ECMAScript
- JavaScript is governed by the European Computer Manufacturers Association (ECMA)
- JavaScripts's File Extension is '.js'
- JavaScript's MIME type is 'text/javascript'