Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. function runWithDebugger(callback, array){
  2.  
  3. debugger;
  4.  
  5. // when has second argument
  6. if(arguments.length > 1){
  7. // when second argument's type is array
  8. if(Array.isArray(array)){
  9. callback.apply(null, array);
  10. // when second argument's type is not array
  11. } else {
  12. try {
  13. throw new TypeError('The second argument must be an array.');
  14. } catch(e) {
  15. console.error(e.stack);
  16. }
  17. }
  18. // when no second argument
  19. } else {
  20. callback();
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement