Skip to content

Instantly share code, notes, and snippets.

@carlesba
carlesba / ImmutableArray.js
Last active November 18, 2022 13:23
Immutable builder
function ImmutableArray (arr) {
arr.forEach((key, index) => {
Object.defineProperty(this, index, {
enumberable: true,
get: () => key,
set: () => {
throw new Error('cannot be mutated')
}
})
})