0% found this document useful (0 votes)
11K views13 pages

Javascript 101: André Odendaal

JavaScript 101 provides an overview of JavaScript including: - A brief history noting it was designed in 1995 by Brendon Eich to replace Java for web pages and was rushed to market. - The language was standardized by ECMA and called ECMAScript. The latest version 5 includes strict mode for error checking. - JavaScript has basic types like numbers, strings, booleans, objects, arrays, and functions. Objects can have properties, property names must be unique strings. - Functions are objects that can be invoked, have parameters, statements, and set the value of 'this' differently based on how they are invoked. - Prototypes allow inheritance where if an object doesn't

Uploaded by

Anthony Low
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11K views13 pages

Javascript 101: André Odendaal

JavaScript 101 provides an overview of JavaScript including: - A brief history noting it was designed in 1995 by Brendon Eich to replace Java for web pages and was rushed to market. - The language was standardized by ECMA and called ECMAScript. The latest version 5 includes strict mode for error checking. - JavaScript has basic types like numbers, strings, booleans, objects, arrays, and functions. Objects can have properties, property names must be unique strings. - Functions are objects that can be invoked, have parameters, statements, and set the value of 'this' differently based on how they are invoked. - Prototypes allow inheritance where if an object doesn't

Uploaded by

Anthony Low
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

JavaScript 101

Andr Odendaal

Background
Netscape Navigator
Designed by Brendon Eich in 1995 Built to replace Java for the web and be easy to use Principles from Java (syntax), Self (prototypes) & Scheme (functional) Rushed to market with good, bad & questionable design choices Microsoft created Jscript, a compatible dialect to avoid trademark issues

ECMA
Standardized by ECMA (European Computer Manufacturers Association) Called ECMAScript between Netscape & Microsoft Latest version 5 includes strict mode for more thorough error checking

Basic Types
number
Only 64-bit floating point No integers, longs, doubles, signed or unsigned to complicate matters Associative Law does not hold for some values (a + b) + c === a + (b + c)

string
0 or more 16-bit Unicode (UCS-2) characters. No character type

boolean
true & false

Objects
Object Literals
Dynamic (not based on pre-defined class) collection of properties Property names must be a unique string within the object

Basic Operations Get, Set & Delete


object.name | object[name] object.name = value | object[name] = value delete object.name | delete object[name]

Property
Named collection of attributes ES5 added functionality to define properties and added Get, Set functions Attributes: value, writable, configurable, enumerable, get, set

Demo Objects

Object Types
Arrays
Special object with index as property names (not associative) Has properties like: length, sort(), filter()

RegEx
Regular expression object 2 primary methods exec() returns a match and test() returns boolean

Functions
An object which can be invoked with parentheses ()

Demo Objects Revisited

Other Types
null
Nothing

undefined
Less than nothing

Functions
Composition
Made up of 4 parts: function, name (optional), parameters, set of statements 2 additional parameters: arguments object & this (invocation context)

Invocation
Method this is the local object Function this is the global object Apply this is passed as a parameter Constructor this is the new object

Calling
Assigning less parameters will make them undefined

Demo Invoking Functions

Inheritance with Prototypes


Prototype with functions
All functions have a property prototype as a base object Use new keyword with function invocation to create new objects Constructor functions should start with a capital letter

Inheritance
If object doesnt have a property look in base object

Demo - Prototyping

Questions?

You might also like