Skip to content

Instantly share code, notes, and snippets.

@andrewjmead
Created July 1, 2016 12:49
Show Gist options
  • Save andrewjmead/80dfc76a4065338d849dbf0175da5cb9 to your computer and use it in GitHub Desktop.
Save andrewjmead/80dfc76a4065338d849dbf0175da5cb9 to your computer and use it in GitHub Desktop.
Jerome Function Example
function add (a, b) {
return a + b;
}
add;
@auchomage
Copy link

auchomage commented Jul 1, 2016

What happens

function sayGordon() {
    console.log('Gordon');
}

function sayName(name){
    console.log(name);
}

sayName(sayGordon);

The output is the text ie code that makes up the function sayGordon(), that is why I said if a function is called without parenthesis the result it the text that makes up the function. You have said this is not correct, instead it is the value associated with the function.

@andrewjmead
Copy link
Author

Correct. If you console.log a variable that's a function, you'll get that functions text back!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment