今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Same methods, different map
- [Instructor] As we briefly touched on in our last lesson WeakMap has four methods that we can utilize when working with them in our code. These four methods are set, get, has and delete. These methods work in the exact same manner that they did with map. In this lesson, we're going to review how these methods work before diving into a challenge in the next video. The first method we will review is set. Just like map you'll use set to build your WeakMap. Remember your key cannot be a primitive value and it must be an object. The next method is get. We use get to retrieve the value associated with the specific key that we pass. We pass the key and the value is returned. If the value does not exist in the WeakMap the value undefined is returned. The WeakMap also utilizes the has method. We pass a key to the has method and it returns true or false based on whether or not the key exists in the WeakMap. And finally, the…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。