Top 10 Javascript One Liners YOU MUST KNOW!

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 พ.ย. 2024

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

  • @eduardointech
    @eduardointech 7 หลายเดือนก่อน +1

    With the first video, the CSS one, you got my like and save, with this second one you got my like and subscribe!

  • @codegenius2932
    @codegenius2932 2 ปีที่แล้ว +108

    I think what you were calling extraction is actually called destructuring (like it's proper term). Nice video, definitely learnt something new

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

      Yes that's it. Destructuring works for objects attributes OR even positional properties of Array with Const keyword
      const [first, second] = [1,2]
      const {f, s} = {f:1, s:2}

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

      Who gets to decide which is term is proper and which is not?

    • @anarchoyeasty3908
      @anarchoyeasty3908 2 ปีที่แล้ว +6

      @@cipherxen2 the language spec?

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

      @@anarchoyeasty3908 language specs are not written in stone, they also change

    • @anarchoyeasty3908
      @anarchoyeasty3908 2 ปีที่แล้ว +6

      @@cipherxen2 ok let me know when it changes from calling it destructuring and this comment thread will become irrelevant. Until such a time as that occurs, the thing is called destructuring.

  • @lainverse
    @lainverse 2 ปีที่แล้ว +9

    3:37 I'd like to add that it's worth remembering that using spread operator on arrays have iteration cost attached to it, so the larger the array the slower this works. So, if your code is called many times over it's better to merge arrays in traditional way by pushing elements of one into another. It doesn't matter on small arrays, but on actually large ones (thousands of items) this may cause a noticeable lag.
    6:33 6-digit hexadecimal number. In decimal (default representation in console) it can go up to 8 digits. ;)

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

      Another approach is to have a third array that is updated at the same time as the other two. The downside would be that it has to search for the entries, but if using a map, that can be solved through using proper keys.

  • @matet12345
    @matet12345 2 ปีที่แล้ว +69

    Always amazing to be greeted as "gorgeous" 😅😁

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

      With all due respect, I thought you're already fed up with it. You must be called gorgeous all the time... :$

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

      Damn, people are now hitting on girls on TH-cam nowadays. What a time to be alive

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

      @@elfelipe1996 Absolutely not, just stated the obvious!

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

      Yeah, this guy is a smoothie

    • @CodeWithUjval
      @CodeWithUjval 3 หลายเดือนก่อน

      but you aint gorgeous

  • @KGmagicjj
    @KGmagicjj 2 ปีที่แล้ว +5

    This is a nice list, but I would strongly recommend w this being a teaching channel, to mention the technical name of some of these patterns and operators as you go. Spread operator, object destructuring syntax, guard blocks, etc.

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

    I've always called the "one line if" a guard statement, or a guard if statement. Helps a ton with nesting.

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

      "guard statement" is a proper term for the thing as well

  • @boneykingofsomewhere
    @boneykingofsomewhere 2 ปีที่แล้ว +10

    I created a random background-color generator with copy-to-clipboard inside a hex code div (the hex code shows inside the div).
    Click the button to generate a random colour and if you like it, click the hex field div to copy it. Great little video that has definitely improved my abilities and knowledge, ta Ed 😀😎

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

    Dude. The random hex was super clever. My favorite new trick.

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

    You are a developer and a successful youtuber, but from the outlook, you could be an actor too. No joke.

  • @trickeddev
    @trickeddev 2 ปีที่แล้ว +4

    Array.from(new Set([…..])) is much cleaner than what you did and is the preferred way btw

  • @jaied
    @jaied 2 ปีที่แล้ว +4

    Cool!
    Although I knew most of these one-liners. Only DesignMode and transitioned events are new to me.
    Thanks for sharing.

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

    8. is actually called a Guard Clause, very useful to avoid nested if statements!

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

    Cool tricks!
    Fun fact: You can make `const copy = (text) => navigator.clipboard.write(text)` even shorter
    `const copy = navigator.clipboard.write`
    no need to wrap in another function that takes text and passes text to it.

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

    That color generator is awesome!! Tyvm!

  • @7heMech
    @7heMech 2 ปีที่แล้ว

    The only thing which I didn't know was 5:01, but it's good to revisit things once in a while, great video!

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

    i love your music taste, super chill

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

    I will make a shortcut of this video to my desktop. Thanks Ed.

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

    The random color hex thing blew my mind!

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

    `console.table(data)` at 11:45 very useful tip!

  • @yoel.taylor
    @yoel.taylor 2 ปีที่แล้ว +3

    Super important to note that the Navigator.Clipboard API only works locally or in HTTPS. So if you want to make an insecure HTTP website, copying text won't work!

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

      I guess that explains why it was not working for me on codepen. Sure, codepen does use HTTPS but i guess it has something to do with it... Because it is not working at all on codepen

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

      Why is that super important you nerd

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

      This is definitely important, but it's also 2022, there are no excuses to not have an SSL certificate on your website.

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

    0:47 Design Mode - awesome feature, I like it!
    Almost all rest poor, because it is something like part of ECMA standards.
    Also last one looks impressive.
    Good job, man, anyway! Thank you!

  • @ekoneko6958
    @ekoneko6958 8 หลายเดือนก่อน

    After CSS one-liners, now this = New Subscriber here :)

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

    We love you, Ed. Just wanted to let you know that.

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

    did he just say "g" when going through the hexadecimal characters at 7:20 lmao

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

    aspiring fan here... i allready new this, but i kinda forgot the other so thanks for the reminder

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

    That merge one liner is great is for interviews

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

    Ed called me friend👌🏻 Life complete, haha,
    These videos are actually golden, keep it up

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

    Cool! I like the screen capturing

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

    thanks for the tutorial Ed Helms.

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

    Ed can u please tell mr what monitor are you using? Looks amazing.

  • @4Sightfails
    @4Sightfails 2 ปีที่แล้ว

    Very fun video, it brings me joy that I knew almost 5 of them.

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

    this man is pure positive energy, lovely human being :)

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

    Thanks a lot bro. awaiting for more videos from you.

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

    Really coool video 🔥🔥🔥
    Cool setup as well 😊
    By the way, please tell me the model of your monitor, it looks dope

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

    The design mode one was very helpful, the rest are also helpful but it's just regular es6 stuff.

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

    // SuerySelector ..............................................
    function Selector(selector) {return document.querySelector(selector)}
    // QuerySelectorAll ..............................................
    function SelectorAll(selector) {return document.querySelectorAll(selector)}
    With this code, you can call any element in an easy and short way
    Example:
    let Element = Selector('Target_Element') // return Element
    or
    let Element = SelectorAll('Target_Element') // Return Array Of Element

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

    Nice video, I like the way you explain. Nice work dude.

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

    I legit thought this was gonna be a video about Javascript jokes

  • @strawhat1927
    @strawhat1927 หลายเดือนก่อน

    transitionend is amazing thank you

  • @Motivado-gp
    @Motivado-gp 2 ปีที่แล้ว

    designMode extremely blows my mind. Great content !

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

    Nice video, Blender in combination with Babylon js would be awesome. Not many people make tutorials about Babylon js while it is a great 3D engine for in the browser

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

    Very nice vid Ed! 🚀 That monitor at the beginning, is it Dell? Can you tell me the type? 😊 Cheers!

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

    Man transitionend will save me tons of time!!!!

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

    Grateful for this video 🤝

  • @khan.hassan
    @khan.hassan 2 ปีที่แล้ว

    Very useful thanks for sharing

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

    Hi ed .
    I wont to ask you from were you have learned data structure and algorithm?
    Thank you ed for your courses🌺❤️❤️

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

    Your tutorials are always so engaging and easy to follow 🔥🔥🔥

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

    he claims to be using the palenight theme, but here hes using the Community material theme ocean high contrast... you're welcome

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

    the 70's prono music in the background makes the video

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

    9:22 or you just set the visibility to hidden aswell. This will not transition by itself, so you'll still need opacity, but it will change the value once the transition is done.

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

      Setting visibility to hidden will disable pointer events on the element, but other elements in the DOM will be affected by its positioning (unless it's set to an absolute or fixed position). To keep the element on the page, you should set it to "display: none;" so that way it will not affect the layout of other DOM elements and be removed from visibility.

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

    thank you for this video, you are awesome!!

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

    Hey man, you're videos great as always, do you consider making a video about javascript road map?

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

    Hey ED :) ! I saw in one of your other video that you had a vs code theme with a gradient up in the title bar in one of your recent videos and i thought it looked SO cool that i figured out how to do it myself :D ... But now you dont have it anymore i see .

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

      i used the "Custom CSS and JS loader" vs code extension and then custom CSS to color the different elements of vs code :)

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

      I cant post a screenshot of my vs code .. Cuz youtube deletes the comment but yeah , could be cool to see a video on that .

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

    The designmode one is super helpful while designing sites

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

      who would have thought...

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

    Thanks! By the way, what is theme color name ?

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

    Thank You Ed This Is Realy Amazing

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

    2:45 you aren't merging two arrays, what you're doing is concatenation. Merging two arrays is more like a zip operation.
    Loop over one and and use the current index to get the corresponding element in the other array, then combine both values as a tuple, or whatever structure you need.

  • @AlekVila
    @AlekVila 4 หลายเดือนก่อน

    concat() is another way to merge arrays: arr1.concat(arr2);
    Retaining only unique values: [...new Set(arr1.concat(arr2))];

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

    This is really great! Thanks for this content Ed! 🚀

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

    The extraction is very useful for any Async call

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

      The official name is destructuring, just in case you want to look it up

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

    Really nice video, Ed!

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

    Ur my best teacher 💜

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

    Gracias querido por estos tips; hace mucho no programaba ni lo más mínimo en js y me voy desactualizando, pero aquí aprendí nuevas funciones y demás

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

    Love the new video quality 😍😁

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

    Awesome! I knew all of them but what was the last one? Didn't know about it

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

    JSON.stringify(data,null,2)

  • @wfl-junior
    @wfl-junior 2 ปีที่แล้ว +5

    Technically you can do anything in one line in JavaScript xD

    • @BlackHayateMX
      @BlackHayateMX 8 วันที่ผ่านมา

      I did that for a test and my teacher wasn't very pleased, but I got my passing grade

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

    👍 great content - thanks so much !
    👍 no floating presenter head
    👍 video and audio quality
    👍 larger ide font size
    👎 (imho) loud, distracting "music"

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

    Doesn't generate colors have an issues with missing leading zeroes in numbers less than 0x100000?

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

    I don’t know how many years Ed has been calling me a gorgeous friend on the internet 😂

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

    Always good content, you're the best

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

    deved numbah one 👑

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

    Really good video ❤

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

    Love your energy 👍

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

    thank you very much 🙌

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

    I like the console.table command.

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

    I like your energy, friend

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

    This is a good one.

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

    This man a little dr crazy looking . Dude thank you.

  • @damianos.2954
    @damianos.2954 2 ปีที่แล้ว

    You're crazy. I love u💚( as instructor)😅💪💪💪

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

    What is the lens you used for recording this video?

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

    It's short just fiery content!!!
    Thanks for this hacks 😉

  • @andrewsharpe4764
    @andrewsharpe4764 6 หลายเดือนก่อน

    For merging arrays, concat is easier to read.

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

    You remind me of the guy in Camera Conspiracies

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

    console.table is super cool!!
    More videos like this please

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

    Nice video! :D Maybe name the "roll the dice" to "flip the coin" since you made it just 2 sided hehe 😜 But keep up the good work nonetheless

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

    Hello plz I m looking for a function or whatever that can help me find list of printers installed on my machine. Thanks lot for your videos

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

    what is your monitor please?

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

    Beard look great Ed ☺️

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

    These are handy one liners, but it worth pointing out most of them are using the web API, not pure JavaScript. 😅

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

    Good Things devEd mawa

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

    Very good

  • @mr.shroom4280
    @mr.shroom4280 2 ปีที่แล้ว

    You make me smile

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

    What vscode theme are you using in this video?

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

      he claims to be using the palenight theme, but here hes using the Community material theme ocean high contrast... you're welcome

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

      @@Mwtorres89 thanks 🙏🏻

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

    Hi, how are you? I have a question. How to implement animation in Figma on the web-site? I can't find a solution on the internet

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

    What's you display brand & model?

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

    I knew designMode, the extraction (because I use a module that imports like that), the clipboard one, transitionend, the short if statements (i use those a lot too!), console.table, and the screen capture.
    I knew like 70% of those, but still good video

    • @Feavy
      @Feavy 2 ปีที่แล้ว +6

      Who asked?

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

      @@Feavy Who asked you to say that?

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

    #4 is called "destructuring," not "extraction."

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

    2nd Boolean(Math.round(Math.random()))

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

    maybe its better to set the transitionend event inside the click event and set it to once: true