DEV Community

Cover image for JavaScript 101: Breaking Down Functions

JavaScript 101: Breaking Down Functions

Kara Luton on June 10, 2019

Functions are at the core of what we do in JavaScript so it's essential that we understand what they do and how they work. But what exactly are fun...
Collapse
 
codingnninja profile image
Ayobami Ogundiran • Edited

Great post!

"If there is no function body then your function will return as undefined."

This statement takes us further to passing a function as a value to a variable.

console.log(isNigerian (Ayobami));

function isNigerian(person){
return // Boolean
}

Will work but the below will not.

console.log(isNigerian(Ayobami));

const isNigerian = function(person){
return // boolean
}// isNigerian is not a function

Will not work because a function passed to a variable in JavaScript will be hoisted but you cannot access it until JS execution gets to its definition

Collapse
 
karaluton profile image
Kara Luton

Thank you! And thanks for the addition!

Collapse
 
tierraskyllc profile image
TierraSkyLLC

? When you wrote:Here I'm passing in 'Kara' as our parameter. Should it not be called an argument as you wrote above. (what goes inside the parentheses) while arguments are the values the function receives from each parameter when the function is executed. Just trying to understand.

Collapse
 
karaluton profile image
Kara Luton

Ah yes! Thank you for catching that. I’ll get it updated.

Collapse
 
fellipegpbotelho profile image
Fellipe Geraldo Pereira Botelho

Nice job :)

Collapse
 
jamonjamon profile image
Jaimie Carter

Thanks for that. This makes it very clear.
I see you’re a music publicist.... I used to work for Rondor publishing a lifetime ago. Always loved my visits to Nashville.

Collapse
 
karaluton profile image
Kara Luton

That’s awesome! Nashville is a great town - it’s grown a ton!

Collapse
 
jamiekaren profile image
Jamie Ferrugiaro

Great post! Especially pointing out argument versus parameters.

Collapse
 
karaluton profile image
Kara Luton

Thank you!