Prep: Learning Javascript

I also want to learn javascript again. Here are some useful pages and notes.

scope & hoisting
+ REMEMBER that variables have function scope, so a var can be declared anywhere in a function, even after use
+ Language-defined: All scopes are, by default, given the names this and arguments.
+ Formal parameters: Functions can have named formal parameters, which are scoped to the body of that function.
+ Function declarations: These are of the form function foo() {}.
+ Variable declarations: These take the form var foo;

+ remove a property from an object
+ cant delete “var x” or “function x()”

numbers and strings
+ add a number and a string, the result will be a string

+ === This is the strict equal operator and only returns a Boolean true if both the operands are equal and of the same type
+ primitive datatypes (value): number, string, boolean, undefined, null
+ reference datatypes: array, object, function
+ pass numbers, strings, functions by value
+ pass objects by reference

Unobtrusive Javascript
+ HTML describes the page structure, without embedded javascript. The javascript adds behavior to existing structure.

Javascript Custom Exceptions
+ throw new NotPositiveNumberException;
+ catch (e){ if … instanceof …

Javascript Type Casting
+ Three type casts are available in JavaScript: Boolean(value) Number(value) String(value)

Javascript Prototypes (for real)
+ a.constructor.prototype
+ every function gets a prototype property
+ var Circle = function(radius) {
+ Circle.prototype.area = function() {

Javascript Instanceof
+ Right Hand Side (RHS) operand which is the actual constructor of a class
+ evaluates to true if the object inherits from the classe’s prototype
+ instanceof is defined by the use of the “new” keyword
+ All “new” calls to a function return an object that inherits from Object

Javascript Functions that take a variable number of arguments
+ use if (! argument)
+ use the arguments array
+ pass an object

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s