Guest User

Untitled

a guest
Sep 21st, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. /**
  2. * Created by azu.
  3. * Date: 12/03/29 10:17
  4. * License: MIT License
  5. */
  6. function wrapConsole(code, args) {
  7. var argStr = JSON.stringify(args || []);
  8. new Function('console', '(' + code + ').apply(null,' + argStr + ')')({
  9. log:function () {
  10. // arguments ["コンソール", [].slice.apply(arguments).join("+")]
  11. alert([].slice.apply(arguments).join(''));
  12. }
  13. });
  14. }
  15.  
  16. wrapConsole(function () {
  17. // arguments [1,2,3]
  18. console.log("コンソール", [].slice.apply(arguments).join("+"));
  19. }, [1, 2, 3]);
Add Comment
Please, Sign In to add comment