what is the difference between these functions?
let square = function square(number) { return number * number }
let square = function(number) { return number * number }
both work the same but is there any difference?
what is the difference between these functions?
let square = function square(number) { return number * number }
let square = function(number) { return number * number }
both work the same but is there any difference?
This function has a name "square", you need to call it with its name to execute it,
function square(number) { return number * number }
while, this is a anonymous function without a name, and it will execute without any call,
function(number) { return number * number }
read more about anonymus functions here.
In let square = function(number) { return number * number }, you are using whats called an anonymous function and setting its value to square.
In let square = function(number) { return number * number } you are just creating a standard named function and assigning it to the variable square.
Both are functionally the same and its up to user preference.