在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:learn-co-students/javascript-arrays-lab-bootcamp-prep-000开源软件地址:https://github.com/learn-co-students/javascript-arrays-lab-bootcamp-prep-000开源编程语言:JavaScript 84.2%开源软件介绍:JavaScript Arrays LabObjectives
IntroductionPreviously, we've learned about how arrays work. We know that Now it's time to put what we've learned to the test. What's with all this destruction?You might have noticed that our tests are looking for functions like
We want to distinguish between actions that mutate ("change") their underlying
structures (like In general, it's good practice to avoid mutating a program's state whenever possible. So we want to call out these methods as destructive, since mutating state means we don't always know what we're dealing with. Indeed, these mutations mean that we need to refresh the test environment after every test to make sure that we're not working with mutated data! By contrast, we also have methods like Try to use methods like Think of it this way: you're making a peanut butter and jelly sandwich. Would you rather work with a sandwich where someone had put an unspecified amount of peanut butter or jelly on the bread before you start making it (or, worse, where someone had taken a bite out of the bread), or would you rather start fresh? Regardless of your feelings about stale peanut butter and jelly, we're going to state unequivocally that fresh sandwiches are preferable — and fresh functions (ones that don't mutate shared state) are preferable, too. Run those tests!You'll notice that the first test asks for an array called In our test file, we're going to reset this array to your initial value after every test. Some of our tests manipulate arrays in place, and we want to be sure that we can get back to a blank slate between tests. Why is a blank slate important? We want our programs to be predictable: this makes them more robust, easier to maintain, and less prone to bugs. One way to achieve predictability is by isolating our tests from one another, meaning that no test should depend on the outcome or process of any other test. That way, tests can run in any order and test known inputs and environments, rather than depending on other tests running first and modifying the entire environment. Remember the workflow:
Normally, resetting the array and the array itself would be decoupled — that is, independent. But because of the nature of this lab, we need to be a bit prescriptive and give you some initial values so that we can focus on what really matters — understanding how to manipulate arrays in JavaScript. Resources |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论