5 MORE Must Know JavaScript Features That Almost Nobody Knows

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ก.ค. 2024
  • 🚨 IMPORTANT:
    JavaScript Simplified Course: javascriptsimplified.com
    Part One: • 5 Must Know JavaScript...
    JavaScript is a vast language with tons of features and it is impossible to know them all. In this video I will be covering 5 more features in JavaScript that nobody knows but are incredibly useful.
    📚 Materials/References:
    Tagged Template Literal Article: blog.webdevsimplified.com/202...
    Dynamic Module Imports: blog.webdevsimplified.com/202...
    Generator Function Article: blog.webdevsimplified.com/202...
    ES6 Module Video: • JavaScript ES6 Modules
    🌎 Find Me Here:
    My Blog: blog.webdevsimplified.com
    My Courses: courses.webdevsimplified.com
    Patreon: / webdevsimplified
    Twitter: / devsimplified
    Discord: / discord
    GitHub: github.com/WebDevSimplified
    CodePen: codepen.io/WebDevSimplified
    ⏱️ Timestamps:
    00:00 - Introduction
    00:24 - Block Statements
    03:36 - in Keyword
    05:49 - Template Literal Functions
    11:12 - Generator Functions
    14:57 - Dynamic Module Imports
    #JSTips #WDS #Top5JS

