官术网_书友最值得收藏!

  • Mastering Immutable.js
  • Adam Boduch
  • 210字
  • 2021-07-08 10:30:03

Deleting old data

When you first learned how to program, one of the earliest concepts that you were taught was the variable. A variable is something that's used to store a value, so of course it's important! When you create a variable and assign its initial value, it feels like you're creating new data. This is because you are creating new data.

Then, later on in your code, you assign a new value to your variable. It's a variable, so naturally it varies. This might also seem like you're creating new data, which you are; if you assign the value 5 to your variable, then that's a new value that didn't exist before. Here's the catch: you're also destroying data. What if your variable had a value of 2 before you assigned it 5?

This might not seem like a big deal. Isn't a variable supposed to store whatever value you assign to it? Yes, variables work perfectly fine that way. They do exactly what we ask them to do. So, the problem isn't strictly that variables can change their values. Rather, it's a human limitation—we can't reason our way through the huge number of variable changes that happen in our code. This leads to some scary bugs.

主站蜘蛛池模板: 左权县| 新密市| 新津县| 平安县| 客服| 库车县| 稻城县| 建德市| 江达县| 辽源市| 洛川县| 长沙市| 宝应县| 陆丰市| 林州市| 西乌| 通江县| 河西区| 冷水江市| 左权县| 沈阳市| 平乐县| 宜良县| 舟曲县| 泾川县| 双鸭山市| 新化县| 武夷山市| 黔东| 社旗县| 深圳市| 两当县| 开鲁县| 晋城| 城步| 安化县| 雷州市| 社旗县| 河曲县| 高尔夫| 沾益县|