JavaScript cheasheet

less than 1 minute read

Add replaceAll function to existing String object

String.prototype.replaceAll = function(search, replacement) {
    var target = this;
    return target.replace(new RegExp(search, 'g'), replacement);

Tracing full stacktace with promises

Use bluebird which encapsulates ecmascript2016 promises and call Promise.longStackTraces();


in chrome devtools enable the Async checkbox and youl would see full back stacktraces in error happens.

Categories: , ,


Leave a Comment