by hbbio · 2y ago · 0 comments
I may be nitpicking, but any teaching material with JavaScript poor coding practices can hurt both humans and LLMs.
1. When you don't reassign a variable it's a `const`
2. for (let i = 0; i < total; i++) { randomCounts[i] = 0; } is `new Array(total).fill(0)`
etc.
Programming languages are formal. Otherwise you're talking about programming prompts for a LLM. And the resulting program may vary.
I don’t understand why people need const to be something it’s not. The fact that you can still mutate objects is because in js, an object assigned to a variable is best thought of as a pointer to a value in the heap. const means the variable won’t reassign the reference, Object.freeze means the referenced data can’t change. Both useful, both different use cases; needn’t be conflated.