Syntax Video
Only One of Us Knew These Dev Facts
Transcript
it's time to play webdev trivia three of us web developers are going to take our best guests at a series of web development questions my name is Wes my name is Scott I'm CJ hello all right question what percentage of devs reported writing more typescript than JavaScript in 2024 the options are a 38% B 56% C 67% or D 78% I think I know cuz so this is from the state of JS survey and I got in a Reddit argument about the answer to this so but it being multiple choice is actually harder because there are two here that are very close and I could have guessed in the middle all right are you guys ready I'm ready I'm saying C 67% d d i feel like it's higher than 67
but I don't feel like it's 78 I 67 and the answer is C 67% I'm here for the downfall of CJ's uh total Victory those redditors got in my head man I I was going back and forth I was like look at the survey results what are you talking about I wonder I wonder like what percentage of it is in other areas you know cuz like people that are taking a JavaScript survey are obviously very excited about the future of JavaScript yeah well if you look on Reddit every person uh uses Firefox despite it having what 2% usage every yeah like the Reddit is like totally skewed all the time so they they have their their ways of doing things for sure for sure all right next up uh which testing tool despite being fourth in usage topped the interest retention and overall positivity rankings in 2024 yeah your options are vest jest Cyprus or mocha I'm locked in already you're locked in okay I have to think about it
because I was focused on my Speech cuz I got my wisdom teeth out like six days ago this are the most words I've said our our whole team is like barely hanging on here I'm con cuss CJ has wisdom teeth taken out Randy got the stomach flu oh man we are we're we're healthy we're a healthy Bunch right now well I'm just a specimen of health so nothing wrong with me here yeah yeah Wes you're next it's uh it's a going to happen yeah I know the answer to this this is one of those things I read it without even understanding what I was reading I know the answer all right ready hey vest it's got to be yeah v test is taking over man everybody who uses it is just like oh yeah this is way better v test is awesome definely zero config yeah it's it's all the things that we love about uh V it honestly makes me write more tests because between I don't know if anything can do that for me but yeah but between the like the hurdle to like adding tests to a project that doesn't have it is
nothing and the fact that you can scaffold out all of the tests with uh AI is you can you can get some very good tests very quickly taking the time to not write tests is not so much of an excuse I'll still use it but not so much of an excuse anymore easy oh yeah we just assumed we got it all right yeah yeah yeah you gave the whole spiel about why v test was the best without even knowing we had the answer next question which JavaScript feature are people most excited about in the new proposals temporal API decorators pattern matching or records and tupal I know this one cuz Scott and I have been talking about on the podcast for like 16 years and I cannot wait for this to be in all of the browsers and all the run times ready a temporal and the answer was temporal API uh which makes a lot of sense cuz it's
going to replace a lot of libraries like momentjs and date function so yeah so the score is Wes with three uh yours truly with three and CJ oh with two oh so sorry CJ we feel so bad for you that you're not in first place this time if you don't want to be in the last place with site reliability and uh coding issues and problems on your site your site SJ of websites yeah you don't want to be CJ of websites no you you want to use Sentry Sentry .io and in fact centry just added uptime monitoring something that you know I've always had to bring in a third party that's not something I'm already using for uptime monitoring so the fact that all my stuff's already in Sentry now I get uptime monitoring big fan of that that way I can make better than updog monitoring yes so much better than updog monitoring I'm not giving into that I
come on all right next question which package manager while not being the most used had the highest retention rate in 2024 we're talking retention the options are npm yarn pnpm or bun not the highest I have my answer and it's just honestly it's just what I use cuz I think I started using it more last last year Well you you're you're kind of giving away here do you know you guys know what I used um no that means you'd have to watch my videos I would assume you use pnpm but I I feel like the answer to this is bun all right I'm locked in are you ready yeah go pmpm see I'm saying West a Jacka Lantern Jack it's the bun logo it's the bun logo it's beautiful wh thank you it
looks like a it looks like an onion or a a garlic clove with eyes thank you it's a it's a um what do you call those Chinese bun yeah yes pnpm I should have guessed that I guessed it specifically because yeah people tend to to like it when they use it and it's like it doesn't cause that many TR troubles if you end up using it so it's like you try it out it's smaller it's faster and then why would you yeah go back yeah like I think beginning of the last year last year I was using npm then I switched to pnpm and now most most of the open source projects I come across especially like tools and libraries they have a PPM lock file like they a lot of of the open source ecosystem has switched to pnpm too yeah I'm at a point now where if something uses yarn I'm like I I run into issues when it's yarn and I never run into I rather just straight up npm or pnpm all right next
up got a code quiz going to like this in the console it's an iffy uh immediately invoked functional expression y yes all the time yeah all right so your potential answers are so it's it's logging out type of a and then type of B so your answers are undefined undefined number and number undefined and number or number and undefined so what is the type of a what is the type of B this sucks I don't know the syntax I'm I'm really good at this I'm going to get I love these little obuse scoping questions okay you gave me a hint Wes cuz we are talking about scope here cuz that's inside of function so I have an answer but I think code will actually error out and not run at all can I okay let let's before we get the answer let's let's give our our opinions on what why we think it is that so why do you think it's going to error CJ uh because when you hit type of a
it's not in scope and so I guess if you're in strict mode uh if there isn't a variable in scope you'll get a uh can't resolve uh or like a is not defined if you're not in strict mode then it would just uh those variables question what's the environment yeah I mean if we're if it's just the code here it's not strict mode so it would be yeah okay yeah let's reveal our answers first hold on I think it's going to be if you run this in the console which I think it is because of the the syntax highlighting it's going to be undefined and then number because a is scoped to the function but B is not but is it oh that is no oh no no you're not declaring the variable B inside of the function therefore it is hoisted to the global scope think number that's what I think yeah my thought is it stays within the scope of the
function which means after the functions and both they're both undefined but that could be it VAR a comma B declares two variables A and B inside of the function VAR a equals B is not declaring two variables it's declaring A and B is not declared and when you are not in strict mode you're allowed to do that I'm really upset because I think Wes is correct yeah I think the answer is don't write code like this yes I wrote a two two undefined I saying undefined and [Music] number yes Wes I the moment you gave your explanation I knew I was wrong because the moment you said B is not in the scope I was M yeah yeah but if it's trick mode this would throw an error cuz B is not defined and then also like a is not defined which HTTP header is used to prevent cross-site scripting otherwise known as xxs xss attacks by specifying
which Dynamic resources are allowed to load content security policy uh X content type options strict Transport Security or XF frame options that's I know this one very easily because actually I'm not going to let Scott get the answer by explaining it again yeah you got to give me a chance I got it wrong last time by you explaining CU I already gave my answer so all right got my answer in all right it's a Content security policy I'm saying I also said a Content security policy we have very good episode from with Alex ston who was like one of the very early employees at stripe and he talked all about content security security policy and what's allowed to be embedded into a website yeah you come across this too when you're building like electron apps because electron gives you a browser window but you want to prevent potentially loading external scripts or going to external websites
because that could be a security issue if like inside your desktop app like that it would not be good if you're inside of like slack or Discord and all of a sudden you're on some other website so those those apps have a CSP that prevent external scripts from being loaded in all right which JavaScript feature allows for nonblocking IO operations a event Loop B web workers C promises or D set time out um oh man I think I know the answer that this is going for yeah but technically multiple of these things allow that but the same thing because of other mechanisms but I think one of them like like is clearly this thing so that's what I'm going to go with all right you ready yep I'm ready oh y I'm going to say I'm going to say promises but the way that promises work is that they put stuff onto the event loop I
said web workers web workers yeah so yeah my logic there was like web workers literally don't execute on the main thread so it's non-blocking promes can access native apis that are non-blocking but a promise itself is still technically in the main thread same thing for anything put on set timeout like like technically the work inside of set timeout could call something in the browser that is a native API that's non-blocking but I I also really wanted to say event Loop because the reason why Ryan doll chose JavaScript for node.js is because it was non-blocking IO and that was that's the talk if you go back and watch the the talk from Ryan doll is he says JavaScript is a good use case for non-blocking Io and at the time promises were not a part of the JavaScript language so it should be a but I'm I'm sticking with C if it's a that these all work inside of the event loop I don't you're not going to even consider web workers yeah if the answer
is not B then I am leaving I'll see you all yeah that's definitely not B all right let's get give us the answer event loop I don't I don't I don't wait you give me that one right well no you said what did you say you said did you say I said c but the event and then I went on a history lesson explaining why freaking JavaScript was chosen as a hold on what you can't do is you can't you can't give one letter and one answer that are different to to safegard I wrote event Loop right here look it you said c but the event Loop you uhhuh rewind the tape Randy I'm going to say I'm going to say promises but the way that promises work is that they put stuff onto the event Loop this one's a wash it's a wash I think it's a wash because no it's not a wash I get a half a point how is web workers not correct Wes because web workers are not the feature that allow that stops non-blocking IO operations it didn't say
what is the feature the reason why JavaScript is non-blocking is because it it it cues things up and it sticks it into the event Loop it doesn't stay there and wait for that thing to be finished but listen the the sentence is which feature allow which JavaScript feature allows for which web workers does is a JavaScript feature that does allow for this where like the question isn't what allows JavaScript to be non-blocking which in case your answer would be then in fact you know I have the definitive thing that will just NX this entire question the event Loop is not a feature the event Loop is oh yes JavaScript it's not a feature it's not a feature true that is true yeah that is fair because like there's no event Loop API right yeah I mean except for like set timeout or set interval technically those allow you to put functions onto the event Loop but the event Loop itself yeah but like you couldn't you can't like get the event Loop unless you have like a lower level so we will give Wes a
point for uh giving C and then the wrong answer and then we will also give CJ and uh Scott a point for giving a a half a point no an actual correct answer all right half a point all right next up in web performance what is the primary purpose of the re preload in a link tag a load CSS files asynchronously B prioritize loading of critical resources C defer the loading of non-critical resources or D establish early connections to required Origins man this is another thing we just did a show on I'm pretty sure I see two decent answers up here mhm okay I said D establish early connections I'm going with d uh yeah establish early connections and then Wes is wrong with prioritize loading of critical resour resources yeah but why do why do you think that was Rel of pre there's there's preload and prefetch and both of those will
download the the assets and preload will not parse the returned assets so if you are pre-loading CSS the browser is not parsing it is simply downloading it but prefetch will parse it out um and then there's also some distance sry Chang is in the speculation API which now allows us to do this as well I saw the word pre and didn't read the rest of the word I had also the wrong feature I I thought this was preconnect uh which is also real preconnect on LinkedIn preconnect is the just the DNS uh lookup doesn't it establish an early connection prect that's what I'm saying that that's why I wrote D cuz I I so what so am I right in in b [Music] yes got it yeah so this is the last question I could only win if there were
some interesting things at play here so what we're going to do is we get to bet points we get to wager how many points we want this next question to be worth Jeopardy rules right you can only wag four of my six and a half points I'm going big or going home I'm wagering 5.5 baby same I'm I'm going going all all the way 4.5 all my points all right the question is the CSS selector what does the CSS selector below Target the answers are a the first a element inside of a div B the first P element inside of the div C all a elements with hre attributes starting with https and D an element that is the immediate sibling of the first P child of a div where the A's H ref starts with https what a sentence holy [ __ ] uh let me now that I've said all that let me
actually read this and uh take a look at this I just have to remember what all these symbols mean cuz I this I always I always have to look up the less than the plus but I I think I know I think I know yeah what they mean are you guys ready no this one's so easy well I'm writing it all out and then I'm going to go back and look at the multiple choice and see if my answer is up there all right are we ready we locked in ready I wrote D an element that is the immediate sibling of the first P child of a div where the A's AG ref starts with https Wes doesn't get the points because he didn't show his work he just wrote The Answer down no because I just know how CSS works you you grabot the whole answer you grab the direct descendants that are paragraphs then from those direct descendants that are paragraphs you only grab the first one uh then you look at the first sibling next to that paragraph and you check if it is an anchor link and also you're checking if the HF
attribute starts with HPS yes yep perfect um and so because of that Wes you wager you had uh 6.5 and you wagered four which means you have 10.5 well I had 5.5 and I wagered 5.5 that means I have AED shoot out of nowhere and what about CJ uh who cares loses again typical what did you wag your CJ 4.5 I have nine at 92 oh nice nice W what an ending yeah I'm still sour about the event Loop one though I feel like I it will chat can you please tell me that I should have won this web workers is totally valid is not you should have lost a point for choosing notat thanks everybody for watching uh subscribe to this channel we do fun stuff like this all the time we also have a podcast on Mondays and Wednesday days and CJ has been creating a ton of deep Dives explainers and just
all around in-depth JavaScript coverage so smash that subscribe button do all that stuff as always thank you so much for watching and check out one of these other episodes and uh give it a click and you might like it
Quote it with credit and a link. Quoting Syntax