To handle divide by 0 properly in Javascript & ReactJs, you can use isFinite() function which returns true if the number is finite. Check this code – Source: MSDN
To get an infinite number in Javascript and ReactJs, you can use Infinity property of global scope. No number is greater than this. You can use it to compare a…
To create an array of size n and having null values, you can use Array(n).fill(null) function. It works in both Javascript and ReactJs. Check out this code example – Example…
To create immutable copy of object in reactjs, you can use Object.assign() method. This method is also used to create a copy of state object. Since states should not be…
React components can have state by setting this.state in their constructors. this.state should be considered as private to a React component that it’s defined in. In this article we are going to…
Learn how you can pass data from one component to another through props in react js. Here we have declared two class components – Board and Square. We are passing…
In this article we are going to learn how to use unordered (UL) and ordered (OL) lists in JSX in React JS codes. Here is the example – Source: Reactjs…
A component can maintain internal state data with this.state. When a component’s state data changes, the rendered markup will be updated by re-invoking render(). Here we are using states in class component…
Introduction The word enum in solidity stands for Enumerable as it does in most of the other languages. Enum is a user defined data type which contains set of a…
In Solidity it wasn’t possible to pass struct as parameter but with the introduction of experimental library ABIEncoderV2, it could be done. Solution Code Explanation In this code I have…
Python Tensorflow throws error “cannot import name ‘to_categorical’ from ‘keras.utils’” when you are using Tensorflow version 2 but implementing the older syntax. Solution Instead of using this syntax for importing…
Python throws error “pip is being invoked by an old script wrapper” either due to incompatible pip version or due to multiple versions of pip. Solution To resolve this error,…
Python poetry throws error “Poetry could not find a pyproject.toml file” when it is not able to find pyproject.toml file in project directory. It means Poetry is not initialized properly.…
Python subprocess library is used to run processes like bash script in the background. It can create new processes, connect with their input/output/error pipes and obtain their error codes. Code…
Functions in carbon language has the same role as in C, Php or any other functional language. It is used to separate a functionality for reuse. For example, a function…
We can use for and while loops in carbon language. Within a loop the break and continue statements can be used for flow control. while Loop while loop in carbon…
In Carbon language we don’t have switch statement. Else we have match. match is a control flow similar to switch of C and C++ and mirrors similar constructs in other languages, such as…
Ternary operators are generally used to return a value based on conditions in a single statement. This prevents unnecessary variable declarations and memory consumption. In Carbon we have if expressions…