This is a basic javascript question basically i was just going though this function below:
function hexToRgb(hex){
  // By Tim Down - http://stackoverflow.com/a/5624139/3493650
  // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
  var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
  hex = hex.replace(shorthandRegex, function(m, r, g, b) {
     return r + r + g + g + b + b;
  });
  var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
  return result ? {
      r: parseInt(result[1], 16),
      g: parseInt(result[2], 16),
      b: parseInt(result[3], 16)
  } : null;
};
As you can see this code is already taken from another thread on SO, now my question is specifically about the peice of code:
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
  hex = hex.replace(shorthandRegex, function(m, r, g, b) {
     return r + r + g + g + b + b;
  });
The parameters of the replace function I.E. m, r, g , b are basically the following as i see in my dev tools:
m = "#fff",
r = f
g = f
b = f
I see the aboe in my dev tools , the option i had passed is #fff.
Now my question is who is passing there parameters ? does the regex have anything to do with parameters being passed ? who is passing these parameters ? m,r,g,b ? I have checked what the regex is doing HERE , but i still don't understand who is passing the parameters to this function ?
 
    