??. Of course, you don’t need TypeScript to use it — you can either configure Babel to enable this feature, or just wait until it lands in the ECMA standard.
Let’s talk about why you’d want to use it, rather than the usual double pipe operator. Consider this example:
The boolean problem
const chickenPref = false;
const globalPref = true;const serveUserChicken = chickenPref || globalPref; // evaluates to true
This user has been crystal clear that she does not like chicken — but the OR operator (||) doesn’t care. It will still continue and evaluate the
globalPref, as if the
chickenPref has not been defined. Why? Because the OR operator doesn’t care what exactly the value of the left operand is —it coerces the left operand into a boolean, and if it’s false, it’ll continue to evaluate the right one, resulting in one unhappy user. …
I suspect that there’s a certain personality type that is drawn to programming. The type of person that must be solving problems and learning new things, because without this drive, it’s hard to get ahead. But this career drive can be a double-edged sword, making it difficult to maintain a balance in life and prevent long-term damage to one’s health.
When I got my first real coding job at a Rails consultancy, there were a few lifestyle changes that came along with the new job that I didn’t pay much attention to at first, but over time had insidious consequences. For one thing, I now had a decent paycheck. …
Ant (GitHub) is much more than a React UI kit with a minimalist design aesthetic and every component under the sun. It is a rabbit’s hole that leads to a giant maze of interconnected libraries, with a serious ecosystem surrounding it. There’s a custom build tool based on Webpack called ant-tool, several CLI apps, community scaffolds, and a complete framework (dva, which has its own CLI as well). And the UI components are mini-projects in and of themselves — see this repo for information on each component.
Many of these libraries appear to be very polished, including an entire React animation library. And I’d love to learn more about them, but Ant comes with a challenge — the majority of the documentation is in Chinese. …