Angular 2 Sort table columns

I assume you are loading the data (selectedData) for this template asynchronously in the component’s class, so at the start it’s not yet returned form the service, hence selectedData = undefined. There are several things you can do to mitigate that: 1. Initialize the data in the component Set the selectedData class property to an empty array so … Read more

Correct modification of state arrays in React.js

The React docs says: Treat this.state as if it were immutable. Your push will mutate the state directly and that could potentially lead to error prone code, even if you are “resetting” the state again afterwards. F.ex, it could lead to that some lifecycle methods like componentDidUpdate won’t trigger. The recommended approach in later React … Read more

How can I unset a JavaScript variable?

The delete operator removes a property from an object. It cannot remove a variable. So the answer to the question depends on how the global variable or property is defined. (1) If it is created with var, it cannot be deleted. For example: (2) If it is created without var, it can be deleted. Technical Explanation 1. Using var In … Read more