M
M
MAXH02013-05-14 10:36:33
JavaScript
MAXH0, 2013-05-14 10:36:33

"print" in Eloquent JavaScript by MARIGNE HAVERBECK?

1. How is it implemented?
2. To what extent is this methodologically correct? "print" on the client seems to cause printing to the printer.

Examples can be seen here eloquentjavascript.net/chapter3.html

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PomanoB, 2013-05-14
@MAXH0

Implemented like this:

  win.print = function() {
    var accum = [];
    for (var i = 0; i != arguments.length; i++)
      accum.push(String(arguments[i]));
    var joined = accum.join("");
    env.output(DIV(null, preNewline != "\n" ? joined.replace(/\n/g, preNewline) : joined));
  };

That is simply redefined.
In my opinion, when learning a language, it is quite logical and customary to name the function that prints in its console with the name print. JavaScript is not only used in browsers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question