Why position CSS <link> between <head></head> and scripts before </body>

Putting s in the head is part of the specification. Besides that, placing at the top allows the page to render progressively which improves user experience. The problem with putting stylesheets near the bottom of the document is that it prohibits progressive rendering in many browsers, including Internet Explorer. Some browsers block rendering to avoid having to repaint elements of the page if their styles change. The user is stuck viewing a blank white page. It prevents the flash of unstyled contents.

Scripts in the other hand are placed in the bottom to allow the HTML to be parsed and displayed to the user first while scripts are downloaded and executed.

References: https://developer.yahoo.com/performance/rules.html#css_top

Object and Array literal in JavaScript

This post is mostly for my own reference as I seem to keep messing this up. :O

The basics

{} is an object literal

//this creates a new object
a = {};
//so does this
a = new Object();

 

[] is an array literal

//this creates a new array
a = [];
//so does this
a = new Array();

 

properties can be accessed via . and [] notation:

//these are the same
a.b = c;
a['b'] = c;

 

Object literals can be set using literal values or strings:

a = {
    //any character you can use for a variable name can be
    //used to instantiate an object without quotes
    b: c,
    //special characters need to be quoted
    "foo bar baz": "fizz buzz"
};