var, let and const - What, why and how - ES6 JavaScript Features

Sdílet
Vložit
  • Äas pÅ™idán 5. 09. 2024
  • 💖 Support the show by becoming a Patreon
    / funfunfunction
    In ES5, we only had one type of variable, var, but in ES6, we have three. types of variables: var, let and const. In this video, we explore the what, why, and how of var, let and const, and I also do a little lecture on the value of minimising mutable state.
    â–º 00:35 var keyword in JavaScript
    â–º 02:35 Immediately-Invoked Function Expression (IIFE) in JavaScript
    â–º 03:14 hoisting variables in JavaScript
    â–º 08:29 let keyword in JavaScript
    â–º 11:55 const keyword in JavaScript
    â–º 14:14 Minimize mutable state when programming
    I'm also active on:
    - Twitter / mpjme
    - Medium / mpjme
    - Quora www.quora.com/...
    Resources:
    - Semicolons cannot save you! (Another funfunfunction video)
    • Semicolons cannot save...
    - ES6 JavaScript Features (Playlist of this series)
    • Generators in JavaScri...
    💛 Follow on Twitch
    We record the show live Mondays 7 AM PT
    / funfunfunction
    💛 Fun Fun Forum
    Private discussion forum with other viewers in between shows. www.funfunforu.... Available to patron members, become one at / funfunfunction
    💛 mpj on Twitter
    / mpjme
    💛 CircleCI (Show sponsor)
    Robust and sleek Docker-based Continuous Integration as a service. I used CircleCI prior to them becoming a sponsor and I love that their free tier is powerful enough for small personal projects, even if they are private. Use this link when you sign up to let them know you came from here:
    circleci.funfu...
    💛 Quokka (Show sponsor)
    Wonder how MPJ evaluates JavaScript inline his editor. Quokka is the answer - use this link when you buy to let them know you came from here:
    quokka.funfunfu...
    💛 FUN FUN FUNCTION
    Since 2015, Fun Fun Function (FFF) is one of the longest running weekly CZcams shows on programming 🅠thanks to its consistency and quality reaching 200,000+ developers.
    🤦â€â™‚ï¸ The Failing Together concept is what makes FFF unique. Most coding content out there focus on step-by-step tutorials. We think tutorials are too far removed from what everyday development is like. Instead, FFF has created a completely new learning environment where we grow from failure, by solving problems while intensively interacting with a live audience.
    Tutorials try to solve a problem. Failing Together makes you grow as a developer and coworker.
    📹 Each show is recorded live on Twitch in a 2-hour livestream on Mondays. The host, assisted by the audience, is tasked to complete a programming challenge by an expert guest. Like in the real world, we often fail, and learn from it. This, of course, reflects what the audience identifies with, and is one of the most praised aspects of the show.
    ⯠On Fridays, an edited version of the show is adapted for and published on CZcams.
    Content Topics revolve around: JavaScript, Functional Programming, Software Architecture, Quality Processes, Developer Career and Health, Software Development, Project Management

Komentáře • 551

  • @webapplication9086
    @webapplication9086 PÅ™ed 7 lety +72

    You are the most friendly instructor in the world

  • @leandrogoncalvesdeoliveira9201
    @leandrogoncalvesdeoliveira9201 PÅ™ed 8 lety +219

    TIL: always use 'const'. If you *REALLY* need to change state, use 'let'. 'var' is dead.
    Thanks! ;)

    • @jordancotter5885
      @jordancotter5885 PÅ™ed 8 lety

      would 'let' still be useful because of the way it's scoped? ...regardless if you need to change it?

    • @pajn
      @pajn PÅ™ed 8 lety +10

      const has the same scoping as let

    • @leandrogoncalvesdeoliveira9201
      @leandrogoncalvesdeoliveira9201 PÅ™ed 8 lety +8

      'const' is block scoped like 'let' :} awesome feature!
      (function () {
      const a = 3;
      if (true) {
      const a = 5; // no error, block scoped!
      console.log(a); // outputs 5
      }
      console.log(a); // outputs 3
      })();

    • @jordancotter5885
      @jordancotter5885 PÅ™ed 8 lety

      That isn't true Rasmus.
      const will behave like so:
      if (true) const x = 5;
      console.log (x);//5
      While let would behave differently:
      if (true) let x = 5;
      console.log (x)//Block-scoped declaration

    • @leandrogoncalvesdeoliveira9201
      @leandrogoncalvesdeoliveira9201 PÅ™ed 8 lety +7

      MDN says 'const' behave like 'let', Jordan. (developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const)
      (function () {
      var x = 'nope';
      if (true) { // block-level
      const x = 23;
      console.log(x); // 23
      }
      console.log(x); // 'nope'
      if (true) { // block-level
      let x = 42;
      console.log(x); // 42
      }
      console.log(x); // 'nope'
      })();

  • @Chocoholic1337
    @Chocoholic1337 PÅ™ed 8 lety +9

    Tip for the arm/hand pain: Do hand exercises! Do a CZcams search for 'gaming hand exercise' and you'll find what you need. Just do this every 30-60 minutes for a couple of minutes... you'll notice a world of difference!
    Thank you for the video. As always, great content!

  • @zsoltoroszlany7172
    @zsoltoroszlany7172 PÅ™ed 8 lety +17

    I have to admit I failed to understand what is hoisted ... until now, many thanks for you. I really enjoyed your tutorial video. Thank you again!

    • @YoungMesrine
      @YoungMesrine PÅ™ed 5 lety

      Pls what is hoisted?

    • @acskck
      @acskck PÅ™ed 4 lety

      @Midas / XIV what he said is not the actual thing happening at all. Your code will not be moved to top. This behavior is due to something called execution context. It has 2 stages, creation stage and execution stage.
      Since JS interpreter is single threaded, it needs to have a execution stack in order to keep track of what is being executed and a execution context is created for global and each function it executes.
      While in the creation stage, it will create global object, determine the value of "this" and also it will scan through the code and put variable declarations and functions to the memory. So when the execution stage comes, those declared variables (not their values) and functions are already available in the memory. Hence it feels like those declarations are moved to the top of the code.

  • @mikeyscimeca
    @mikeyscimeca PÅ™ed 7 lety +71

    Thank you so much for making these videos. I have learned so much and have been entertained with your jokes. Thank you Thank You Thank You.

    • @funfunfunction
      @funfunfunction  PÅ™ed 7 lety +22

      thanks michael, that's exactly the kind of response I was aiming for! Thanks for following the channel!

    • @battosaijenkins946
      @battosaijenkins946 PÅ™ed 7 lety

      @funfunfunction, Hi sir With all due respect I believe that var, let, and const all have a time and a place. To say that var is no longer used, let should take its place, and const should be everywhere I simply disagree.
      Yes let should be used for block scoping but I really have to say that const is being overused. If you want your object/code to not change, simply think a bit more about the outcome of your code ahead of time to prevent unforseen errors or even worse coding yourself into a corner.
      And also, as my professor says const should be something you know will never change, for example PI, gravitational acceleration, Euler's constant etc... In other words, use it when you know variables will never change, dont just assume its better than var. That is all, thank you~

  • @atxaqualion75
    @atxaqualion75 PÅ™ed 8 lety +4

    Good stuff. Immutability is really key to taking advantages of higher level programming languages that can parallel process your code without explicitly defining how the parallel processing occurs. This is why functional programming languages such as Scala, Clojure, etc. are gaining traction.
    I've been using JavaScript for 20 years and several of your JavaScript-centric episodes teach me something new about how things work "under the hood". Thanks mpj.

  • @Mikethealtarboy
    @Mikethealtarboy PÅ™ed 8 lety +2

    Love your videos as always!
    I had some arm pain after starting my desk job - mostly in the forearm, and a little tingling around the ring finger. My solution was to make sure my chair was high enough that my arms were 90 degrees with my keyboard, and get a stand for my laptop so I wasn't looking down at it. The source of the problem was actually tight muscles up around my shoulders and neck, which resulted in a nerve being pinched. A little ointment on my shoulder when I found it getting tight helped too. It took a couple months but did get back to normal.

    • @sheriffderek
      @sheriffderek PÅ™ed 8 lety

      This worked for me too. Why are desks and chairs so misaligned? codepen.io/sheriffderek/pen/gppRbd

  • @qwarlockz8017
    @qwarlockz8017 PÅ™ed 8 lety +2

    First off of course... thanks so much for your great videos! I really enjoy them. Programmers are getting this now but historically this was a condition that pianists got. This has been topic of conversation for pianists for since the first piano was built. Some of the advice is to have your arm parallel to the floor and to keep your wrist straight (so as to not cut off blood or restrict the nerves) an d to let the weight of your arm or hand coming down (ie gravity) is what provides the force to hit the keys not forcing the arm down. Lots of books on piano technique out there that all programmers should look at.

  • @SayuStrife
    @SayuStrife PÅ™ed 8 lety +2

    Brilliant Video. The talk about mutable state will definately help me design my code better going forward.

  • @rdagger
    @rdagger PÅ™ed 8 lety +4

    I had bad wrist pains from long days at the computer. I cured it by adding dumbbell wrist curls and reverse wrist curls to my workouts. 4 sets of 12 reps with light weights, 3 times a week. I also use gel keyboard and mouse wrist rests to try to keep my wrists in the same plane as my forearm. I’ve been wrist pain free for several years. Now would be a good time to also add some preventive shoulder exercises because that is another very bad consequence of too much desk work.

    • @nickwoodward819
      @nickwoodward819 PÅ™ed 6 lety

      yeah, i had wrist issues (see above), that terminated (and relieved) just between the shoulder blades. definitely all connected

  • @adamkucharik9189
    @adamkucharik9189 PÅ™ed 8 lety +3

    Another arm pain tip: In addition to posture and exercises, if you use a mouse, train your opposite hand so you can switch and give each hand/forearm a break. The first week of using the opposite hand was quite challenging for me. I became both physically and mentally tired quickly. But after the first week my accuracy and stamina was good enough for non-pixel perfect use.

  • @ahwaliazizi
    @ahwaliazizi PÅ™ed 6 lety

    impressive... very smart, no keyboard strok sound, no nasty backgroud sounds, theroy plus practical, deep knowledge so deep explaination ....amazing video !

  • @afitnessca
    @afitnessca PÅ™ed 6 lety

    Hey just wanted to say thanks. I am a 3 years into Java development, was trained in one of the software development bootcamps and learned ruby. As JavaScript is taking over the world my knowledge about it was very basic, and your tutorials makes me interested to apply more of these principles. I do find your videos very engaging, very informative, clear and concise. Thank you.

  • @erickvoodoo1993
    @erickvoodoo1993 PÅ™ed 8 lety +5

    Thank you! I've been waited for next lesson about ES6 features and now I have it!

  • @user-uj6le5fl9c
    @user-uj6le5fl9c PÅ™ed 7 lety +2

    Great video sir! in terms of ergonomics: i used to experience what you described on a daily basis previously.
    What fixed it for my was: Have a chair which has a good straight sit mode (not hanging back nor too forwards) and make sure that your chair has armrests where your elbow can rest at height of about 2/3cm lower than your desk height.
    Also what is essential is using a mouse that suits your hand. It would shock you to know how many people use too small mice.
    A nice long mouse ergonomics wise is the Razer Deathadder.
    Again thanks for making these awsome video's for new aspiring JS devs and i hope your arm is okay again by now!

  • @stevenwilson1890
    @stevenwilson1890 PÅ™ed 8 lety +1

    I'm not even a JS programmer, but your show is so well done I look forward to it and watch it every week! Thank you!

  • @jamesmcginn6291
    @jamesmcginn6291 PÅ™ed 7 lety

    "It's so nice for something to be immutable." Great explanation. I loved the dishwasher analogy. Thank you!

  • @vacprokop
    @vacprokop PÅ™ed 7 lety

    I have learned two universal principles so far: minimize scope and don't reassign a variable. Well done with this episode!

  • @OttoRobba
    @OttoRobba PÅ™ed 8 lety

    For ergonomy - and this is something that has helped me immensely - you should look into compact mechanical keyboards.
    - Short distance between mouse and keyboard
    - Shortcuts for moving the cursors (stay in the home row)
    - Better typing feedback = less mistakes, more precision and less typing
    I'd recommend a Pok3r keyboard with brown switches or, for an endgame, comfortable keyboard, the Happy Hacking Keyboard Pro 2.
    Touchpad instead of mouse is pretty nice too, it helps in keeping the hand flatter instead of "claw-shaped" and avoids wrist movement.

  • @davidbrewitz
    @davidbrewitz PÅ™ed 8 lety

    I trained my left hand to be as efficient as my right hand using the mouse. It was annoying for the first week or two but you will appreciate being able too switch back and forth when one gets too painful. Its always good to have a backup.
    Thanks for the awesome vid's by the way!

  • @GordWayne
    @GordWayne PÅ™ed 5 lety

    The best sound effects! You should bring them back for the newer episodes.

  • @sab611
    @sab611 PÅ™ed 8 lety

    Hi MPJ
    Use your mouse with your left hand for a while. You get used to it after a bit. Also get a pad to lift up the base of your palm so your hand is parallel with your forearm, ie your wrist isn't bent backwards at all. Or have a high platform to use your mouse on which also stops your wrist getting bent. The only rear cure for RSI (repetitive strain injury) or Carpal Tunnel is rest. Turmeric is a good natural remedy for inflammation.

  • @patrickbarnes5853
    @patrickbarnes5853 PÅ™ed 7 lety

    Just discovered you today and can't stop watching. Great content and humor! Concerning arm pain: I had this and it was due to clicking on mouse buttons. Makes sense that extending a finger and mashing a button hundreds of times a day would cause RSI. Problem went away quickly and has stayed away for years when I replaced the mouse with, first, a Wacom tablet and later a magic track pad with tap to click enabled.

  • @SuperManitu1
    @SuperManitu1 PÅ™ed 8 lety +14

    Concerning your arm: I had something similar, bought a vertical mouse off amazon and Im very happy with it. No pain since then.

    • @atxaqualion75
      @atxaqualion75 PÅ™ed 8 lety

      I had a developer friend that also advocates a mouse that is similar to an orig Atari joy stick.

    • @SuperManitu1
      @SuperManitu1 PÅ™ed 8 lety +2

      If anyone else is interested, this is the one I bought: www.amazon.de/Delux-M618-Scroll-Rad-PC-Maus-2-Wege/dp/B00AYXUIO6
      It seems that this very model is sold unter a bunch of different names, seems to be the same mouse though.

    • @TimothyWillis1981
      @TimothyWillis1981 PÅ™ed 8 lety

      Had an issue too, got a vertical mouse and made a place to rest my elbows, no more pain for me.

    • @error.418
      @error.418 PÅ™ed 7 lety

      Also consider a keyboard that allows tenting and splaying, it does the same thing as switching to a vertical. Combined, be pain free.

    • @nickwoodward819
      @nickwoodward819 PÅ™ed 6 lety

      you really don't need it though, at least not initally depending on your injury. most rsi comes over time (obviously.) so most is fixed by improving your wrists/arm/shoulder movements. powerball, stretches, nerve glide exercises. a vertical mouse aliviates the symptoms, it doesn't prevent them. :)

  • @agasarang
    @agasarang PÅ™ed 7 lety

    Just found your videos. Are you still having arm pains? I was thiiiiis close to surgery before going all ergonomic setup. This included a ten-keyless keyboard (Kinesis Advantage 2 -- best keyboard I've ever owned), trackball, a keypad on the left side (Razer Orbweaver for shortcuts), etc. This COMPLETELY eliminated all arm pains, shooting electric shots up through the shoulder and spine, etc. Saved me tens of thousands in medical fees.
    Really enjoying the vids -- subscribed!

  • @YanasChanell
    @YanasChanell PÅ™ed 7 lety

    Thank you very much! You make clear things I've read about many times on my native language but couldn't understand.

  • @VictorMorettiOfficial
    @VictorMorettiOfficial PÅ™ed 7 lety

    Man, I am currently on 7:08 and have learned more than with hundreds of articles on the web. Thank you very much, seriously. JS looks crazy for square guys like me haha

  • @enterteg
    @enterteg PÅ™ed 7 lety +1

    I love the scenography in your room :) Great videos, great job! You are very inspiring, thanks a lot!

  • @robertperry8588
    @robertperry8588 PÅ™ed 8 lety

    For the arm pain... I know people who said they had the same issue but switched keyboard styles to an alternative to qwerty and that fixed it for them. Also, I know you prefer very simple text editors, but a nice perk to vim is that your hands stay on home row during everything you do, so that you don't have to move your hands down to the arrow keys and Control keys as much

  • @sweeball
    @sweeball PÅ™ed 7 lety

    I am not a doctor, but I suspect that your hand/arm pain is most probably Repetitive Strain Injury (RSI). I think that it might be helpful when you get it in, say, your right hand/arm to try to use your left hand to operate your mouse, etc. You need to be able to rest your affected limb.
    Thanks mpj for the vids on "becoming a better programmer" FunFunFunctions is the best I've found for a wide variety of programming topics (... and the most entertaining). Keep up the good work. I always look forward to Monday mornings at 08:00 GMT for my next "fix".

  • @mattharris2058
    @mattharris2058 PÅ™ed 8 lety

    First, great video. Second, wrist pain.
    I don't get wrist pain for the same reason, but I think I have a solution. I tore my left TFCC (cartilage in the wrist). Ever since, I've had problems with pain. I bought a Goldtouch V2 Adjustable Keyboard and it literally solved all my issues. It looks incredibly weird (I've never met anyone that hasn't commented on it) and takes some getting used to, but it feels incredible. My first one lasted about 6 years (I think it broke in a box while moving, so I don't think it even gave out), and I just bought my second one a few months ago. I honestly swear by it. Writing this makes me think I should write a review lol.

  • @rico042002
    @rico042002 PÅ™ed 8 lety

    Great explanation of 'let' and 'const'. I'm only a few months into JavaScript programming and this was a great tutorial on ES6

  • @charmainetabilas3132
    @charmainetabilas3132 PÅ™ed 5 lety

    I'm super late but if you are still feeling pain in your hands/arms from coding/typing all day, try to keep your wrist at an angle below your elbows. Also try to stretch out your wrist and shoulders occasionally. Also take some time to do stretches that bring your shoulders back and traps down. (i.e. grab your hands together on your low back and pull them back). Simple but effective.
    These videos are so helpful and great though so thank you so much!

  • @mikedeakin7518
    @mikedeakin7518 PÅ™ed 8 lety +3

    I've been looking at ergonomics for a little while, and while I'm not an expert and definitely not a doctor (seriously, if you have any sort of regular pain; arm, wrist, legs, back, whatever; go see a doctor.) and lot of what's out there is speculation and hypothesis, but here's what I've learned.
    Step 1 is posture. I'm currently reading Deskbound (by Kelly Starrett) and the general theme is DON'T SIT! If possible, a standing desk with good posture should be more comfortable and better for you in the long run. If you need to sit, try an alternative to a chair such as a large ball (this will strengthen the core and align the spine naturally). REALLY need a chair? Make sure you're posture is tip-top, no slouching and no arching, and get up and move regularly (~every 15 mins).
    Desk height is also key, all the normal stuff. Keep the top of monitor at eye height, and the arms should be relaxed at 90 degrees, elbows just resting on the desk without lifting the shoulders. Don't use a wrist-rest! The weight of your forearm on your wrist, even padded, could exacerbate carpel tunnel issues more than help them! Weight should be spread as even as possible along the length of your arm. The mouse hand can pivot nicely from either the bony part of the wrist (pinkie side of the carpel tunnel) or the elbow.
    Speaking of mice, input devices! Vertical mice seem promising but I must say I'm not totally convinced (arms neutral, my palms rotate to point up, not inward or down). However, regular mice and touch-pads are known to be awful for wrist injuries. Everybody is different so if you know one mouse input gives you grief, try another (e.g. graphics tablets are a good option). One thing I've heard is to cycle through the input methods you have throughout the day. Keyboards are also an issue, for me in particular. A regular keyboard has my wrists in almost constant ulnar deviation (palms down, rotating outwards towards the pinkie) which gets very uncomfortable by the end of the day. A split/ergonomic keyboard should fix this (in theory) so I'm looking to get one asap.
    Hope this helps someone!

    • @jnfsmile
      @jnfsmile PÅ™ed 8 lety

      Posture is the part they call static load. The second is repetitive action. What +funfunfunction describes sounds more like something that happens from continuous typing, or usage of the mouse. As you've pointed out - doctors are best (they can give you sick leave etc...)

    • @ricardo.mazeto
      @ricardo.mazeto PÅ™ed 8 lety

      Hey, Interesting comment. Does this book says something about stretching?

    • @HarriMehtala
      @HarriMehtala PÅ™ed 5 lety

      Exercising daily and taking breaks often is the only thing that works for me. It doesn't have to be anything special, just some 5 min of body-weight exercises. Don't forget to work on your core. Use handles for pushups if you're having wrist pain. And don't overdo it! It's better to do 5-8 pushups every morning and evening than to do 20 at once and then not be able to train at all the next day.

  • @koltonIII
    @koltonIII PÅ™ed 3 lety

    hell yes. this is they type of instructing i am looking for. thank you

  • @richardtapan3950
    @richardtapan3950 PÅ™ed 6 lety

    Man I was reading a book about es6 and it was sooooo boring I almost fell asleep without actually learning, but when I watched this, I feel like Im learning alot more in less time. Thanks man, huge help!

  • @zackthoutt8457
    @zackthoutt8457 PÅ™ed 7 lety

    I had the same arm pains along with something akin to tennis elbow. I got a vertical mouse and had to do a series of weekly massages before everything went back to normal. I now stretch my arm muscles several times per day and try to exercise them in other ways to keep them feeling fresh.

  • @pascovicidinmoscova
    @pascovicidinmoscova PÅ™ed 5 lety

    I have a degree in Sports
    Forearm issue: inflamed muscles &&|| tendons
    Reason: Pronation of the hand while using the mouse and typing
    Forearm pain:
    1. Mouse: Try a larger(as in taller) one that permits a more claw like grip, this will make your hand rotate to a more neutral position => opposite of apple mouse, that's horrible
    2. Self-massage
    3. Stretching (try and find the angle where it hurts)
    3.0 Steps (I think for starters twice a day will yield results, you will figure out for yourself if you need more or less)
    3.1 Warm-up your forearm (movement with no pain)
    3.2 Light stretch (some pain is allowed)
    3.3 Gain mobility / Hard Stretch
    3.4 Don't go crazy on it, after several minutes you shouldn't feel more acute pain than before
    4+ There are some more techniques but the forearm being such a small muscle group they wouldn't help too much
    General muscle pain
    1. Eat enough proteins
    2. Try and not underdo too much the basics
    - Hydration
    - Sleep
    - Some vegetables in the diet
    Great vids btw

  • @lamecfletez7598
    @lamecfletez7598 PÅ™ed 7 lety

    I had carpal tunnel surgery in January. Your symptoms sound very similar to mine. I had arm pain, wrist and hand pain, numbness and loss of strength. You should visit an orthopedic surgeon. They have tests that can verify if it's carpal tunnel syndrome. Recovery wasn't fun but definitely worth it.

  • @willsi
    @willsi PÅ™ed 8 lety

    MPJ! My recommendation is lift weights. You don't have to lift for Strongman or join a gym, however activity will get blood-flow where needed and assist recovery in minor injuries. Stretching, swimming, moving the body in general helps. Love the video!

  • @ChrisRuzin
    @ChrisRuzin PÅ™ed 8 lety

    I was also having arm pain a couple years back, and what greatly helped me was learning to use a Kinesis Advantage keyboard along with a trackball mouse. The Advantage has the keys in a columnar layout and shaped like a bowl so your fingers don't have to travel as much. It took me a good week before I felt comfortable using it but now I can't stand any keyboard that isn't columnar.

  • @Loige_com
    @Loige_com PÅ™ed 8 lety

    finally a very in depth clarification of the differences between var, let and const! kudos for mentioning that const doesn't make object immutable, which at first is very counterintuitive.
    now you should do one about Object.freeze and deep-freeze 😋

  • @kaosmentalgeral
    @kaosmentalgeral PÅ™ed 7 lety

    I also have problems with this type of pain. What I started doing is switching the mouse hand from time to time. At first it is REALLY hard to use it with the other hand (but I had no choice, was finnishing my masters and had to keep writting my dissertation and coding). But nowadays I can use both hands
    with the same speed.
    I also noticed that puting my chair higher helped.
    Good luck!

  • @sunilsandhu6717
    @sunilsandhu6717 PÅ™ed 7 lety

    Subscribed to your channel after coming across this video - super educational, super entertaining and supremely accessible - you the funkiest!

  • @piratecourtney
    @piratecourtney PÅ™ed 7 lety

    An ergonomic mouse from Amazon is great and you can find them for around 20$, also you can give yourself a self-deep tissue massage by putting strong pressure on the places in your arm where you feel pain. If you feel a crunch, then try to breathe through the pain and work it out. If it's in your hand it's probably originating in the shoulder or even the chest or back. You don't want to hurt the other hand by over-exerting it on the pressure, so I push my body against the source of the pain on a chair arm, corner of a wall, or the pole of the subway car when I'm going to work.

  • @zhenwang4108
    @zhenwang4108 PÅ™ed 7 lety +1

    I was giving up on coding, but after I saw this, I think it might be just because of lack inner motivation... Thanks!

  • @SteveSchmechel
    @SteveSchmechel PÅ™ed 8 lety

    From where you are pointing, it could be ulnar nerve entrapment - not a doctor but I have dealt with that before. Initial cause is slouching posture for long hours that happens as you get tired. To get rid of it, plan on doing some massage and some back-strengthening exercises for quite some time. I highly recommend this book "It's Not Carpal Tunnel Syndrome! - RSI Theory and Therapy for Computer Professionals" by Suparna Damany and Jack Bellis.

  • @ivofs
    @ivofs PÅ™ed 8 lety +1

    Tips on dealing with arm pain (I'm not a doctor, just telling what I do since I had bad pain):
    1) Workout - Sorry dev fellas but the body need some exercise.
    2) Stretching - From time to time stop and do some streching (something like this: czcams.com/video/Ub0UQpPzttc/video.html).
    3) Trick your brain and try to use the mouse with the other hand. This is funny but you get used.
    4) Make sure you have enough space at the table to support your forearm when you are typing and using the mouse.
    Cheers

  • @CarloRizzante
    @CarloRizzante PÅ™ed 7 lety

    Kyle Simpson has written a neat explanation about how hoisting actually works (compilation vs execution) in his series of books "You Don't Know JS". Those books are an absolute must read for anyone who works in JS, even seasoned programmers can benefit from it.
    For the record, he has as well excellent arguments for the use of semicolons where the JS engine would put them. My argument is that ultimately semicolons communicate your intentions just like "const" do.
    Said that, thanks for your endless stream of video. It's really nice to see so much love for JS. I love it too :)

  • @satishramjee
    @satishramjee PÅ™ed 5 lety

    I had a similar problem with meta tarsals. Changed the mouse to use a trackball or a very small mouse and that helped so much that the pain went away.

  • @armenbakir112
    @armenbakir112 PÅ™ed 6 lety

    this guy rly help me through my biggest problem love you keep it up i am you a new fun

  • @everydayhustle6641
    @everydayhustle6641 PÅ™ed 8 lety

    You have a really fun channel. You make learning very digestible, thanks!

  • @zrajm
    @zrajm PÅ™ed 6 lety

    On the subject of arm pain: Place the mouse on the left hand side of the keyboard - this works by 1) spreading the workload between the hands (only slightly, if you're a terminal-minded person like me, but still) and 2) decreasing the distance you move your hand to reach the mouse (since normal keyboards are asymmetrical and stick out further to your right - with arrow keys, and numerical part).
    Also, make sure you arms are supported by your desk (don't hold them up by muscle force), and that your wrists are not bent (usually this entails putting your keyboard flat on the desktop surface and not folding out those small legs most keyboards have).

  • @vladanng
    @vladanng PÅ™ed 7 lety

    When he is making video 20 minutes length, you know you will watch it for one hour, not because of looking to understand problems and various situations, , but looking his facial expresions, movement, voices and shouts and constantly repeting them. Yes.

  • @Gjacolby83
    @Gjacolby83 PÅ™ed 8 lety

    Nice video! That was a great little explanation on those concepts. I now credit you with convincing me to start using let until I am wise enough to know when to use const.

  • @K4TaY
    @K4TaY PÅ™ed 5 mÄ›síci

    For your arm pain....get a yo-yo and make sure you use it properly by holding the yo-yo in your palm and throwing the yoyo down by facing your palm to the sky and rolling the yoyo out of your hand by extending and stretching your wrist backwards and rolling the yoyo off the end of your fingers. 15 years ago I thought I was being trolled by asking a reddit thread how to cure Carpal tunnel syndrome and was told by a russian programmer to get a yoyo. Once I learned the proper way to throw the yoyo, the pain subsided in 1 week after a doctor had just told me I would need surgery. I carry a yoyo with me in my backpack to this day and have never had the pain issues again!

  • @alanosman444
    @alanosman444 PÅ™ed 7 lety

    Very very nice.. thanks for re-teaching me Javascript basics in the most fun way.

  • @kpihus2
    @kpihus2 PÅ™ed 8 lety

    About pain in your primary arm, use trackball. With trackball, you basically have to move only your thumb, thus helps a lot. Logitech M540 is my personal favorite.

  • @2bitornot2bit73
    @2bitornot2bit73 PÅ™ed 6 lety

    I started using apple's magic mouse and it helped me a lot, it's height form factor did the trick for me

  • @josemaenzo
    @josemaenzo PÅ™ed 8 lety

    Great as usual. It would be nice if one episode is about immutability, with real life examples of how bad is mutate objects.

  • @simonprickett
    @simonprickett PÅ™ed 7 lety

    Hand pain idea... I have found the old school Microsoft Natural Keyboards to be fantastic, and I own several now. Takes some time to adjust typing style, but has helped me a lot and acts as good security as nobody else will want to use your workstation as it will ruin their typing speed.

  • @clarenceworley5125
    @clarenceworley5125 PÅ™ed 7 lety

    I enjoy your teaching style.. added you to my short list of go to youtube teachers.

  • @josemarin359
    @josemarin359 PÅ™ed 6 lety

    Thanks a lot for your great effort. It is really fun to watch. I love the role plays with different characters to see all the different angles. I have noticed the way you express your self with words that stress the reserve words you are explaining. It sparks my neurons and keep me focus. Interestingly I have watched a lot of your videos about the most complex subjects and such a basic thing as the proper use of const will increase the robutness of my code. I have been leaking so much unnecessary state in my code!!!! So I will go to basic.

  • @SystemCTRL
    @SystemCTRL PÅ™ed 8 lety

    Hand / arm issues related to long hours smashing your keyboard can be relived with the help of stretches and tender loving care.
    1. Stretch and do it often. Extend your arm straight out in front of you. Palm facing away from your chest and fingers pointed away from your feet. Take your other hand and apply pressure to your fingers so they are bend back toward your wrist. You can also reverse this by bending your hand and fingers downward. Do not over extend, listen to your body.
    2. Place hand / arm in warm water for 3 -5 minutes. After massage the muscles with you opposite hand.
    3. Take any anti inflammatory drug. (aspirin, ibuprofen) Not recommended for constant use. Haha get it, constant?...
    4. Take time away from your computer and change your working set-up. I personally use thumb controlled mouses. The ones with the ball and all you do is move your thumb to move the mouse cursor around.. anyone else use em? Helps wonders.

  • @Qbe_Root
    @Qbe_Root PÅ™ed 7 lety

    6:42 You’ll also have issues with lines starting with a bracket (e.g. an array destructuring assignment), a unary plus/minus operator (e.g. an expression that needs to be converted to a number but not stored for some reason?), though clearly the IIFE is the most common case. Basically, when you start a new line with a character that could also be part of the previous statement, start it with a semicolon instead because the JS engine will assume that you’re just breaking a single statement into several lines unless that really doesn’t make any sense. Also, here’s a pretty effective way to get your team to hate you:
    a
    ++
    b

  • @autochton
    @autochton PÅ™ed 8 lety

    If you type a lot, consider a wrist brace (handledsstöd). My wife uses these (she's an author), and they help a lot. She prefers the type with a metal support bar, you may find those are too stiff, but braces are available without.

  • @gabrielbalsa1843
    @gabrielbalsa1843 PÅ™ed 7 lety

    Excellent videos!
    I followed you on twitter first where I knew about FunFunFunction and I'm McLoving it! Keep it up!

  • @robsmith1184
    @robsmith1184 PÅ™ed 8 lety

    I find having an active lifestyle outside of work, lifting weights, swimming, climbing leave me with no pain from being at a desk all day.

  • @ChuckLeone
    @ChuckLeone PÅ™ed 7 lety

    I switched from a mouse to a Wacom tablet and my right wrist pain stopped pretty much immediately. Took about 2 weeks to get fully comfortable with a stylus and haven't used a mouse in 10 years. I'm now using Surface Studio and Surface Pros for all development and design work.

    • @Newportcouncilcyngorcasnewydd
      @Newportcouncilcyngorcasnewydd PÅ™ed 7 lety

      Hi Chuck,
      Interesting that you swapped that way as I did exactly the opposite back in 2003 as my tablet caused pains in my wrist until I added a gel pad for support. I'm not a designer though, so I have much more keyboard use and a decent sloped/padded one works for me. Something I've recently found is my tendons tighten up which is a whole different set of pain than the pins and needles. An over-tight watch strap is something to look out for!
      MPJ - thanks for a very entertaining and educational style. Learning plenty from your videos even though I'm an old dog ;-)

  • @NurseDaveBSMSON
    @NurseDaveBSMSON PÅ™ed 8 lety

    just wanted you to know you're a hit at our bootcamp.

  • @joycelu962
    @joycelu962 PÅ™ed 8 lety

    I never laughed this much when I watch a tech video. And what amazing is, you make the confusing things so much easier to understand. A BIG Thank You!
    You've talked about the const. Can you talk about how to save a global const? Like save user's uid after they login, and this value can be accessed from all the rest of the project?

    • @funfunfunction
      @funfunfunction  PÅ™ed 8 lety +1

      +Joyce Lu what you describe is not a constant, it will change if the user logs out and in. It mutates per definition. A constant is not the tool to manage what you describe. In fact, global variables is almost always bad engineering, because they make it extremely hard for you to track what code depends on what, and makes your application brittle, and hard to test and change. Instead of keeping global around you should prefer to pass such dependencies around as function arguments. When the amount of arguments that you pass around starts reaching cumbersome amounts, that exposes to you that you application is getting entangled and hard to manage. If you are using global variables to do the same thing, the mess is less visible and you are gradually digging yourself into a hole that will get harder and harder to get out of.

    • @joycelu962
      @joycelu962 PÅ™ed 8 lety

      Thank you for your reply. I guess I need to let go the global variable. Right now I'm using Firebase with Angular, which is AngularFire2. They have a method to get current logged in user. Seems like it's the way to go.
      I'm new to Functional Programming, it's killing me right now. But I definitely see its beauty and want to go with it.
      I don't know will you be interested in look into Angular 2 with new Firebase 3, to see is it possible to give us a lecture on how to use Functional Programming with AngularFire2? They return different type of Firebase Observable. I'd love to use the functional way to make my code clean, since AngularFire didn't return array, I don't know how to apply the functional programming to it.
      If you can make a lecture on this, that'd be awesome! And much appreciated, like those videos for the functional programming.
      With the Parse going out of the field, many are turn to Firebase, as it's much smaller compare to AWS. I'm sure many will be benefit from your lecture if you will give one. :)
      Please, think about it! Thank you!

  • @ManuelPenaloza
    @ManuelPenaloza PÅ™ed 8 lety +1

    I've been waiting for an explanation of this just like your's. Thank you!

  • @TheNzdavis
    @TheNzdavis PÅ™ed 6 lety

    I love the way you present your lectures. I'm like playing super mario on my switch at the same time learning. :D

  • @keithwins
    @keithwins PÅ™ed 8 lety

    for your arm pain -- the Microsoft comfort sculpt keyboard is awesome. best ergonomic ever, and I've tried a lot. make sure you get the sculpt comfort, there are a few sculpt models. it's the cool looking one too...

  • @AvindraGoolcharan
    @AvindraGoolcharan PÅ™ed 8 lety

    Not sure if you already know this one but CTRL + L does "clear" for you (works in any libreadline powered shells IIRC). So node and bash are covered.
    For your hands, try rock climbing. You'll exercise them in new ways and toughen them up.

  • @pleabargain
    @pleabargain PÅ™ed 7 lety +4

    1:30 nice use of the cursor highlight/ focus! Your production qualities continue to improve!

  • @TheMrChugger
    @TheMrChugger PÅ™ed 8 lety

    Glad to know I was using this correctly! Also great explanation of some of the internal JS scope behaviours. Crazy little language.

  • @pudd1ncat
    @pudd1ncat PÅ™ed 6 lety

    Just found your channel, you are such a great teacher. thank you for all your time!!!

  • @cesalberca
    @cesalberca PÅ™ed 8 lety +4

    I had the same problem Mattias! I just started swimming. The thing is some kind of pains on the wrists and the arms come from a bad sitting posture.

  • @Headifen
    @Headifen PÅ™ed 7 lety

    Thanks man, fun video! I wish I found this 6 months ago when I was banging my head against the wall on this stuff!!! Love the format and I learned a few things :).

  • @xcgalicia
    @xcgalicia PÅ™ed 6 lety

    I used to have problems with the pain and nasty sensation in my hands. I fixed that with YOGA.
    I discovered that everything is connected, so if you're feeling problems in your hands, you don't just need to exercise and stretch your hands but also your arms, and your neck, and your back, and your spine and your legs, and the reason for this is that everything in the body is connected so Yoga its a good remedy since it makes you stretch and excercise everything! Ive been doing Yoga for years, however not so disciplined, until i realize that it would help me with my hands problem so i had to start doing it at least three times a week and that definitely has cured me. If you're not into Yoga I'm sure you can try with Tai Chi or Kung Fu which are in the end very similar. Hope this helps others as much as it has helped me.

  • @HaakonHestness
    @HaakonHestness PÅ™ed 6 lety

    I solved my wrist pain that was headed for surgery with a trackball. Mice are deadly! I haven't had any symptoms since I started using it 10 years ago. I use the kensington expert mouse, which is a trackball with the large ball.

  • @Neppord
    @Neppord PÅ™ed 8 lety +10

    fantastic state rant!

  • @ThePolaris87
    @ThePolaris87 PÅ™ed 7 lety

    Thank you for clarifying this. You have gotten yourself a subscriber!

  • @justinr4650
    @justinr4650 PÅ™ed 6 lety

    Very well explained MPJ, you are the man!!

  • @samguliker6394
    @samguliker6394 PÅ™ed 7 lety

    Hee!
    I found out that Yoga works a lot for me. While I'm studying computer sciences accuires to sit around a lot the body is out of balance.I hope this helps, thanks for the great videos, keep them coming!

  • @joshuaesmero1464
    @joshuaesmero1464 PÅ™ed 7 lety +1

    best explanation I've found so far on this.

  • @ahwaliazizi
    @ahwaliazizi PÅ™ed 6 lety

    loved the dish washer example!

  • @srivastav_prince07
    @srivastav_prince07 PÅ™ed 6 lety

    Great explanation ! finally got my doubt cleared after watching this video , Thanks a lot.

  • @gtg502x
    @gtg502x PÅ™ed 7 lety

    Hi, the pain you are experiencing is likely due to Carpal Tunnel Syndrome. The bones in your wrist are called carpal bones. The bones are arranged in a circle, which makes up your wrist, and this circle has a hole in the middle, which forms the tunnel. This is similar to a doughnut. The tunnel has tendons and a nerve running inside of it. When you overwork your fingers, the tendons in the tunnel become inflamed, as you mentioned. When the tendons become inflamed, they get bigger. However, the tunnel is fixed in size and cannot expand. This causes a lot of pressure to build up inside the tunnel. The nerve in the tunnel ends up getting compressed and damaged, which causes the pain in your wrist and fingers. This is called Carpal Tunnel Syndrome.
    The way to avoid this is to put as little strain on your fingers as possible. I am a doctor who writes a lot of code, and I had carpel tunnel syndrome in the past. I was able to fix it by buying a keyboard with keys that have a low click force. I am currently using a mechanical keyboard with Cherry MX red switches that has an actuation force of 45g. I also replaced my mouse with one that has low click force buttons. Basically, if any buttons or keys are hard to press down, get rid of it. Thank you for the great video.

  • @MatiasBenavides
    @MatiasBenavides PÅ™ed 8 lety

    Now it would be cool that you show some techniques you use when programming. Like, mental steps you take before each problem you face. Or something (?)
    Great video!

  • @jtucker87
    @jtucker87 PÅ™ed 7 lety

    Just learned about redux. Ultimate way to reduce mutable states. Going to use it in my new project.

    • @funfunfunction
      @funfunfunction  PÅ™ed 7 lety

      +Jason Tucker it is very nice indeed. I don't know about ultimate, but it's one of the nicer ways we have found so far!

  • @SacrificialGoat94
    @SacrificialGoat94 PÅ™ed 7 lety

    Wow you are good at this! Entertaining and informative! I would argue that you over simplified the example with the washing machine (in hardware cosmic rays can flip bits etc. and software developers can't do anything about it), but it got the point through.

  • @mcalavera81
    @mcalavera81 PÅ™ed 8 lety

    Recommendations for hand pain/injuries:
    1. Using trackballs.
    2. Learn to use both hands
    3. Stretch arm and neck muscles.
    4. Taking breaks.

  • @doaashafik3073
    @doaashafik3073 PÅ™ed 5 lety

    any video I see in this channel is very useful
    thank you 💖

  • @anuragkothare6181
    @anuragkothare6181 PÅ™ed 6 lety

    So nicely explained. Good presentation. Loved it.

  • @PiotrZientara
    @PiotrZientara PÅ™ed 6 lety

    I had some pain in my arm too. I almost couldn't use the keyboard and it hurt me for longer than 3 months.
    There was a video on carpal tunnel syndrome yoga, with a 1 hour session which totally recovered me form this problem.
    Unfortunately this particular video is not on CZcams anymore but there are a lot of yoga sessions you can find and test.

  • @longtran12345678
    @longtran12345678 PÅ™ed 8 lety

    thanks a lot, very clear and fun to learn with your video every Monday

  • @ramiahviknesh3014
    @ramiahviknesh3014 PÅ™ed 6 lety

    Great video on Let,Const and Var

  • @pewpew_pew
    @pewpew_pew PÅ™ed 8 lety

    I use those selfrolling balls from the 90's (Gyrotwister or Powerball) before and after a workday of coding. It really helps to train the entire arm and hand. Some friends even use a medical wrist support, but it feels very strange to work a whole day with it. Maybe I just had the wrong one