Never reference js-
prefixed class names from CSS files. js-
are used exclusively from JS files.
Use the is-
prefix for state rules that are shared between CSS and JS.
Classes and IDs are lowercase with words separated by a dash:
Right:
// SOLUTION: | |
// Turns out that the following is the most performant in terms of ops per seconds. | |
// It iterates on an array, staying within the "while loop" as long as | |
// the current item exists. Checking also whether using concat to the very same "arr" argument | |
// or push methods in a new stack array until no items are left within the "arr" argument | |
const flattenLoop = arr => { | |
let stack = [] | |
let item | |
while (item = arr.shift()) { |
/** | |
* Flattens passed in array. | |
* | |
* @param {Array} input is the array to flatten. | |
* @returns {out} returns flattened array. | |
*/ | |
function flatten(input) { | |
let i, | |
placeHolder = [input], |
Never reference js-
prefixed class names from CSS files. js-
are used exclusively from JS files.
Use the is-
prefix for state rules that are shared between CSS and JS.
Classes and IDs are lowercase with words separated by a dash:
Right:
function makeRequest(url,callback,context) { | |
var httpRequest = null; | |
if (window.XMLHttpRequest) { // Mozilla, Safari, ... | |
httpRequest = new XMLHttpRequest(); | |
} else if (window.ActiveXObject) { // IE | |
try { | |
httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); | |
} | |
catch (e) { | |
try { |