At first I was like "I can't think of anything this video could teach me". After two minutes "I don't even know how console logging works..."
00:48 how to use console.log 02:39 Object Destructuring 04:00 Template Literals 06:09 Spread Syntax 08:20 Loops 10:21 Async/Await
00:51 - Debugging with console.log 02:39 - Destructuring 03:59 - Template literals 06:07 - Spread syntax 08:19 - Loops 10:18 - async/await
Fireship : So we're going to parse the arguments in it.... Me : Looses focus for a bit Fireship : So yeah that's how you make Minecraft with JS
It's a whole new level of console.log!
console.table() --- mind blown
Code not this that
Shit, I just realized I don't know nothing about JS.
This is depressing and motivating at the same time
9:23 It should be a disclaimer that running the for-loop on orders once (in the code he advises against) is faster than iterating orders 3 times using orders.reduce, orders.map, and orders.filter. If orders is a huge array this could significantly impact performance, and then the for-loop would actually be an optimisation.
Another thing to keep in mind at ~10:15 is that you're now doing 3 loops compared to one loop. At some point you have to wonder whether you want to give up runtime for readability, because the for loop is definitely going to be faster. It doesn't matter when you have one record, but if you have an array of multiple hundreds of thousands of records if you're running a batch or an import of something, it is going to make a difference if you reduce, filter, and map, or just do one for loop. Technically you could also just do it in one reduce function.
"I can do a whole video on console logging" Please do!!
Wow, I had no idea about: - console.table - console.log({propertyName}) - CSS style in console.log Thanks for the tips!
A coffe for the great content of the channel
This is more a guide on how to use the latest JS features than a good pratices tutorial.
Please be very careful when condensing traditional loops to functions like map and filter... You can wind up running your loop several extra times, or in many cases dozens of extra times - per function call. It's often the case that a map or filter operation will be used by someone and re-run per element thousands of times on a single page load or interaction, and they'll even let it run on the UI thread... Concise code is good, and I like a lot of your recommendations but please exercise caution with convenience/style in the loop category. I see probably 3-4 times a month places in our prod code base that can be improved in execution time by orders of magnitude. We're talking seconds of wait time in production code used by tens of thousands of people daily. It's probably my number one pet peeve, wasting millions of cycles on fancy one liners. That's just my one crticism; it's not "💩" code to use manually indexed loops. It's usually the best solution.
Most "pro" tip videos are pretty obvious syntax sugar in ES6; But I actually learned some cool stuff from this one! I can use console.table to print formatted arrays?? "Woah!" I can add inline styling to console.logs?? "Whaaattt!" I can use template literals to automagically destructure function parameters??? "Mind BLOWN!!" Great video!
A lot of valuable information in here, thanks so much. Not too basic, but also not confusingly high-level. The console table, "Oh that's sexy"
For spread syntax keep in mind that it only shallowly creates a new object. If you have deeply nested variables those are copied by reference, so to keep immutability with a deep object you can do, var x = JSON.parse(JSON.stringify(some_obj)); Not sure of the time cost, but it’s an easy way to maintain immutability.
@Fireship