0

Javascript is def not my main programming language I for practice I wanted to do something simple, at least i thought ;)

This is my code:

function Log () {}

Log.format = function (func, facility, text) {
    func("hellow");
};

Log.debug = function(facility, text) {
    Log.format(console.warn);
};

When I call Log.debug("we", "deb"); I get a Uncaught TypeError: Illegal invocation error. What am I doing wrong?

Haagenti
  • 7,974
  • 5
  • 38
  • 52

1 Answers1

1

Depending on the browser, console methods can only be called in the context of console. Try Log.format(console.warn.bind(console));

user123444555621
  • 148,182
  • 27
  • 114
  • 126