Sobsno wondered whether to shorten the console.log () construct for convenience. Since I often use the console output firebug. I implemented it like this: var cout = console.log; cout ('It's great. But doesn't work in Chrome's console!');

As you understand from the output line, this case does not work in the chrome console. I did not understand the reason. Can you explain? Or tell me another way to cut?

  • Yes. By the way, the other day I tried to do something else like this: function cout (x) {console.log (x); } It seems to be so. I do not remember. I really did not check this method in chrome. - Ghringo

2 answers 2

var log = function(msg){ console.log ? console.log(msg) : alert(msg); } log('Где то пошло, что то не так') 
  • In general, there may be such a situation that the left part of the operator: will not be fulfilled? - Ghringo
  • one
    I don’t know for sure, there can be anything in our world) - Mikha Nikolaev
  • "God protects the cherished" - said the nun, putting a condom on the candle :) - mazzy
 window.c = function (msg) { console.log(msg); }; c('Тра-та-та..');