Monday, 9 October 2017

Difference between constants and read-only variables.

While constants and read-only variable share many similarities, there are some important differences:
  • Constants are evaluated at compile time, while the read-only variables are evaluated at run time.
  • Constants support only value-type variables, while read-only variables can hold reference-type variables.
  • Constants should be used when the value is not changing during run time, and read-only variables are used mostly when their actual value is unknown before run time.
  • Read-only variables can only be initialised at the time of declaration or in a constructor.

No comments:

Post a Comment

React Hooks - custom Hook

  v CustomHook Ø React allows us to create our own hook which is known as custom hook. Example – 1 localStorage Demo Step-1 Create ...