7 different ways to write JavaScript functions (explained for beginners)

  Рет қаралды 1,735

Code With Bubb

Code With Bubb

Күн бұрын

Пікірлер: 26
@codewithbubb
@codewithbubb Жыл бұрын
I have this written up as a blog article but I can't build my site at the moment! I'll add a link to it once I can publish the article!
@MuhammadOsama-f7r
@MuhammadOsama-f7r Жыл бұрын
hello Brother, Brother, I am stuck in javascript functions for so long I mean for four days and this issue is not getting clear. Brother I recorded the video of my problem because it would then get hard for me to type my problem in detail here. just give me some source so I could share a video with you. Here's the code. (This is the solved version. but I am not still cleared). ``` function add(number){ const sum = number + number; return sum; } const result = add(5); console.log(result); ``` and except all this. You are legend. Lot's of love.
@codewithbubb
@codewithbubb Жыл бұрын
Hey, thanks for your message. What were you having problems with exactly? Are you stuck understanding functions in JavaScript?
@djlee0721
@djlee0721 Жыл бұрын
Another great video 🙌🏻
@codewithbubb
@codewithbubb Жыл бұрын
Ah, thanks very much Daniel - appreciate the support!
@BloodyClash
@BloodyClash Жыл бұрын
😁usually i quit when people call javascript a programming language. but this time...was interesting to see how much javascript already has gotten from its big brother
@codewithbubb
@codewithbubb Жыл бұрын
Cool, and what are your thoughts on JavaScript now? (Also, thanks for being a long time subscriber 😀)
@BloodyClash
@BloodyClash Жыл бұрын
@@codewithbubb i do like javascript. used it for some small web thingies in the past and since i love java i have to like its relatives, too 😁
@CheefCoach
@CheefCoach Жыл бұрын
The first way is the best way to write functions. Unless you are inside of class, object or callback.
@codewithbubb
@codewithbubb Жыл бұрын
Thanks Aleksandar! Definitely using the function keyword makes it obvious what you’re doing in your JavaScript code.
@Shehjeishiwwhbememd
@Shehjeishiwwhbememd Жыл бұрын
❤thanks
@codewithbubb
@codewithbubb Жыл бұрын
You're welcome! Hope you find it useful.
@oukiebotha2227
@oukiebotha2227 Жыл бұрын
Hi James. Agree, great video, thanks, 🙏🙏. I thought a function declaration is the way to go. Still struggling to understand and practice arrow functions. You are an excellent teacher with a great t shirt😂😂,😊😊👍👍
@codewithbubb
@codewithbubb Жыл бұрын
Hey Oukie, yeah nothing wrong with them as such but there are better options 😊. Yeah, arrow functions are really confusing at first but you'll get the hang of them I'm sure. Thanks again for the support!
@oukiebotha2227
@oukiebotha2227 Жыл бұрын
Hi James. Trust you are doing well. Please encourage me not to beat up the neighbour😊😊, because i had a terrible week with JS. None of my projects are running, none.😡😡. I am frustrated. I code about 3 hours every night, and with projects not running, that's a big NO for me. Have a good weekend and i hope the neighbour is out of town😂😂. Best regards.🖐️🖐️
@codewithbubb
@codewithbubb Жыл бұрын
Glad i'm not your neighbour! But seriously, I think everyone has those time (I do even now) when you feel like nothing is working and you know nothing. The best thing to do is to take a bit of a break and not get frustrated and understand that it's normal when learning something new. If there's anything I can help with then just let me know!
@benb3928
@benb3928 Жыл бұрын
aw to no closures, __prototype__ or .apply for types 8.9, and 10
@codewithbubb
@codewithbubb Жыл бұрын
That would be some worthy additons 🤓
@amiranGo
@amiranGo Жыл бұрын
Protip: Almost never use `this` unless you're actually in a Class. Even with the example of the factorial you provided, you're better off with just referring to the object itself: const myMath = { factorial(n) { if (n === 0) return 1; return n * myMath.factorial(n - 1); } } This way, you can also destruct the function out of the object and it will still work: const { factorial } = myMath; factorial(5)
@codewithbubb
@codewithbubb Жыл бұрын
Thanks for sharing 😉
@harpo187bling
@harpo187bling Жыл бұрын
Nice t-shirt.
@codewithbubb
@codewithbubb Жыл бұрын
Haha! Thanks. From Amazon if I remember.
@inteltone
@inteltone Жыл бұрын
Very useful information, but its presentation makes it very difficult to understand. The material is told and shown too quickly. For a beginner to understand it, you need to watch the video 2-3 times or even more.
@codewithbubb
@codewithbubb Жыл бұрын
Hey, thanks so much for your feedback. Really appreciate it. Yes, I agree with you - when I was editing I was thinking "this is a lot of information delivered very quickly!". I hope you'll agree though that it is tricky to slow down, give details and still keep people engaged (as everyone has short attention spans these days!) and making this content 20,30 or 40 minutes long might put other people off also. Kinda tricky to get the balance 🤔
@fritiofrusck
@fritiofrusck Жыл бұрын
eval(" function foo() { return \"bar\"; } ")
@codewithbubb
@codewithbubb Жыл бұрын
Haha! Yes, should have mentioned that 😀
My complete beginner’s guide to using JavaScript with the DOM
43:24
Beginners Should Think Differently When Writing Golang
11:35
Anthony GG
Рет қаралды 124 М.
Миллионер | 3 - серия
36:09
Million Show
Рет қаралды 2,2 МЛН
Мама у нас строгая
00:20
VAVAN
Рет қаралды 11 МЛН
Javascript Functions & Parameters | Javascript Tutorial For Beginners
14:27
What Is Abstraction in Computer Science
6:24
Codexpanse with Rakhim
Рет қаралды 97 М.
Inheritance in JavaScript - Prototypal Inheritance tutorial
20:06
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 828 М.
5 MUST KNOW JavaScript Object Functions
10:42
dcode
Рет қаралды 29 М.
3 Coding Secrets I Wish I Knew Earlier
9:38
Code With Bubb
Рет қаралды 1,1 М.
My 10 “Clean” Code Principles (Start These Now)
15:12
Conner Ardman
Рет қаралды 289 М.
Миллионер | 3 - серия
36:09
Million Show
Рет қаралды 2,2 МЛН