JavaScript Code-Segment: PiggybackData : The Proper Object-Oriented Way to Overcome Known Problem Of “Callback-Hell” And Chained Callbacks With Single Data Parameter

   * this is a proper object-oriented way to resolve a problem known as (or derived from..) "callback hell", 
   * essentially this allows information to be added to a simple string, while still maintaining its original functionality.
   * @type {{}}
   * @author
  String.prototype.piggybackData = {};

at any point you can store data in a string and pass it along the callback,

   * @param {function(string)?} callback
var action = function(callback){
  var str = "hi"; = new Date();
  str.piggybackData.isTrue = true;
  str.piggybackData.hello = "world";


and extract it at any time later,

    date =,
    isTrue = strContent.isTrue,
    hello = strContent.hello;

in short: JavaScript. Rocks!

nodeJs too..

Leave a Reply