The variable "X" can be made constant, "which means" constant "?

VStudio or ReSharper gives me the following suggestion:

enter image description here

What does constant value mean in this scenario? If it is a constant in the scope of the current method, what is the purpose? Are the methods tending to be small and therefore should not give any advantages over the usual var?

Please enroll me

+4
source share
1 answer

Nothing complicated.

const let ( var), const , , , , , , . , .

, , . , const x = [1]; x[0] = 2; , -, , . , ImmutableJs , .

var vs let vs const : https://jsperf.com/let-vs- -/35. OSX 10.10.2 Firefox 38 const 3% , var ( ), Chrome 43 const 1,28% , var. , . , const .

, const let ECMAScript 2015. const let ECMAScript , const let var.

+6

All Articles