What is Javascript?

JavaScript gives you the freedom to add interactivity and responsiveness to your web pages.

No prior knowledge of JavaScript is assumed, but because JavaScript sits within and manipulates web pages.

JavaScript is a lightweight, easy to learn, scripting language. It’s used on almost every website to respond to user actions, validate web forms, detect browser support, and much more.

JavaScript is a web programming language, that is, a language that enables you, the designer of your website, to control how a web page behaves. This makes JavaScript crucially different from HTML, the language that gives structure to your web documents, and CSS, the language that controls the appearance of web pages.

Are JavaScript and Java the same thing?

No, they are not.

Java (developed by Sun Microsystems) is a powerful and much more complex programming language in the same category as C and C++.

JavaScript was created by Brendan Eich at Netscape and was first introduced in December 1995 under the name of LiveScript. However, it was rather quickly renamed JavaScript, although JavaScript’s official name is ECMAScript, which is developed and maintained by theECMA (European Computer Manufacturer’s Association) International organization.

JavaScript is a scripting language, that is, a lightweight programming language that is interpreted by the browser engine when the web page is loaded.

The HTML DOM

The HTML Document Object Model (DOM) is the browser’s view of an HTML page as an object hierarchy, starting with the browser window itself and moving deeper into the page, including all of the elements on the page and their attributes. Below is a simplified version of the HTML DOM.

The HTML DOM

As shown, the top-level object is window. The document object is a child of window and all the objects (i.e, elements or nodes) that appear on the page (e.g, forms, links, images, tables, etc.) are descendants of the document object. These objects can have children of their own. For example, form objects generally have several child objects, including textboxes, radio buttons, and select menus.

Dot Notation

In JavaScript, elements (and other objects) can be referenced using dot notation, starting with the highest-level object (i.e, window). Objects can be referred to by name or id or by their position on the page. For example, if there is a form on the page named “loginform”, using dot notation you could refer to the form as follows:

window.document.loginform

Assuming that loginform is the first form on the page, you could also refer to this way:

window.document.forms[0]

document can have multiple form elements as children. The number in the square brackets ([]) indicates the specific form in question. In programming speak, everydocument object contains a collection of forms. The length of the collection could be zero (meaning there are no forms on the page) or greater. In JavaScript, collections (and arrays) are zero-based, meaning that the first form on the page is referenced with the number zero (0) as shown in the syntax example above.

Square Bracket Notation

Objects can also be referenced using square bracket notation as shown below:

1
2
3
4
5
window['document']['loginform']
// and
window['document']['forms'][0]

javascript: Pseudo-Protocol

Try this:

  1. Open your browser.
  2. In the location bar, type in javascript:alert("Hello world!");
  3. Press Enter.
  4. You should get an alert reading “Hello world!”. The javascript: prefix is called a pseudo-protocol, because it mimics the protocol syntax (e.g, like http:ftp:, andmailto:).

Tutorials:

http://www.learn-javascript-tutorial.com/javascript-basics.cfm

http://www.w3schools.com/js/DEFAULT.asp

 

Advertisements

What is javascript?

JavaScript (JS) is a dynamic computer programming language. It is most 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. It is also being used in server-side programming, game development and the creation of desktop and mobile applications.JavaScript is a prototype-based scripting language with dynamic typing and has first-class functions. Its syntax was influenced by C.
Birth at Netscape

JavaScript was originally developed by Brendan Eich, while working for Netscape Communications Corporation.
Although it was developed under the name Mocha, the language was officially called LiveScript when it first shipped in beta releases of Netscape Navigator 2.0 in September 1995, but it was renamed JavaScript when it was deployed in the Netscape browser version 2.0B3
Server-side JavaScript
Netscape introduced an implementation of the language for server-side scripting (SSJS) with Netscape Enterprise Server, first released in December, 1994 (soon after releasing JavaScript for browsers). Since the mid-2000s, there has been a proliferation of server-side JavaScript implementations. Node.js is one recent notable example of server-side JavaScript being used in real-world applications.

Where should i learn javascript?

You can start learning js from the following sites

w3schools

learnjs