javascript - Prepend argument to arguments then apply -
I have a function, Add (""); // will actually be used to set a type of div on div / but I'm just using console.log so that it can be as simple as ever. Console.log (type + ":" + msg); } I want to provide helpful tasks, The first path seems a little unnecessary, creating a new array, the first argument and logic are flat. The other way seems a bit ... messed up? Although using my: I get the following output: View message which takes an overview to define the message type And then
is added to any other argument to create a message for the function message (type) {var msg = _.rest (arguments), purely an undisputed one.
error ,
warning ,
information , which just call With the right type, I am just unsure about the best way to go about this. I can think of two ways but I am not sure I go about it in the right way. Or maybe I want to finish things.
Message. Now (this, _. Fleeton (["error", logic]));
Array.prototype.unshift.call (logic, "error"); Message.apply (this, arguments);
(function () {Array.prototype.unshift.call (logic, 0); console, log (logic) ;}) (1, 2, 3);
[0, 1, 2, 3, undefined, undefined, undefined, ..., undefined]
var args = Array.prototype.slice.call (argument); // argin args.unshift ("error") create the actual array; Message.apply (this, args);
Comments
Post a Comment