21 LIFE CHANGING JavaScript tricks

Поділитися
Вставка
  • Опубліковано 3 сер 2024
  • Freelance Coding is the way in 2024! Learn How: www.freemote.com/strategy
    / aaronjack
    #coding #programming #javascript
  • Наука та технологія

КОМЕНТАРІ • 163

  • @jaimerojas6578
    @jaimerojas6578 4 роки тому +26

    Man your JS Cheat Sheet is the most gorgeous thing I've seen in a while, so compact, concise and good looking OMG Loved It!

    • @sakshampethkar8970
      @sakshampethkar8970 3 роки тому

      I can't download it. It isn't taking my gmail

    • @aashiqahmed5273
      @aashiqahmed5273 3 роки тому

      Pls gimme the link here

    • @rylandreuben2250
      @rylandreuben2250 2 роки тому

      i dont mean to be so offtopic but does someone know a trick to get back into an instagram account??
      I was stupid forgot the login password. I would appreciate any assistance you can offer me!

  • @bawad
    @bawad 4 роки тому +150

    my favorite life changing JavaScript tip:
    yarn add -D typescript

  • @I_am_Alan
    @I_am_Alan 4 роки тому +56

    1:00 - Local Storage
    2:08 - Session Storage
    2:30 - document.cookie
    3:10 - Console Methods
    3:29 - Log Colors
    5:38 - Destructive Args

  • @migueldomingos4570
    @migueldomingos4570 4 роки тому +20

    One file if statements
    Vs code prettier: Let's make that multiline!

  • @PhilSmit
    @PhilSmit 4 роки тому +1

    Awesome content Aaron 👍
    Can't believe how much I've just learnt - thank you!

  • @cranklepuss
    @cranklepuss 4 роки тому +3

    Love these types of videos! I hope that you will also intermix some news item videos every now and then too!

  • @AS-if5jg
    @AS-if5jg 4 роки тому +1

    Yes yes yes!
    I was so freaking waiting to learn web scraping for long time, I'll be waiting eagerly to buy your course!!!! Thanks Aaron, you're the best!

  • @KeepOnCoding
    @KeepOnCoding 4 роки тому +3

    Thanks for sharing!

  • @tekforge
    @tekforge Рік тому

    I love your tips. Thanks for sharing!

  • @dansteryoo
    @dansteryoo 4 роки тому

    one of your best videos yet. thank you.

  • @xianghou9526
    @xianghou9526 4 роки тому +1

    Thank you Aaron, best gift ever :)

  • @DanielTateNZ
    @DanielTateNZ 4 роки тому +5

    Double ternary is easier to read when you wrap the second condition in parenthesis imo

  • @AbdulRahimntk
    @AbdulRahimntk 4 роки тому

    Thank you Aaron! It helps ❤️

  • @kishoreandra
    @kishoreandra 4 роки тому

    Fast , cool , informative straight to the point ..... Loved it

  • @Alex-xw5bc
    @Alex-xw5bc 4 роки тому +1

    Yes yes yes yessss!!! I am super excited you are finally making a web scraping course. Even better hat it’s with js

  • @osherezra8460
    @osherezra8460 4 роки тому

    Awesome Man keep it up great tips love it

  • @duckmasterflex
    @duckmasterflex 4 роки тому

    Love you dude btw, keep these up

  • @mxc_clips
    @mxc_clips 4 роки тому +1

    Great video, I work with JS everyday and its impossible to know/remember all these tricks. Keep up the videos like this!

  • @jaimerojas6578
    @jaimerojas6578 4 роки тому

    Wow had no idea of most of then, great content mate

  • @EnglishRain
    @EnglishRain 4 роки тому

    Amazing video, please keep making such javascript vids as well! Thou art awesome!

  • @MakeMoneyGuide
    @MakeMoneyGuide 3 роки тому

    Keep posting interesting contents like this!

  • @philippec4448
    @philippec4448 4 роки тому

    Awesome tricks ! Thanks !

  • @EnglishRain
    @EnglishRain 4 роки тому +2

    18:35 - That was the best part imo. The Dark Arts! Absolutely agree with you that those simple If statements cramming up 5-6 lines is sacrilege... that ternary trick is BEAUTIFUL. Next time please keep the dark arts right at the beginning! ;D

  • @georgechanturidze1409
    @georgechanturidze1409 4 роки тому

    5 minutes in... this is already gold.

  • @ead5590
    @ead5590 4 роки тому

    Downloaded the JS cheat sheet. Super clean, super helpful. Thanks a lot! 😆

  • @engboy69
    @engboy69 4 роки тому +3

    I'm only new to coding and the last tip blew my mind

  • @akshattamrakar9071
    @akshattamrakar9071 4 роки тому

    This is good, I learned a lot of stuff

  • @Gohel95
    @Gohel95 4 роки тому

    thanks for tips💕

  • @xRichhhx
    @xRichhhx 4 роки тому +1

    Well somebody's been playing Destiny 2 haha. Great vid btw!

  • @fabricio5p
    @fabricio5p 4 роки тому +1

    Nice vid fellow guardian

  • @elijah4840
    @elijah4840 4 роки тому +1

    Ayee, nice vid!! CSS tricks doe?

  • @sumedhdixit4771
    @sumedhdixit4771 4 роки тому

    Waiting for the web screpping course! Kudos!

  • @zee2823
    @zee2823 4 роки тому +1

    The last tip hit me the most. I remember my first job when I knew very little about js (still very little now), in the code base i saw few lines with at least 6 ? and : and wondered what the hell is that and where do I even start to read.

  • @mudandmoss4132
    @mudandmoss4132 4 роки тому +1

    You can use optional chaining in JS instead of the get function from lodash. To use it you do: objName.user?.address?.zipcode just use the ? before the dot notation to check if it's null

  • @AtizaJuanita
    @AtizaJuanita 4 роки тому +1

    Destructure logs😍

  • @FunOfHeuristic
    @FunOfHeuristic 4 роки тому

    Nice tricks, Thanks for sharing.
    For deep copy (if you don't have a circular reference ) then you can also use JSON.parse(JSON.stringify(obj)), this will also be going to do a deep copy and its pretty efficient.

  • @julianvazquez1435
    @julianvazquez1435 4 роки тому

    You just turned me into a lodash believer .

  • @veeker77
    @veeker77 4 роки тому +4

    12:40
    You can also add question mark at the end of each attributes, should work just fine too with the recent update of node ! (user?.profile?.fullName)

    • @Metruzanca
      @Metruzanca 4 роки тому +1

      I was also wondering why he did't use that, but I've got a feeling that its not browser safe yet and wont be for a while.

  • @sebastianberglund2604
    @sebastianberglund2604 4 роки тому

    Wow! Great video. Number 6 about destructuring logs was the best one for me. So much time spent writing good log messages. I wonder, is it possible to combine it woth number 5, so you can have destructured messages in a color you choose? That would be pretty nice! =D

  • @RusuTraianCristian
    @RusuTraianCristian 4 роки тому +1

    Knew them all. But then again, JS is my main language so that's normal. Good refresher though!

  • @dusannikcevic7771
    @dusannikcevic7771 4 роки тому +1

    Using lodash for every small problem could result in a huge bundle sizes. Especially when imported as you shown as a destructured object. This would be much preferred way if you are adamant in using lodash eagerly:
    import map from "lodash/map";
    this way, you only import what you really need, and not the whole library.
    Still cool video though, learned couple of neat tricks :)

    • @AaronJack
      @AaronJack  4 роки тому +1

      if you set up tree shaking correctly, only the functions you need will be imported
      stackoverflow.com/questions/48816704/lodash-not-treeshaking-with-webpack-with-webpack-4

    • @dusannikcevic7771
      @dusannikcevic7771 4 роки тому

      @@AaronJack if you mentioned that in your video then i apologize. If not, you should maybe in one of your next videos, so that the beginners know :)
      p.s upon further inspection of the link you sent i noticed that syntax for importing that they use in that thread is as follows:
      import map from "lodash/map";
      they are not destructuring object

  • @JustSkillGG
    @JustSkillGG 4 роки тому

    Aaron, what software did you use to create the javascript cheat sheet?
    Its really awesome!

  • @soorajkj1564
    @soorajkj1564 3 роки тому +1

    Deep cloning issuse can be fix using json Parsing and stringify

  • @kamranmalik1840
    @kamranmalik1840 4 роки тому

    Cheat Sheet is awesome :) Thanks :)

  • @migueldomingos4570
    @migueldomingos4570 4 роки тому +6

    The dark arts of javascript 🤣

  • @KevinTempelx
    @KevinTempelx 4 роки тому

    Thanks

  • @tylerjnewman
    @tylerjnewman 3 роки тому

    If you want to adopt latest features of native javascript, you can use optional changing instead of lodash get
    const adventurer = {
    name: 'Alice',
    cat: {
    name: 'Dinah'
    }
    };
    const dogName = adventurer.dog?.name;
    can also use nullish coalescing operator (??) for defaults
    this prevents unexpected behaviors if you consider some falsy values as usable (eg. '' or 0).
    there is also Logical nullish assignment (??=) which only assigns if x is nullish (null or undefined).
    const a = { duration: 50 };
    a.duration ??= 10;
    console.log(a.duration);
    // expected output: 50

  • @EnglishRain
    @EnglishRain 4 роки тому

    Wowwwwww JS web scraping can't wait!! :D

  • @geoffmahugu8983
    @geoffmahugu8983 4 роки тому

    Was really getting 😡 with the Ternary operator but having a second and a third look at it I started to appreciate how clean and straight forward it is.
    However, wouldn't try it without documentation 😸

  • @david-cn1xv
    @david-cn1xv 2 роки тому

    i love writing nested ternary operations specially calling methods or even anonymous arrow functions. can you please make another video like this going deeper? thanks

  • @predatorgr7311
    @predatorgr7311 4 роки тому

    One of the best typing saver is:
    const test = (something) => console.log(something) || (do something with something)
    This will log something without opening {}

  • @chris94kennedy
    @chris94kennedy 4 роки тому

    Time to start using lodash damn

  • @quigglebat
    @quigglebat 4 роки тому

    He's back. Fuckin a!

  • @MinNyeAccount
    @MinNyeAccount 3 роки тому +1

    When i have to make a deep copy of an object i use: JSON.parse(JSON.stringify( object )) ... that is if i dont need to import a lib like lowdash

  • @highzenburger1829
    @highzenburger1829 4 роки тому +12

    Would like to know what extensions/theme you're using.

    • @therevolution1482
      @therevolution1482 4 роки тому +2

      horizon theme I think

    • @highzenburger1829
      @highzenburger1829 4 роки тому

      @@therevolution1482 I'll check it out. Totally forgot about this. But if you guys want glyphs/ligratures Google "VSC with Firecoda"

    • @highzenburger1829
      @highzenburger1829 4 роки тому

      @@xorlop awesome thanks 😁

  • @AwkworldStudios
    @AwkworldStudios 4 роки тому +1

    You can make a deep copy of a JavaScript object using JSON.stringify and JSON.parse

  • @ahsansher
    @ahsansher 4 роки тому +3

    at 8:11 how are you showing those console.log within editor? Is it a vscode extension or you added in while editing video. Thanks.

    • @dawitg3898
      @dawitg3898 3 роки тому +1

      It's the Quokka extension

  • @greekgastone1
    @greekgastone1 3 роки тому

    Great video. One addition: What you described for lodash get , checkout Optional chaining and existential operator:
    www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#optional-chaining
    And a very good addition to your tips which all frontend developers has to know, is how to transform an object or an array of objects to another array of objects with different keys and values.
    For example:
    [
    {
    "code":1,
    "name":"test",
    "other":"test 1"
    },
    {
    "code":2,
    "name":"test",
    "other":"test 2"
    }
    ]
    to get another array like this:
    [
    {
    "id":1,
    "value":"test"
    },
    {
    "id":2,
    "value":"test"
    }
    ]
    which can also be done with object.assign and mapor Lodash. An example for such a task could be really useful.

  • @tomroberts8666
    @tomroberts8666 4 роки тому +1

    For the last console.log trick - using console.log({favoriteFood}) - there is a good reason to not use this sometimes..
    like if the output is written to a file instead of your console you will see the dreaded '[Object] Object]' log message instead of the JSON.stringified value that the chrome console outputs

  • @LabhamJain
    @LabhamJain 4 роки тому

    Can You Please Make Video On Debounce, Throttle If You Haven't Please...🙏🙏🙏

  • @kukuster
    @kukuster 4 роки тому

    Good luck working with people who freak out of such a double ternary operator...

  • @davidnuanez4716
    @davidnuanez4716 3 роки тому

    Man i remember seeing a double ternary operator as an ‘advanced’ solution in freecodecamp somewhere, may have even been a community solution, and i was like holy shit you can do that?! 😂 But it definitely seems really useful in some cases!

  • @doncoder13
    @doncoder13 3 роки тому

    21 Lodash changing tricks

  • @flaxEblax
    @flaxEblax 4 роки тому +2

    You can do user.profile?.fullName in vanilla JavaScript now

    • @sweatobertrinderknecht3480
      @sweatobertrinderknecht3480 4 роки тому +1

      thats right! no need for lodash, this is a new feature

    • @AaronJack
      @AaronJack  4 роки тому +2

      this is an ES2019 feature called optional chaining
      developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining
      though it's not supported in all browsers

  • @jdub1657
    @jdub1657 4 роки тому +1

    where can i buy my code drip tshirt or mug?

  • @braswelljr
    @braswelljr 4 роки тому

    What extension are using for showing your results in vscode

  • @JustSkillGG
    @JustSkillGG 4 роки тому +1

    I just love that guy
    Btw probably a nooby question, but does anybody know how to console.log at VS like Aaron does?

  • @GuilhermeTeixeira
    @GuilhermeTeixeira 4 роки тому

    Which extension do you use to display JS output in real time?

  • @rajeevsinxh
    @rajeevsinxh 4 роки тому

    What theme and extension you are using?

  • @saivivekravi4979
    @saivivekravi4979 4 роки тому

    Which theme are using in editor

  • @limpep
    @limpep 4 роки тому

    Great tips, but last one is a bit too dark for me 😅

  • @ofeenee
    @ofeenee 4 роки тому

    What extension do you have that allows you to preview the expected output/value?

    • @ofeenee
      @ofeenee 4 роки тому

      Is it the terminal running Quokka?

  • @codefallacy
    @codefallacy 4 роки тому

    bro you were MIA for a bit started to wonder if you moved again

  • @rp2804
    @rp2804 4 роки тому

    hate the email thing :( lovv channel though

  • @Champagnerushi
    @Champagnerushi 4 роки тому

    Xur location reference 👀

  • @albertoarriaga9611
    @albertoarriaga9611 4 роки тому

    What is the difference between debounce and setTimeout?

  • @ngx8967
    @ngx8967 4 роки тому +1

    What VS Code theme and font do you use?

    • @AaronJack
      @AaronJack  4 роки тому +1

      horizon + dank mono

    • @samfondacaro6674
      @samfondacaro6674 4 роки тому

      Lets goooooooo NG X getting a reply that’s pretty epic!!!!!!!!!!!!!!!!!!

  • @Yvefutura
    @Yvefutura 4 роки тому

    Lit

  • @fanatic5565
    @fanatic5565 4 роки тому

    15:12 JS has toUpperCase that works similar to lodash capitalize

    • @agoston_fekete
      @agoston_fekete 4 роки тому

      it's different cause toUpperCase sets every character to uppercase.

  • @sajadmalik9097
    @sajadmalik9097 4 роки тому

    how do u get result right there in vscode whenever you console things....
    It must be an extension that i would love to use... tell me plx

  • @DandHAdventures
    @DandHAdventures 4 роки тому

    Lodash is heavy. Optional changing with a ?? A better way. Const name = user?.name ?? “No name”

  • @scottknight8410
    @scottknight8410 4 роки тому

    You make me feel like I don't know shit.

  • @Metruzanca
    @Metruzanca 4 роки тому +2

    "reverse-destructuring" is actually just making an object. Which is something that was a part of js long before destructuring.

    • @hansmeyer2
      @hansmeyer2 4 роки тому

      yea that confused me too. i think "property shorthand" is probably the better way to refer to what he was doing there.

    • @Metruzanca
      @Metruzanca 4 роки тому

      @@hansmeyer2 well actually its called object literal.

    • @hansmeyer2
      @hansmeyer2 4 роки тому

      @@Metruzanca that's another JS feature this trick employs, but the question is what would have been a better way than "reverse-destructuring" to refer to it.
      "object literal" might be more appropriate but that's debatable since the whole point of the tip is to log a variable name and value without having to write them both out. you wouldn't gain much from console.log({ favoriteFood: favoriteFood })

    • @Metruzanca
      @Metruzanca 4 роки тому

      ​@@hansmeyer2 Its not debatable, thats the name for that feature. And he doesn't just use "reverse-destructuring" when talking about logging.
      Writing it as
      let varr = 1
      const obj = {varr}
      console.log(obj)
      or
      let varr = 1
      console.log({varr})
      Is equivalent. In the first case its called an object literal. In the second its still an object literal, its just not being assigned to anything and instead being passed directly to the function.
      A tip, shouldn't use incorrect feature names as 1. its confusing 2. if someone watched this before an interview and said "reverse-destructuring" to a senior js developer.

    • @hansmeyer2
      @hansmeyer2 4 роки тому

      @@Metruzanca your response is missing the point of what i am claiming is debatable.
      never mind, not really worth quibbling over.

  • @zokonilzokonil7402
    @zokonilzokonil7402 4 роки тому +1

    life changing js tricks == install lodash?

  • @piotrpawowski1711
    @piotrpawowski1711 3 роки тому

    for me not the prettiest but the easiest way to make deep copy is:
    var copy = JSON.parse( JSON.stringify( object ) );

  • @nowacry
    @nowacry 4 роки тому

    hey, would anyone like to share how they console log right in the editor?

  • @wesleytejeda
    @wesleytejeda 3 роки тому

    Cant get teh cheatsheet is it gone ?

  • @guidingtechbd
    @guidingtechbd 4 роки тому

    What is your theme name? Please tell me!!

  • @nahkama4211
    @nahkama4211 4 роки тому

    Anyone knows how the result/debug from the code appears right next to the code he writes? Any ideas?

    • @AaronJack
      @AaronJack  4 роки тому +1

      it's a VS code extension called Quokka.js

  • @Brsrtc
    @Brsrtc 4 роки тому

    lodash : use javascript like python

  • @skgujar2725
    @skgujar2725 3 роки тому

    Please please tell me your vs code theme name and font

  • @alii4334
    @alii4334 4 роки тому

    the JavaScript cheat sheet is JUST very basic stuff.

  • @abhishekshukla2745
    @abhishekshukla2745 4 роки тому

    I have seen developers nesting ternary up-to 5-6 levels and it is really painful to understand and debug.

  • @randidoesthings
    @randidoesthings 4 роки тому

    Why not spread the object to a new one instead of using lodash? Like const userCopy={...user}

  • @duckmasterflex
    @duckmasterflex 4 роки тому +1

    Tried that double ternary, let’s just say it wasn’t a hit

    • @Metruzanca
      @Metruzanca 4 роки тому +1

      Using a double ternary is debatable. I used them in some react projects mostly but now I found theres an eslint rule against double ternary, and my new org just so happens to use that rule.

  • @riousa7934
    @riousa7934 4 роки тому

    What are you doing in Serbia?

  • @bencemichelle
    @bencemichelle 4 роки тому +1

    Didn't get the js copy after entering email... Checked spam too.

    • @mikamanelka1326
      @mikamanelka1326 4 роки тому

      same here

    • @AaronJack
      @AaronJack  4 роки тому

      yeah working to fix that, my bad, i didn't save any emails

  • @th3n3rdman
    @th3n3rdman 4 роки тому

    Anyone who is learning about ternary operators from this video, please never nest them..... thats as much of a tip as saying i can shorten my code by naming my variables with single letters..... an actual tip is that if you cant understand what code is doing by reading it the first time, its too complex and needs to be made more explicit

  • @emanuelederiu5154
    @emanuelederiu5154 4 роки тому

    put a 301 on the www version of the website ;\

  • @DavidFregoli
    @DavidFregoli 3 роки тому

    Bad hair day?