when do we use let
and when do we use const
?
I know that :
- use let keybord to create block/local scoped variable
- const is a special kind of let which you can read only but cannot reassign value to it
- const value is fixed,
but for example, in the snippet below, we do need to pass in different arguments into the function dont we?
const myConcat = (arr1,arr2)=> {
"use strict";
return arr1.concat(arr2);
};
// test your code
console.log(myConcat([1, 2], [3, 4, 5]));
what I mean is that if the const value should be fixed, (unless its an object) then why are we using it in the snippet? why not use let ?