Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function runWithDebugger(callback, args) {
- debugger;
- if (Array.isArray(args)){
- callback(...args);
- }
- else {
- callback(args);
- }
- }
- function sayHi() {
- console.log('Hi');
- }
- function sayHiTo(name) {
- console.log('hi ' + name);
- }
- function sayFullName(first, last) {
- console.log(first + ' ' + last);
- }
- console.log('testing without any arguments');
- runWithDebugger(sayHi); // 'Hi'
- console.log('Testing sayHiTo with string input:');
- runWithDebugger(sayHiTo, 'gordon'); // 'Hi gordon'
- console.log('Testing sayHiTo Array one item:');
- runWithDebugger(sayHiTo, ['gordon']); // 'Hi gordon''
- console.log('Testing sayFullName Array multiple items:');
- runWithDebugger(sayFullName, ['gordon', 'zhu']); // 'gordon zhu'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement