Sitemap
codeburst

Bursts of code to power through your day. Web Development articles, tutorials, and news.

Follow publication

JavaScript Functions — Understanding The Basics

5 min readFeb 12, 2018

--

What is a Function?

Define a Function.

function name(parameters){
statements
}
let name = function(parameters){
statements
}
let name = (parameters) => {
statements
}

Parameters vs. Arguments.

const param1 = true;
const param2 = false;
function twoParams(param1, param2){
console.log(param1, param2);
}

Invoking a Function.

function logIt(name){
console.log(name);
}
logIt('Joe');
// Joe
function logIt2(){
console.log('The second one');
}
logIt2();
// The second one

Function Return.

function test(){};test();
// undefined
function test(){
return true;
};
test();
// true
let double = function(num) {
return num * 2;
}
let test = double(3);
console.log(test);
// 6
function test(){
return true;
return false;
};
test();
// true

Function Objects.

Key Takeaways.

Closing Notes:

If this post was helpful, please click the clap 👏 button below a few times to show your support! ⬇⬇

--

--

codeburst
codeburst

Published in codeburst

Bursts of code to power through your day. Web Development articles, tutorials, and news.

Brandon Morelli
Brandon Morelli

Written by Brandon Morelli

Creator of @codeburstio — Frequently posting web development tutorials & articles. Follow me on Twitter too: @BrandonMorelli

Responses (21)