Skip to content

JavaScript

Marie-Louise edited this page Jan 27, 2019 · 42 revisions

History

It was developed in 10 days by Brendan Eich for netscape navigator, one of the first internet browsers

JavaScript was created in 1995 by Brendan Eich while he was an engineer at Netscape. JavaScript was first released with Netscape 2 early in 1996. It was originally going to be called LiveScript, but it was renamed in an ill-fated marketing decision that attempted to capitalize on the popularity of Sun Microsystem's Java language — despite the two having very little in common. This has been a source of confusion ever since.

Overview

JavaScript is a multi-paradigm, dynamic language with types and operators, standard built-in objects, and methods. Its syntax is based on the Java and C languages — many structures from those languages apply to JavaScript as well. JavaScript supports object-oriented programming with object prototypes, instead of classes. JavaScript also supports functional programming — functions are objects, giving functions the capacity to hold executable code and be passed around like any other object.

Basic operators

you can declare all of the variables at the top and then don't have to reuse the var keyword var year, yearJohn, yearMark;

each variable needs to have a value assigned to it arithmetic operators

now = 2018;
ageJohn = 28;
ageMark = 33;

console.log(ageJohn);
console.log(now + 2);
console.log(now * 2);
console.log(now / 10);

Relational Operators

Less than <

evaluates to true if its first operand is greater than its second operand; otherwise it evaluates to false

Greater than >

Less than or equal <=

Greater than or equal >=

Type conversion / coercion

Javascript will convert the data type as it is needed so for example:

var firstName = 'John'; //string literal
var age = 28; //number

console.log(firstName + ' ' + age);

In the console, the var age is converted and the both will display as strings.

or

var job, isMarried;

job = 'teacher';
isMarried = false;

console.log(firstName + ' is a ' + age + 'year old' + job + '.Is he married?' + isMarried);

will also display as a string

Package.JSON

Objects

Functions

ECMAScript

Variable scope

Data Types

Clone this wiki locally