Javascript

General topics about Javascript and front-end develpoment.

Bower

Front-end package management tool.

Objects

Prototype

function Dog (breed) {
  this.breed = breed;
};

var buddy = new Dog("golden Retriever");

// add a method to prototype of Dog
Dog.prototype.bark = function() {
  console.log("Woof");
};

Inheritance by Prototype

Douglas Crockford's video course: Prototypal Inheritance

function Gizmo(id) {
    this.id = id;
}

Gizmo.prototype.toString = function() {
    return "gizmo " + this.id;
}
var g = new Gizmo(1);

Object

Javascript: The Good Parts

convert strings to numbers

    +"42" -> 42;
    Number("42") -> 42;
    parseInt("42", 10) -> 42;

truesy and falsey

functions

    // function expression
    var foo = funcion() {};

    // function statement
    function foo() {};

    // function statement is a short-hand for var statement, which will expand to:
    var foo = undefined;
    foo = function foo() {};

**don't put function statement in a block, such as `if` block, since the function name will also be hoisted**

style guides