With 15+ years of dev experience, I'm an online educator, mentor, and consultant--teaching practical, advanced topics to developers like you on how to write: ✅ maintainable JS code ✅ scalable web apps ...yup that's about it! 🎤
Nothing here yet.
For an IFace1 object, if you call Object.keys() on it, it will always return an array with "NotOptional" it it. Not so with IFace2 . Like you said, in practical terms that's mostly useful for memory allocation. But sometimes there can also be subtle implications as well; kinda like the difference between null and undefined.
One of my favourite util functions using Array.from: const listRange = ( begin, end, inc = 1 ) => Array .from({ length : Math .ceil((end - begin) / inc) }, ( _, i ) => begin + i * inc); // console.log(listRange(0, 4, 1)); // [0, 1, 2, 3] // console.log(listRange(0, 4)); // [0, 1, 2, 3] // console.log(listRange(1, 10, 2)); // [1, 3, 5, 7, 9]