Thank you SO much for this video it has helped me tremendously. I hope your channel blows up soon. A lot of us younger developers are presented with these giant inscrutable pillars of abstraction, solutions to pains we never felt. We have to descend down from the top in order to gain understanding and level up as engineers. This time-travel approach is extremely effective and I plan to use it in the future to understands other parts of the stack.
@Mitsunee_
Жыл бұрын
interesting that IIFEs were used so early on. As a self taught developer I made up my own conventions for how to handle globals and had all my code in a single file for a looong time. Nowadays I only use IIFEs as a workaround for some tools not yet fully grasping that top-level await is now a thing. They're also great for handling temporary variables that are only really needed at that one spot, freeing up the name thereafter, even making TypeScript happy despite the name collision. Overall I'm really happy with the ES module standard we have now, as it's simply the least verbose way we ever had to do the same thing, although I avoid default exports since they tend to create issues with some bundlers still. Also using `await import("package").then(pkg => Object.assign(global, pkg)&&pkg)` (imports any es module, assigns its named exports to the global scope and then displays the imported module) in the node REPL only really works with named exports.
@branvandermeer
Жыл бұрын
Agreed, very interesting that IIFE's are so old, I've gotten to know them as "the first module system". As for temporary variables, you can also use the block statement (just curly braces) we got with ES2015, they're shorter than IIFE's and don't use the overhead of a function: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/block#block_scoping_rules_with_let_const_class_or_function_declaration_in_strict_mode
@LambdaJack
Жыл бұрын
Object.assign? Lisp FTW.
@micalevisk
Жыл бұрын
Your videos are pretty good. Thanks!
@draganbogdan4267
3 ай бұрын
So for the iife exemple, if the function is called and not saved in a variable how do you acces it's content doesn't it just get popped away after it's called ? I don't know if my question is clear.
@blu3tan
8 ай бұрын
excellent explanation, also nice song in the bg, what is it?
@branvandermeer
8 ай бұрын
Thanks! - The song is Legato - Ever So Blue. I have access to this via my Epidemic Sound subscription, a service for youtubers which takes care of the whole licensing-music-on-youtube-problem.
Пікірлер: 9