Node.js examples for Array:Array Operation
Normalize css liked array configuration
/**//from ww w.j av a 2 s.c om * Normalize css liked array configuration * e.g. * 3 => [3, 3, 3, 3] * [4, 2] => [4, 2, 4, 2] * [4, 3, 2] => [4, 3, 2, 3] * @param {number|Array.<number>} val */ function normalizeCssArray(val) { var len = val.length; if (typeof (val) === 'number') { return [val, val, val, val]; } else if (len === 2) { // vertical | horizontal return [val[0], val[1], val[0], val[1]]; } else if (len === 3) { // top | horizontal | bottom return [val[0], val[1], val[2], val[1]]; } return val; }