Javascript (Js|ECMAScript)

> (World Wide) Web - (W3|WWW) > Javascript (Js|ECMAScript)

1 - About

Javascript was born to run in the browser but may know with the advent of node run on the server side. See Javascript - (Interpreter|Engine)

JavaScript is also known as:

This is the world's most popular programming languages due to its role as the scripting language of the web and is universally used to script web content in browsers.

It was invented by Brendan Eich, co-founder of the Mozilla project, the Mozilla Foundation, and the Mozilla Corporation.

The term JavaScript refers often to the ECMA262 (official term ECMAScript), since this term is more widely known.

It is a dynamically typed scripting language but typed version exist also (see Javascript - Static Typing).

JavaScript is most commonly used for client-side scripting in a browser, being used to manipulate Document Object Model (DOM) objects for example. The DOM is not, however, typically provided by the JavaScript engine but instead by the browser.

If the javascript script has no dependencies to the DOM, it can be run in a non-browser JavaScript environment.

I created JavaScript in ten days in May 1995, under duress and conflicting management imperatives

  • “make it look like Java,”
  • “make it easy for beginners,”,
  • “make it control almost everything in the Netscape browser.”
The strength of JavaScript is that you can do anything. The weakness is that you will.
Reg Braithwaite
Advertising

3 - (Grammar|Syntax)

Javascript syntax is based on the Java and C languages.

One of the key differences is that JavaScript doesn't instantiate object through static classes definition; instead, the instantiation is accomplished by object prototypes.

JavaScript grammar:

4 - Javascript vs Java

JavaScript follows most Java expression syntax, naming conventions and basic control-flow constructs which was the reason why it was renamed from LiveScript to JavaScript.

Feature Java Javascript Note
Type Static typing and strong type checking free-form language
Object Model class-based prototype-based The prototype-based model provides dynamic inheritance; that is, what is inherited can vary for individual objects.
Instances of Class Object A typical object inherits properties (including methods) from Object.prototype, although these properties may be shadowed (a.k.a. overridden).
Functions Non declarative requirements Functions can be properties of objects, executing as loosely typed methods.

Java is a class-based programming language designed for fast execution and type safety. Java's class-based model means that programs consist exclusively of classes and their methods. Java's class inheritance and strong typing generally require tightly coupled object hierarchies. These requirements make Java programming more complex than JavaScript programming.

Advertising

5 - History

6 - Support

6.1 - Cannot be resolved to a type

  • Error : …cannot be resolved to a type
  • Answer : You need to have the class that provides the type in your classpath.

Make sure your code is

<% new MyClass*()*.myMethod() %> instead of <% new MyClass.myMethod() %>

It's a common mistake.

7 - Documentation / Reference

web/javascript/javascript.txt · Last modified: 2019/06/09 11:39 by gerardnico