constant needs to be initialized when it is declared.
read only variable can be assigned dynamically but need to be done before constructor exists as the the value is not changeable later.
Choosing between read only or constant depends on our requirement. When we are confident that our constant value does not change we can use "const". The issue with constant is when we define a constant "a" variable with value 20 in an assembly X and use this assembly in another assembly Y, any update of variable "a" is not reflected until we recompile it.
But when we use a read only value here it is a reference to memory location and when we have new "a" value and on building assembly "X" all the assemblies using this X assembly the value of "a" is updated without being building them again.
Subscribe to:
Post Comments (Atom)
Call a function in child component from parent component in React
Consider the following parent component class Parent extends React.Component { constructor(props) { super(props); thi...
-
Web Application:Any application which we can run in our web browser is a web application. Web Service:A web service is an Application Prog...
-
Amazon cloudfront offers a simple cost effective way to improve the performance, reliability and global reach of your entire website for s...
-
p5.js is a JavaScript library which can be used by artists,designers,educators and beginners who want to code. Using p5.js we have a full se...
No comments:
Post a Comment