Extending console.log without affecting log line - Javascript Function

Javascript examples for Function:Function Bind

Description

Extending console.log without affecting log line

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from   w w  w .j  a  v a2 s  . c o  m*/

log = function() {
    var context = "My Descriptive Logger Prefix:";
    return Function.prototype.bind.call(console.log, console, context);
}();
log("This is a test...");

    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials