Tips and Tricks for Debugging JavaScript

Поділитися
Вставка
  • Опубліковано 28 гру 2024

КОМЕНТАРІ • 274

  • @ilijatrbogazov4579
    @ilijatrbogazov4579 2 роки тому +190

    You missed, console.trace , super useful to know the call stack when debugging complex applications

  • @florinbujoreanu1020
    @florinbujoreanu1020 Рік тому +8

    you saved my life with this little piece of knowledge that apparently you don't find anywhere straightforward..

  • @AdamGaffney96
    @AdamGaffney96 2 роки тому +56

    Honestly the biggest piece of advice that I have to beginners and even some intermediates really is to just read the error messages. I can't possibly counts the amount of people who post on forums asking "why is my code broken?" and post an error message that says on line 30 there's an unexpected bracket. ALWAYS always read the error messages thoroughly before asking for help.

  • @alejandro.mangione
    @alejandro.mangione 2 роки тому +7

    Something that I didn't see you mentioning was that when you add a debugger, you can also use the console at that scope. I find that really useful.

  • @geraldleroy2225
    @geraldleroy2225 2 роки тому +41

    I wasn't aware that console.assert(), console.time() and console.timeEnd() existed. I also found the tips re: debugging in VS Code to be helpful. Also the reminder to step away is always a good reminder. Thanks for taking the time to put this helpful video together.

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

    My dude my favorite tip has to be throwing variables is an object for console logs. So simple but so freaking useful. I'm mad I never thought of it before. Thank you!

    • @Ahmad-ww4ue
      @Ahmad-ww4ue 2 роки тому

      That one tip was pure gold

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

    Thanks!

  • @Sledgeh101
    @Sledgeh101 2 роки тому +14

    The console.table one alone made this video worth it! Thanks so much!

  • @SebastianZartner
    @SebastianZartner 2 роки тому +18

    Btw. if you really want to log something, you don't even have to modify your code by inserting console.log(). The debuggers in the DevTools and VSCode allow to set so-called logpoints. Those work similar to breakpoints but log the variables you provide like a console.log() at that line of code where you set them.

  • @invictuz4803
    @invictuz4803 2 роки тому +92

    I think in many non-trivial real world scenarios like when you need to debug a web app in production that uses a library, it's more practical to use just the browser developer tools to debug - adding DOM/Event Listener breakpoints, watch expressions, black boxing library code, etc.. One thing that stumps me is that when I try to inspect event handlers that are registered on a button, I usually only see minified library code which doesn't help. I think doing a video on all the Chrome DevTools debugging features would be really helpful, and also when it wouldn't work like when code is obfuscated on the client.

    • @undefinedvariable8085
      @undefinedvariable8085 2 роки тому +16

      Agreed. I came here expecting this video to cover more browser runtime debugging solutions with DevTools.
      Don't care much for logging objects out in table format and most intermediate developers are most likely already familiar with all the other console methods mentioned.

    • @kigerukage6641
      @kigerukage6641 2 роки тому +2

      I definitely agree, I have spent countless hours trying to find out where a legacy application is failing hard on new requirements and I have to hunt down event listeners and the like for clues. In the Sources tab of the developer tools there is a button {} that will help format minified files to make it easier to read

    • @SebastianZartner
      @SebastianZartner 2 роки тому +5

      Regarding minified library code, the browser DevTools also support source maps. That means, they maps the minified statements to the original code for debugging.
      Another thing related to that is that the Firefox DevTools show when they recognize code of a specific library like React, Angular, etc. That makes it a little easier to black box them.

  • @felipesakuma9882
    @felipesakuma9882 2 роки тому +3

    which theme you use? It's beautiful

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

    you're the best man. this is literally the last quesiton on these interview questions (my friend is a team lead and sent me the interview quesitons lol)
    "...Can you please describe 3 ways you could use the Developer Tools in the browser to further debug the impacted Javascript."
    my rough draft answer right now is
    1) check the console for errors
    2) check event listeners and breakpoints
    3) use debugger; and console.log/dir/table/assert/time/timeLog/TimeEnd/warn/error/count/countEnd/trace

  • @BG-fo4si
    @BG-fo4si 2 роки тому +7

    Didn't know console has so many different methods 😅 Thank you for this material

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

      Yeah there's so much out there!

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

    And here I thought it was some kind of video about debuggers and breakpoints, but half of it is actually about console.logging like a boss!

  • @MuratKeremOzcan
    @MuratKeremOzcan 2 роки тому +8

    The most clear and concise content I've seen on the topic, thanks

  • @willadams6217
    @willadams6217 2 роки тому +2

    Yeah excited to hear you have entered the Vim world. I think the VS Code extension is a great entry to Vim, keep us updated please.

  • @chandlerchen2192
    @chandlerchen2192 2 роки тому +2

    What is the theme you are using in VS code? It looks really nice!

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

    Wow, thanks so much!. I don't know how many times I set a breakpoint in Chrome and press F5 to continue running as if I was in Visual Studio (C#) and reloaded my app. This was SO helpful!

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

    This has just become my fav video on youtube. Cheers

  • @AlleyDev
    @AlleyDev 2 роки тому +1

    I only said a couple weeks ago to a couple of colleages that there isnt many helpful resources out there to help with debugging, and its not something you generally get taught/shown on courses. Thank you, this has been super helpful for me as a junior, especially as I want to become more efficient at debugging and move away from console.logging everything!

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

    Honestly, it's been fifteen years since I began coding as an amateur, still an amateur today. But I always stuck with my console.log as a multimeter pin, I thought I needed nothing else ... I thought.
    If I could give you 10 thhumbs up I would ! ^^

  • @gabrielv1856
    @gabrielv1856 2 роки тому +3

    I personally use styled console.logs for warnings, alerts and oks. If theres another kind of message i can change styles also is a bit limited but for me is good enough. Thanks for the video! Ive been thinking about this lately and makes me want to build my own mini debugger i can use on every project. Again, thanks!

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

    Duuude I've been debugging with stone age techniques..... Thaaaanks!!! Fastest Liked + subscribed I've ever done 😆

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

    Assert and debugging is really useful, thank you!

  • @milad8436
    @milad8436 4 місяці тому

    You are a life savor. Thank you 🙏

  • @prsriddsaw6570
    @prsriddsaw6570 2 роки тому +3

    Resume :
    Console.log("length:",length);
    Console.log({length});
    Console.table(var); //better représentation of array
    Console.assert(password!==undefined);
    Console.error("this should not be undefined); //print in red color
    Console.warn("this should not be undefined); //print in yellow color
    Console.time(); => Console.timeEnd //print the duration between
    debugger; //function to launch debug step in browser
    9:20 tuto in vscode debugging config

  • @МихаилКорвин
    @МихаилКорвин 2 роки тому +8

    Would be useful making a video on spa debugging experience on the big three (vue react angular) or debugging experience on some js code that pushed thrue webpack.

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

    Awesome, the console table is awesome to know about!

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

    Thank you, I did not know the table and dir operations in console.

  • @thomad8538
    @thomad8538 2 роки тому +1

    You're the BEST, Thanks so much.

  • @saketabhishek5147
    @saketabhishek5147 2 роки тому +1

    Thanks for sharing I love your video !!Please keep posting

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

    I was looking for a normal crack for a long time and stumbled upon you, thank you very much

  • @ExtremeCrashCam
    @ExtremeCrashCam 2 роки тому +1

    Console commands seemed so useful until my code started getting really complicated. Thanks for the debugger tips, using dev tools on chrome would have saved me so much time in my last project.

  • @ssygon2
    @ssygon2 2 роки тому +1

    Wow, i didn't know "debugger" existed! Useful for debugging inline js(non external js file), which i couldn't set a breakpoint on! 👍

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

    Could you please tell which theme you are using?

  • @jesper.ordrup
    @jesper.ordrup 2 роки тому +1

    Debugging is so much more powerful than console logging. Being able to pause execution (breakpoint) and discover what really goes on (step through a flow) because of the state of variables (you can see all variable values - and even change them for testing) is so so so more much valuable.
    And you don't modify your code.
    Serverside code debugging can be tough to setup, though. That's could be a follow up video

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

      also you can log that same variable and know what is going on

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

      @@jcoucelanga4373 try doing it 30 times over, and logging 20 variables. Just not the same.

    • @jcoucelanga4373
      @jcoucelanga4373 2 роки тому +1

      @@dingusfartacus9624 Meh, I insist, some specific issues demand debugging, but 99% you can do it faster with advanced logs

  • @andresruedalibre
    @andresruedalibre 10 місяців тому

    Thanks James, this was very useful!

  • @devstefancho
    @devstefancho 2 роки тому +1

    I already know console.dir shows more information than log, but element usage of console.dir is very impressive!

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

    vsCode debugging only, but Your tips for console - awesome!

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

    so good tips for debug projects.. thank you for the video James!

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

    Great video. Thanks, James

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

    Super helpful dude, thanks for sharing!!!

  • @vince-sig1014
    @vince-sig1014 2 роки тому +1

    i honestly cant wait to try this out and show this to my colleagues! Thank you so much!

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

    Console table will be handy. Thanks

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

    Just one question
    Which theme is that..name please?
    Thanks..
    I really liked it

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

    @3:50 = syntactical sugar. {length} simply creates a new object {length: length} ... useful for debugging sure but it's a feature of Javascript overall, not just for debugging

  • @alanhf
    @alanhf 2 роки тому +1

    That's public service, James. I really appreciate it.

  • @vishwasrvibhu6670
    @vishwasrvibhu6670 2 роки тому +2

    Great video! Can you please also tell me the font and theme of VS Code you are using?

  • @HowManyShrimps-g7z
    @HowManyShrimps-g7z 2 роки тому

    3:52 didn't know about that. big thanks

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

    Extremely helpful video!

  • @neontuts5637
    @neontuts5637 2 роки тому +2

    Thanks for the video. [Q] - Debugger in vscode is built-in or do we need to install the "Debugger for Chrome" extension?

    • @JamesQQuick
      @JamesQQuick  2 роки тому +5

      It’s built in now :)

    • @neontuts5637
      @neontuts5637 2 роки тому +1

      @@JamesQQuick Wow that's cool. Thanks You :)

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

    Thank you kind sir. Console.table has been my go to since day dot.

  • @fliplucky8813
    @fliplucky8813 2 роки тому +1

    vim plug

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

    Very helpful video. Thanks! James.

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

    Fantastic! Thanks for the video!

  • @fer-ri
    @fer-ri 2 роки тому

    Never knew about console.table .. Thanks 👍

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

    Fantastic Video! Thanks!

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

    Hi what's the theme you are using in vscode?

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

    What's vscode theme are you using?

  • @Xe054
    @Xe054 2 роки тому +13

    Great video 👍. Side note: when you impersonate different people, it might help to face the characters against each other (person one looks right, person two looks left).

    • @JamesQQuick
      @JamesQQuick  2 роки тому +1

      haha yeah I'll get better at this!

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

    Thank you so much, this is going to be very very useful!!!

  • @damirmubarakshin1811
    @damirmubarakshin1811 2 роки тому +1

    Awesome tips! Thanks!
    By the way, what is the name of your vscode color theme?

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

      have you found out? he is not 'quick' responding

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

    What plugins do you use ?

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

    Thank you for the video. Maybe you could create a video about debugging TypeScript using debugger in VS Code ?

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

    Woow, what's that VSCode theme?

  • @viberson-vibe
    @viberson-vibe 2 роки тому

    How can I get that purple theme for vscode?

  • @LukasPlaysMusic
    @LukasPlaysMusic 2 роки тому +1

    Great video 👍

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

    Thank you very much! Very helpfull

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

    What's inside the inspiration folder 🤔

  • @Pareshbpatel
    @Pareshbpatel 2 роки тому +1

    Great introduction on Debugging in JavaScript. - Thanks, James
    {2022-03-09}

  • @PradeepYadav-fg2yg
    @PradeepYadav-fg2yg 4 місяці тому

    Please someone tell me which theme he is using in vs code

  • @kishorpatel1254
    @kishorpatel1254 2 роки тому +6

    You look really tired buddy, take some rest. We like you content but you will be able to keep making it only if you take care of your health. Wishing more power to creators and contributors like you.

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

      Yeah I noticed that as well. Glad someone else pointed it out too. Take care @James Q Quick!

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

    Which font are you using in vscode?

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

    what color do you use for the Cobalt 2 theme?

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

    Amazing, thanks ! Do you know if it works with VSCode Remote ?

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

    Great video,James this is so significant
    Thanks so much

  • @Russell.Jolly.2023
    @Russell.Jolly.2023 2 роки тому

    Important for developers to know.

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

    It looked as if you were clicking the source location link in the Chrome console to automatically jump into the right place in VS Code. This was probably just a nice edit and not the actual result of clicking that link. Is there no such tool/plugin/extension for Chrome/VS Code to jump from the console output directly into the VS Code source? That would be super nice!

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

    How is the vim extension so far?

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

    What theme are you using?

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

    Wow...can you tell me the which font family you used in the vs code... it's looking awesome
    ..😍👌

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

    James: "we are all guilty of using console.log to debug... but there are lots of other tools..."
    also James: "so we can start by logging..." lol seems legit 👍 great video..

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

    what font are you using?

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

    Nice video - does it matter where you put the debugger statement if you're also adding break points?

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

    Any idea how to view Mongo doc id during debugging? Debugger usually shows the binary value for them.

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

    Great teacher

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

    What extension is that gives you the animated text cursor? That is so cool.

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

      It's a setting called like cursor style I think lol

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

    nice - didn't know about the dir, or the {} console options

  • @luke-urban
    @luke-urban 2 роки тому +2

    I did enjoy the video, the assert is something new for me. Also try turbo console log (vscode plugin) 😉 I recently discovered it 🔎

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

      Yeah I’ve been meaning to do a video on it!

    • @luke-urban
      @luke-urban 2 роки тому

      @@JamesQQuick Nice!

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

    Any good debugging tools with reactjs?

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

    Does someone know how to get the Firefox Debugger (vscode extension) when using WSL2?

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

    I've also recommend an Extension called Turbo Console Log 👌😎

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

    I have a monorepo project i work with, and the debugging by default takes a huge amount of time so i need to configure the "outFile" property. Could you make a video showing the debugging of something like a monorepo that uses lerna?

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

    Nice, learned a couple of console methods I wasn’t aware of (never had to use them). But, why wouldn’t you use the developer tools in the browser? Same results, less effort.

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

    Thank you Sir !!

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

    Amazing, thanks !

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

    Thanks James. I just found out I dont know everything :)

    • @JamesQQuick
      @JamesQQuick  2 роки тому +1

      hahaha everyone has something to learn every day!

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

    Great content. Thanks .could you please share the theme you are using please?

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

    Brilliant ❤️❤️❤️

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

    Amazing! Thank you