Kyle spends a few minutes answering audience questions on immutability. He also talks about implementing a function that returns a copy of an array as a way to remain pure while working with array values.
(flute and bass music)…- [Participant] So if z and w both pointed to the same…array and you froze like w, z would also be frozen.…The contents of z, right?…So z and w equal.…- If you had a line 11 const w = Object.freeze…and then on line 11 and-a-half you said z = w,…is that what you're asking?…- [Participant] Or you could do it the other way,…if you say w = z, - Uh huh.…- [Participant] And then you freeze w.…
- If I said, if line 11 said const w = Object.freeze z.…Okay, is that the question?…- [Participant] Yeah.…- The answer to that question is all about references.…Z is simply a reference to the array.…So you would be taking a reference to the array,…passing it in object.freeze, it would be making…a change to the actual array, and now z and w…would be constant references to the same array…which now had been frozen.…- [Participant] Okay, so z would be frozen also.…- It's not appropriate to think of it as being…frozen "also," because there's only one.…
- [Participant] Okay.…- What we're saying is that we've made that change…
This course was created by Frontend Masters. It was originally released on 03/08/2016. We're pleased to host this training in our library.
- Pure functions
- Manual composition
- Composition utility
- List operations
Skill Level Intermediate
1. Pure Functions
2. Composition and Immutability
3. Closure and Recursion
4. List Operations
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.