For the first one, removing the curly braces will also fix the error by relying on the implicit return mechanism of concise body arrow functions. This is specific to arrow functions, and can only be used if the function can be written as a single expression. If you need a block body, you do need an explicit return statement. Just thought it's worth mentioning because people might come across code that looks almost like the example but which actually works.
I have been working in the industry for a couple of years now. Most of what you mentioned would have been very helpful to know back when I started. I admit there are a couple of those that I still struggle to remember to do, i.e. handling errors and knowing if a method or extension is a mutator or asynchronous. Thanks for the reminders and for making me aware of how much I have grown as a developer. Things like this help me to prepare for being a better mentor as well. I think it is easy for us to forget what the exact struggles we went through on our journey. Your videos are always helpful in either teaching something new, reminding me to do things the right way, or keeping me aware of the things I should help pass down to the next new developer. Thank you, James!!!
Thanks for the useful video, Just a quick note in 9:50 condition of for loop i must be less than names.length not arr.length also in second line access to it by names[i] not arr[i]
Thank you, as I watch many people, I've learned shorter ways, but not always the best or most descriptive, here are a few. - defer your js file like so. in the Head. - isOdd can be shorter like so, const isOdd = num => (num % 2 === 1) - err && console.error(err)
or, if this should be even shorter "const isOdd = num => num % 2" I would not call this great but it works because 0 == false and 1 == true are both true
First of all, I would like to wish you good luck on this "new path" working full time here. I hope you enjoy it and that you have way more return than effort making these awesome videos. Also I'm quite happy to realise that I usually don't make most of these mistakes and as a beginner it's hell of incentive. Thanks James, for real!!!
Excellent video ! Thanks for sharing, James. Using most of these "pitfalls" during a first interview .. Just as an info ... JS Juniors sometimes also are getting "blocked" when seeing a try... catch... finally structure... Might need some explanation as well.
I would put into beginner mistakes as well when someone creating a variable with an anonymous function as a value instead of using function keyword. :) joking apart, could you please explain why do you prefer anonym functions as variables than named functions? the former is a function acting as data. why using a function as a data when there is a way to create a function just to be a function? ...and functions with names are better for debugging. functions as data should be used for example to work with higher-order functions.
20:00 and 23:15, Objects in JS, unlike primitive types, are passed by reference, then you are, essentially, messing with the same object. Be careful here.
I’m not sure where exactly you’re going here? I specifically talk about objects being passed by reference and show an example of how they’re equal if you assign one variable to another variable that is an ovjsct
He said in other comment that is correct, but avoided to mention it in the video for considering it a little not "beginner-friendly". Anyway, you're right, the defer attribute would do the trick.
In this example you gave concerning the object vs primitives comparison, is this situation only specific to objects, or does it include other non-primitive data types?
Hmm, you could create a snippet in VS Code? I feel like that would be tough though because what would the trigger for that snippet be? It's hard to get a trigger much shorter than const I would think.
I just created a global "user snippets" file so typing co then enter generates const, typing le then enter generates let (just for mental consistency). I'll see how it goes haha
i will make my recommendation before watching the whole video, when you guys are programming in JS, use a well configured linter, like ES lint for example, it can show bad javascript in red (like errors) it will compile anyways, but you will have the chance to correct them before compiling.
In "Cannot Read Property of Undefined", how about using optional chaining: function printName(person) { let name = person?.name; console.log(name?name:'Unknown person'); }
Javascript is a weird programming language, one has to know certain strange behavior to achieve the desired result. But despite its bad design and syntax its still number 1 web application programming language.
Because my functions usually return nothing. I also didn't know that 'some text' % 2 may return something not int. I knew so many good things, so I can ask for a raise now.
Why use anything other than VS Code these days? May not be the best or perfect, but does run on windows, mac, unix and supports nearly any language one might care for...
Check out the full Source Code 👉 join.replit.com/jamesqquick
For the first one, removing the curly braces will also fix the error by relying on the implicit return mechanism of concise body arrow functions. This is specific to arrow functions, and can only be used if the function can be written as a single expression. If you need a block body, you do need an explicit return statement. Just thought it's worth mentioning because people might come across code that looks almost like the example but which actually works.
Yep arrow functions syntax would definitely simplify that
Just a small note, you can keep script in the head of the document, but you should add defer attribute to it and it would solve the issue)
Yep. Agreed. Figured that wasn’t as beginner friendly but I did refer to that in the blog post. Great suggestion!
He def mentioned this in the video lol
I have been working in the industry for a couple of years now. Most of what you mentioned would have been very helpful to know back when I started. I admit there are a couple of those that I still struggle to remember to do, i.e. handling errors and knowing if a method or extension is a mutator or asynchronous. Thanks for the reminders and for making me aware of how much I have grown as a developer. Things like this help me to prepare for being a better mentor as well. I think it is easy for us to forget what the exact struggles we went through on our journey. Your videos are always helpful in either teaching something new, reminding me to do things the right way, or keeping me aware of the things I should help pass down to the next new developer.
Thank you, James!!!
So glad you found this helpb
Thanks for the useful video, Just a quick note in 9:50 condition of for loop i must be less than names.length not arr.length also in second line access to it by names[i] not arr[i]
Ah yes great question!
Thanks, it was great to see I'm not alone making these beginner's mistakes! Great way of explaining!
Thank you, as I watch many people, I've learned shorter ways, but not always the best or most descriptive, here are a few.
- defer your js file like so. in the Head.
- isOdd can be shorter like so, const isOdd = num => (num % 2 === 1)
- err && console.error(err)
All very true!
or, if this should be even shorter "const isOdd = num => num % 2" I would not call this great but it works because 0 == false and 1 == true are both true
First of all, I would like to wish you good luck on this "new path" working full time here.
I hope you enjoy it and that you have way more return than effort making these awesome videos.
Also I'm quite happy to realise that I usually don't make most of these mistakes and as a beginner
it's hell of incentive. Thanks James, for real!!!
Thank you so much :)
Note: arrow functions DO return values (implicitly). This would have worked "const getAddedValue = (a, b) => a + b" without using return.
Excellent video !
Thanks for sharing, James.
Using most of these "pitfalls" during a first interview ..
Just as an info ...
JS Juniors sometimes also are getting "blocked" when seeing a try... catch... finally structure...
Might need some explanation as well.
Great point! Thanks for sharing that.
The biggest mistake that I personally make is not coding every, single, day. Gotta be in it to win it, thanks @James Q Quick! 💪🏻
Anytime! :)
I would put into beginner mistakes as well when someone creating a variable with an anonymous function as a value instead of using function keyword. :)
joking apart, could you please explain why do you prefer anonym functions as variables than named functions? the former is a function acting as data. why using a function as a data when there is a way to create a function just to be a function? ...and functions with names are better for debugging. functions as data should be used for example to work with higher-order functions.
Honestly, it's just a preference for me syntactically. I wouldn't say I have a great logical reason lol
both these guys are in the same room!!!
Thank you. Interesting. In the hasEvenNumber function, the retVal variable remained, which is not used
Thanks
Always happy to see cap guy making his cameo!
youre the man mil gracias !!
You're very welcome!
Thanks for the video
20:00 and 23:15, Objects in JS, unlike primitive types, are passed by reference, then you are, essentially, messing with the same object. Be careful here.
I’m not sure where exactly you’re going here? I specifically talk about objects being passed by reference and show an example of how they’re equal if you assign one variable to another variable that is an ovjsct
@@JamesQQuick only reinforce this concept after read some comments. BTW I really like your style. Subscribed for along time.
I’ve been told it’s better practice to store the JS file in the head with all other meta data and just defer it. What are your thoughts?
He said in other comment that is correct, but avoided to mention it in the video for considering it a little not "beginner-friendly". Anyway, you're right, the defer attribute would do the trick.
Hahaha I like that you talk to yourself :)
Amazing @James Q Quick It was awesome I did learn a lot thank you so much Amazing chanell
10:25 i have "problem" with event listeners.. sometimes 30 lines ans more :(
08:22 Could anyone explain what is James explaining about, I'm unable to understand
In this example you gave concerning the object vs primitives comparison, is this situation only specific to objects, or does it include other non-primitive data types?
thanks
would you ever make a video like this about React? I'm going through it currently and trying to avoid the crap I did with vanilla 😅
That's a great question. I'll think through that :) Any mistakes you would add to the beginner React mistakes list?
Hi James, in VS Code what’s the fastest way to type “const” … is there a shortcut? Like, a way to generate it faster than typing 5 chars.
Hmm, you could create a snippet in VS Code? I feel like that would be tough though because what would the trigger for that snippet be? It's hard to get a trigger much shorter than const I would think.
I just created a global "user snippets" file so typing co then enter generates const, typing le then enter generates let (just for mental consistency). I'll see how it goes haha
@@tedfitzpatrickyt Yeah I just wondered about that beign super generic, but i think you got it!
Replit looks pretty cool. However, that white theme is burning a hole in my retina :-D Option for dark?
Ok I found it. There is a dark mode. Whew ;-)
That was a close call haha
i will make my recommendation before watching the whole video, when you guys are programming in JS, use a well configured linter, like ES lint for example, it can show bad javascript in red (like errors) it will compile anyways, but you will have the chance to correct them before compiling.
Video Se Excellent But can you add some syllable Stress On your English speaking 🐏 it'll Really Help
In "Cannot Read Property of Undefined", how about using optional chaining:
function printName(person) {
let name = person?.name;
console.log(name?name:'Unknown person');
}
Nevermind, you mentioned it right after the first method.
bahaha love these two comments!
Still great to see this stuff
Glad you enjoyed it!
Javascript is a weird programming language, one has to know certain strange behavior to achieve the desired result. But despite its bad design and syntax its still number 1 web application programming language.
awesome
Line 80 @ 10:00, you have changed arr to names, but not in the ***Better*** code.
Ah great catch! Updated now :)
Because my functions usually return nothing. I also didn't know that 'some text' % 2 may return something not int. I knew so many good things, so I can ask for a raise now.
Do it!
7. unnecessary return. Even shorter (use implicit return, skip optional paren) "const isOdd = num => num % 2 === 1"
Yes i face same in beginning 💪👍
Glad to hear it was relevant :)
HTML and CSS Layout -
czcams.com/video/4l7jUOc-2QQ/video.html
Why use anything other than VS Code these days? May not be the best or perfect, but does run on windows, mac, unix and supports nearly any language one might care for...
Too bright lol
The webpage you mean?