ความคิดเห็น • 363

  • @IceMetalPunk
    @IceMetalPunk 3 ปีที่แล้ว +192

    One fun note: generators are the foundation of async/await syntax. Under the hood, when you create an async/await function, the JS engine creates a recursive generator where all the awaits are converted into yields, and the promises you're awaiting get a .then tacked on which calls the generator's next() method. Without generators, async/await wouldn't be possible :)

    • @whoman7930
      @whoman7930 3 ปีที่แล้ว +4

      where can i learn more?

    • @spacedoohicky
      @spacedoohicky 3 ปีที่แล้ว +3

      @@whoman7930 Look up the "co" module. It's on npm. Look at its source on github. That's how it works. The module "co" is a weird early version of doing async/await before async/await existed.

    • @AlexFord
      @AlexFord 3 ปีที่แล้ว +26

      @@whoman7930 It is rumored that high up in the mountain valley there is a guru. One who has been trained in the ancient arts. The journey is perilous but those who reach him are blessed with the gift of his knowledge. Good luck.

    • @whoman7930
      @whoman7930 3 ปีที่แล้ว +3

      @@AlexFord LOL thank you

    • @karthikkhoday5555
      @karthikkhoday5555 3 ปีที่แล้ว +4

      @@AlexFord 🤣🤣

  • @StevenHoodlebrink
    @StevenHoodlebrink 3 ปีที่แล้ว +28

    That dynamic import part was mindblowing. I can see it being useful when you're making API calls to refresh the data of an application. There are many instances where the source is only updated weekly or monthly so instead of making API calls with every load. You could do some date checking first and then refresh the data if it is out of date. Great stuff as always Kyle!

    • @sidharthsid3429
      @sidharthsid3429 3 ปีที่แล้ว +2

      Yeah, you're absolutely right ..Great use case

  • @deonrich3149
    @deonrich3149 3 ปีที่แล้ว +102

    the curly bracket thing is super cool, never knew that!

    • @michael6955
      @michael6955 3 ปีที่แล้ว +1

      Same xD

    • @TheRealCAPerry
      @TheRealCAPerry 3 ปีที่แล้ว +1

      Also same

    • @lawrencedoliveiro9104
      @lawrencedoliveiro9104 3 ปีที่แล้ว +3

      It’s a standard feature of block-structured languages, like C. Which in turn copied it from old Algol.

    • @bennybar
      @bennybar 3 ปีที่แล้ว +1

      I've used that with switch statements for a while, just never thought why it worked :)

    • @KasuraIchimaki
      @KasuraIchimaki 3 ปีที่แล้ว +1

      me neither... super weird that you could use brackets like that

  • @CodingNuggets
    @CodingNuggets 3 ปีที่แล้ว +16

    Glad you're continuing on with these. Definitely learning a thing or two that I didn't know. Much love as always Kyle. See you soon!

  • @ahmaddynugroho
    @ahmaddynugroho 3 ปีที่แล้ว +62

    “Example isn't another way to teach, it is the only way to teach." - A. Einstein

    • @chrisual
      @chrisual 3 ปีที่แล้ว +3

      '98% of A. Einstein quotes were not said by A. Einstein' - A. Einstein

    • @sovietbot6708
      @sovietbot6708 2 ปีที่แล้ว

      Fun fact: Einstein was a socialist who supported the Soviet Union.
      I'm not using the word socialism the way right wingers use it. I mean he literally called himself a socialist. He even wrote a book called "Why Socialism"

  • @christophalbrecht1088
    @christophalbrecht1088 3 ปีที่แล้ว +4

    Loving it! supposedly simple things like scopes open up completely new possibilities. Thx for your videos I'm always inspired

  • @szpaklabs8893
    @szpaklabs8893 3 ปีที่แล้ว +1

    great examples! finally I understood the purpose of the generator functions.
    dynamic import is also very useful, thank you!

  • @danvindsouza2725
    @danvindsouza2725 3 ปีที่แล้ว +6

    Nice Video Kyle! Enjoyed it like most of them!
    5:40 The in operator also looks at the prototype chain. Using object_name.hasOwnProperty(property_name) will search only for that property within the object. But in operator will search for the property within the object and if not found will search the prototype chain. In certain cases we need to consider that.

  • @ritudey8520
    @ritudey8520 3 ปีที่แล้ว

    Love your explanations. Simple, short and clear. Thanks🤍

  • @michakwasiuk1731
    @michakwasiuk1731 3 ปีที่แล้ว

    You are awesome kyle! Looking forward to your javascript course!!

  • @ro1942
    @ro1942 3 ปีที่แล้ว

    Wow the generator function knowledge blew my mind out of the back of my head and through the drywall into the garden! Insanely useful , thank you Kyle!

  • @tezdogs
    @tezdogs 3 ปีที่แล้ว

    I only started writing JavaScript about 2 or 3 months ago and these videos are absolute gold! Liked, subscribed, and a comment for the algorithm.
    Keep up the great content man! Love your work

  • @Rodo1802
    @Rodo1802 2 ปีที่แล้ว

    I cannot get enough of your knowledge and clarity. You are a saviour in all its dimension!

  • @sesho777
    @sesho777 3 ปีที่แล้ว

    You are the best at explaining confusing stuff in a simple way, thanks man!

  • @stoneshou
    @stoneshou 3 ปีที่แล้ว

    this is so good! right on point when i'm looking for a way to postload some modules.

  • @JimRooney
    @JimRooney 3 ปีที่แล้ว

    Always such quality content! Love your work mate.

  • @liondeluxe3834
    @liondeluxe3834 3 ปีที่แล้ว +8

    Template literal functions is really useful. I wish I knew before because I can now use it to sanitize user generated inputs for dynamically rendered content

  • @nfarruggia
    @nfarruggia 3 ปีที่แล้ว

    Your videos are insanely helpful! Keep it up!

  • @xXYourShadowDaniXx
    @xXYourShadowDaniXx 2 ปีที่แล้ว +1

    That id generator example was great, very intuitive use case!

  • @duanemcdonald6960
    @duanemcdonald6960 3 ปีที่แล้ว

    Kyle, you are so effective, helpful and concise. Please don't stop.

  • @IkraamDev
    @IkraamDev 3 ปีที่แล้ว +1

    I'm currently working on a Todoist clone and I never use Switch Statements, but when you mentioned it, I was literally working on a perfect part of the app to add a Switch Statement!

  • @mohannadize
    @mohannadize 3 ปีที่แล้ว

    I have seen and used the tagged template literal syntax in developit/htm and have always wondered how it works but i didn't find the docs for it. Thank you so much for the tips! ♥️

  • @yeahyeahduderooski
    @yeahyeahduderooski 3 ปีที่แล้ว

    Love the import() info at the end! Our pages are full of stuff so this will help speed up the code our team owns

  • @allthingsdev4071
    @allthingsdev4071 3 ปีที่แล้ว

    Thanks for explaining things to people whom have little prior coding experience. Every detail counts

  • @88spaces
    @88spaces 2 หลายเดือนก่อน

    Generator functions are new to me. I'm glad you covered this.

  • @WeaselBass
    @WeaselBass 3 ปีที่แล้ว +4

    Those are some awesome things I'm going to immediately forget the next time I have to write any JavaScript...

    • @brhh
      @brhh 3 ปีที่แล้ว

      press Y for S ame

  • @tajuddinkhan5206
    @tajuddinkhan5206 3 ปีที่แล้ว +2

    It's just amazing that you are able to explain these concepts so easily.

    • @brhh
      @brhh 3 ปีที่แล้ว

      such an amazing teacher isn't he!

  • @patrickc.6183
    @patrickc.6183 3 ปีที่แล้ว +69

    Dynamic imports are a very cool feature! Definitely useful, but not well known 👍.

    • @lawrencedoliveiro9104
      @lawrencedoliveiro9104 3 ปีที่แล้ว +2

      Interesting that, in Python, all imports are dynamic; you can put a regular “import” statement inside a function or class if you want.

  • @i3looi2
    @i3looi2 3 ปีที่แล้ว

    Berry nice. I think I have a use for the generator function in one of my projects.
    Also the dynamic imports.
    Thanks.

  • @johnkeck
    @johnkeck 3 ปีที่แล้ว

    Great stuff! Thanks so much!

  • @jimmyj.6792
    @jimmyj.6792 3 ปีที่แล้ว

    Awesome tips discovery. Thanks a lot for this 👌

  • @rachidb9624
    @rachidb9624 2 ปีที่แล้ว

    Generator function looks interesting, first time hearing about it, thanks mate !

  • @reyanrahman
    @reyanrahman 3 ปีที่แล้ว +4

    U always comes up with something new every time

  • @jojok427
    @jojok427 ปีที่แล้ว

    Dang, how did I not know half of these... this was incredibly helpful! Thank you!

  • @AlexFord
    @AlexFord 3 ปีที่แล้ว +6

    In the generator you could have just done `yield id++` since the ++ executes after the yield statement. You probably already know this but just in case, you can also reverse that syntax (`yield ++id`) to ensure the ++ executes *before* the yield statement :)

  • @rejinraghavan7616
    @rejinraghavan7616 3 ปีที่แล้ว

    Hey Kyle.. Came across your videos recently.. I really like it.. It's concise and informative.. :)

  • @88spaces
    @88spaces 2 หลายเดือนก่อน

    I've been watching videos of JS things I've never heard of, and the dynamic import feature blows me away. This is truly a game changer.

  • @MrBroady02
    @MrBroady02 3 ปีที่แล้ว +1

    I like to click these on the off case that I may learn something. Today I learned 3 things. Nice work!

  • @AymanAliAli
    @AymanAliAli 3 ปีที่แล้ว

    I really enjoyed this video. Thank you for the time you spent carefully planning for it.

  • @aeronwolfe7072
    @aeronwolfe7072 ปีที่แล้ว

    Great stuff. Thank you sooo much man!!!!

  • @Paul-xg1fr
    @Paul-xg1fr 3 ปีที่แล้ว

    Very interesting with template strings🤯. Thank you!

  • @Nyco3D
    @Nyco3D 3 ปีที่แล้ว

    Best advice is the dynamic module import, life saver!

  • @DewieTheBard
    @DewieTheBard 3 ปีที่แล้ว

    I watched the last video and a few days later I used one of those features. Thank you for making great content

  • @sohammondal578
    @sohammondal578 2 ปีที่แล้ว

    Wow so much content in just 20 mins. Brilliant. ❤️

  • @ganeshbabu6458
    @ganeshbabu6458 3 ปีที่แล้ว

    Your channel is awesome. Keep us educated as usual👍

  • @dabbopabblo
    @dabbopabblo ปีที่แล้ว

    For years now Ive been appending scripts to the body and listening for their load event, realizing import() is a thing is a literal game changer

  • @hamidmohamadi2943
    @hamidmohamadi2943 3 ปีที่แล้ว

    Great kyle as always. Thanks a lot

  • @webgeeks9090
    @webgeeks9090 3 ปีที่แล้ว

    Very informative . dynamic import , curly brackets and generator func
    We need more examples and use cases about these features it will be useful too
    Thanks Kyle

  • @CotyCondry
    @CotyCondry 3 ปีที่แล้ว +2

    these are really good, I think I actually understand generators now.

  • @HuoShengChiou
    @HuoShengChiou 3 ปีที่แล้ว

    This video gives me new knowledge. Thank you

  • @sapindersingh1165
    @sapindersingh1165 3 ปีที่แล้ว

    Kyle definitely knows what things I'm ignorant of. That's why he pushes my javascript level further every time.

  • @stanislavmalyshev5209
    @stanislavmalyshev5209 3 ปีที่แล้ว

    Top content!
    Thank you :)

  • @christianfreund2039
    @christianfreund2039 3 ปีที่แล้ว +1

    Hi Kyle,
    I was mesmerized when you moved the brackets down in the switch-statement example. Can you show how you did that? Or even better: Wouldn't it be a nice topic for a video? Keyboard tricks for faster work in VS Code

  • @letieuanh8698
    @letieuanh8698 2 ปีที่แล้ว

    That Generator explanation is god damn helpful with me, thanks!

  • @devrxt10
    @devrxt10 3 ปีที่แล้ว

    thanks for this video. keep making videos like this

  • @AlanD20
    @AlanD20 3 ปีที่แล้ว +1

    WOW, that's amazing :) I feel like the generator function is pretty useful for building a linked list or binary trees and other algorithms. definitely makes thing easier.

    • @Lokus122
      @Lokus122 3 ปีที่แล้ว

      I think It would also fit nicely to create some loading screen with progress bar if function takes a lot of time

  • @Tuuhwix
    @Tuuhwix 3 ปีที่แล้ว

    Time to refactor my code! For the dynamic module import. I recently had to use require() because I wanted to put a template literal based on the name of file. But now I think I'm going to change it to the way you showed us 🙂
    My example:
    for (const file of myFiles) {
    const myModule = require(`./foldername/${file}`).default
    // more code done with myModule...
    }

  • @BrandonNozakiMiller
    @BrandonNozakiMiller 3 ปีที่แล้ว

    I am impressed with your knowledge of archane JS. I didn't know one or two of these.

  • @patcodingcodester9781
    @patcodingcodester9781 3 ปีที่แล้ว

    DUDE the curly brackets thing comes up with me using state management. the reducer switch statements always got me with this. I'd end up having the most dumb names for new objects and arrays because my naming convention was always impacted. So clutch!

  • @ms77grz
    @ms77grz 3 ปีที่แล้ว

    That curly braces thing is so called block scope in JS (ES6) scoping and applies to variables declared via const and let. Functions are also block scoped (in strict mode)

  • @vincentjohnflorio
    @vincentjohnflorio 3 ปีที่แล้ว

    I get ragged on constantly for talking too fast; once I taped a kind of infomercial and they needed four takes at one point to get useful footage because even me purposely slowing myself down left them clueless at how to make me clearly enunciate.
    So I really appreciate that I can hear and understand you perfectly fine at 2x speed. It saves me time but also means that you're not losing people like I am with my meandering babble speed.

  • @HakunaMatata-it2qr
    @HakunaMatata-it2qr 3 ปีที่แล้ว

    I love this feature series..!🔥🔥

  • @graemekalb2292
    @graemekalb2292 3 ปีที่แล้ว

    DEFINITELY using the in keyword, thank you!!

  • @scheimong
    @scheimong 3 ปีที่แล้ว +2

    The generator function in JavaScript is semantically similar to the concept of "lazy iterator" in other languages, in particular Rust.
    I'm mentioning Rust by name because it's not until I learned this language that I was able to fully appreciate how powerful iterators can be.

  • @dasten123
    @dasten123 3 ปีที่แล้ว

    Crazy good video!!!

  • @ianterada6821
    @ianterada6821 3 ปีที่แล้ว

    The template literal section was really interesting!

  • @berkaybakacak
    @berkaybakacak 3 ปีที่แล้ว

    Thanks for theese useful informations 😁

  • @exodustx0
    @exodustx0 3 ปีที่แล้ว +2

    Might have been useful to point out that generator functions can be iterated through with a for-of loop too. That's easily my favourite way of using them.

  • @hamzac.4555
    @hamzac.4555 3 ปีที่แล้ว

    good job, keep it up !

  • @avi12
    @avi12 3 ปีที่แล้ว

    Back in the day, when I was using switch statements, I put the { } because I thought they were necessary, as I came from C# and I've seen switch statements with { } for each case
    Thanks to you, I realized it works because each { } block is basically a nested scope

  • @antoniorivera6014
    @antoniorivera6014 3 ปีที่แล้ว

    So useful!

  • @SergeofBIBEK
    @SergeofBIBEK 2 ปีที่แล้ว

    I've used the template literals to handle adding the optional s based on the count. Pretty clean compared to some ternary if or something in the string itself.

  • @NickoSinclair
    @NickoSinclair 3 ปีที่แล้ว +1

    Cool video, just a slight bugbear of mine: doesn't make it more semantic, if anything you made it less semantic. Stick with in that context. Strong doesn't simply make the text bold, it strongly emphasizes it.

  • @chaitanyavarma2283
    @chaitanyavarma2283 3 ปีที่แล้ว

    Very useful👌

  • @chlbri
    @chlbri 2 ปีที่แล้ว

    the "in" keyword to validate an object is awesome

  • @nitsanbh
    @nitsanbh 3 ปีที่แล้ว +18

    “When you have a specific use case for them, they are really useful”
    Well I can’t say that’s untrue

    • @brhh
      @brhh 3 ปีที่แล้ว +1

      out of all the ways you could've said false, you chose the one that doesn't relate to programmers, F

  • @jaideepshekhar4621
    @jaideepshekhar4621 3 ปีที่แล้ว +1

    For the template literal functions, I prefer them like this:
    const user_profile = (firstName, hobby) => `

  • @josebarrera9346
    @josebarrera9346 3 ปีที่แล้ว

    Bro thank you so much. Not joking yesterday I was like 2am not knowing how to fix my Code... had a weird error inside a switch sentence. Ended up refactoring into if-else and now i know what the problem was. Thanks truly

  • @Vishalkumar-vj7hx
    @Vishalkumar-vj7hx 3 ปีที่แล้ว

    Awesome explanation . Your new subscriber

  • @artgreg2296
    @artgreg2296 3 ปีที่แล้ว

    Thanks Kyle. I was knowing all of them. Did you mention delegator generator?

  • @HosamSultan
    @HosamSultan ปีที่แล้ว

    3rd time I watch this video, and, Man! So many new things I get every time!!

  • @mybluemars
    @mybluemars 3 ปีที่แล้ว

    Hi Kyle, I just wanted to say that your logic and teaching style is very good, and I am not a programmer!

  • @axiezimmah
    @axiezimmah 3 ปีที่แล้ว +1

    yield is actually something I did not know. nice

  • @nept1187
    @nept1187 2 ปีที่แล้ว

    INCREDIBLE FOR DYNAMIC IMPORTS

  • @aashiqahmed5273
    @aashiqahmed5273 3 ปีที่แล้ว

    dynamic import are dope man

  • @DaggieBlanqx
    @DaggieBlanqx 3 ปีที่แล้ว +2

    Wow! Just wow! Nothing more... just another wow!

  • @GamBar64
    @GamBar64 3 ปีที่แล้ว

    So good!

  • @rohithchittibommala2002
    @rohithchittibommala2002 3 ปีที่แล้ว

    Kyle it would be much appreciated if you can make a video on decorators in typescript

  • @I-just-hold-white-paper-up
    @I-just-hold-white-paper-up 3 ปีที่แล้ว

    This episode is incredibly useful

  • @sarwankumar5339
    @sarwankumar5339 2 ปีที่แล้ว

    I liked the one about dynamic import and checking if a property exists in an object

    • @sarwankumar5339
      @sarwankumar5339 2 ปีที่แล้ว

      Is going to use this in our project

  • @ngneerin
    @ngneerin 3 ปีที่แล้ว

    You could use continue instead of if block

  • @user-fu6kf1yk2o
    @user-fu6kf1yk2o 3 ปีที่แล้ว

    I knew every of this feature, and I wont really use any of them)
    Well maybe except 1st and last examples, I think they are awesome.
    Thanks for video

  • @ehtishamtahir2187
    @ehtishamtahir2187 3 ปีที่แล้ว

    That curly bracket trick👌👌👌

  • @kitsunekaze93
    @kitsunekaze93 3 ปีที่แล้ว

    5:45 "cant do any other way" can do: *if ( person.hasOwnProperty('name') )*
    also userful for stuff like: for ( let key in array )
    can also loop over the values: for ( let val of array )

  • @Gigatless
    @Gigatless 3 ปีที่แล้ว +2

    That's pretty sick bro good job. Can you make a vid about what a starting JS programmer can do between finishing a course/writing his first app and finding a job? Talking about finding a way to apply skills and maybe making some money along the way. Someone mentioned contributing to real projects on github but I can't find that video and how to do it.

    • @Californ1a
      @Californ1a 3 ปีที่แล้ว

      For contributing to projects on github, check out CodingGarden's "How to Contribute to Open Source Projects" video. It's a livestream past broadcast, about 3 hours long, but he goes through the entire process of finding a project, going through all their contribution guidelines, finding an issue to work on, cloning the repo, running the tests, reproducing the issue locally, and tracking down the cause of the issue plus a little bit of trying to fix it.

    • @Gigatless
      @Gigatless 3 ปีที่แล้ว

      @@Californ1a thanks!

  • @anonymously94
    @anonymously94 3 ปีที่แล้ว

    And here I was, thinking I knew all there was to JavaScript. Silly me.
    Thank you for sharing. Very helpful

  • @devashishbahri3353
    @devashishbahri3353 3 ปีที่แล้ว

    Can you please tell which extension of VS Code are you using which is dynamically striking through code and also graying out condition statements if they are false?

  • @zulfikarahmad3684
    @zulfikarahmad3684 3 ปีที่แล้ว

    Thanks kyle, please make another video like this ^_^

  • @manishneog9595
    @manishneog9595 3 ปีที่แล้ว

    Your videos always helps me a lot ❤️ love from INDIA

  • @nithinkottary9578
    @nithinkottary9578 3 ปีที่แล้ว

    please make such types of videos more