3 ms·
Function objects are mutable in the sense that you can define new properties for them or assign new values to (writable) existing properties. This is sometimes
by aragonite 3y ago
Function objects are mutable in the sense that you can define new properties for them or assign new values to (writable) existing properties. This is sometimes used to simulate static variables:
function f() {
f.count ??= 1;
console.log(f.count++);
}
f(); // Outputs: 1
f(); // Outputs: 2
f(); // Outputs: 3