Javascript utilities; mostly from the book "JavaScript Patterns" by Stojan Stefanov; partially updated