0

JS function-expression

For function expressions e.g: const calculateArea = function(width,height) { const area = width*height; return area; }; Q1)I am trying to interpret this compared to the function declaration way. Is it like saying: perform the function with the parameters height and width. Carry out the block statement. Return the result and assign the 'calculateArea' variable the value result??? Q2)And I don't get how you can define it as 'const' when the function block will return DIFFERENT values (depending on what arguments are passed into the parameters)??? Or does it just mean that later down the code, you can't assign const calculateArea as something else?

24th Apr 2019, 1:57 PM
J3fro C
J3fro C - avatar
1 ответ
+ 1
1) yes 2) the function does the same task everytime it runs. So 'const' makes sense. This way you don't need to return the value const foo = (a,b)=> {}
24th Apr 2019, 2:12 PM
wenz
wenz - avatar