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.
Sunday, May 7, 2017
Saturday, May 6, 2017
Friday, May 5, 2017
Thursday, May 4, 2017
Wednesday, May 3, 2017
Tuesday, May 2, 2017
object literals in Javascript
A JavaScript object literal is like a comma separated name value pairs .
Ex: var myObject={name:"narendra",height:180};
We can access the properties as myObject.name which gives "narendra"
Ex: var myObject={name:"narendra",height:180};
We can access the properties as myObject.name which gives "narendra"
Monday, May 1, 2017
Truthy and falsy values
Truthy Values:
"0"
"false"
empty functions
empty arrays
empty objects
typeof(null)
these above listed items are considered true in javascript
Falsy values:
false
0
""
null
undefined
NaN(Not a number)
These are considered false.
When dealing with these truthy and falsy values we should be careful and always try to use "===" or "!==" when we need to compare .
"0"
"false"
empty functions
empty arrays
empty objects
typeof(null)
these above listed items are considered true in javascript
Falsy values:
false
0
""
null
undefined
NaN(Not a number)
These are considered false.
When dealing with these truthy and falsy values we should be careful and always try to use "===" or "!==" when we need to compare .
Subscribe to:
Posts (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...
-
The process of replacing a module with generic and mostly empty object, called a mock. Advantages: Isolates our code from its dependen...
-
An object is an entity that has Properties for identifying State, Methods for behavior, Events for depicting the change of State. Data ass...
-
Common Language Runtime or CLR is the run-time execution environment of .Net Framework. Converting MS-IL into platform or OS specific code ...