14: How to Create JavaScript Functions | JavaScript User Defined Functions | JavaScript Tutorial

  Рет қаралды 120,285

Dani Krossing

Dani Krossing

Күн бұрын

How to Create JavaScript Functions | JavaScript User Defined Functions | JavaScript Tutorial. In this JavaScript tutorial you will learn how to build JavaScript functions.
A functions is used to create a block of JavaScript code which we can call upon at any time we want. JavaScript functions are also a great way to re-use code in order for us to save space in our file.
➤ GET ACCESS TO MY LESSON MATERIAL HERE!
First of all, thank you for all the support you have given me!
I am really glad to have such an awesome community on my channel. It motivates me to continue creating and uploading content! So thank you!
I am now using Patreon to share improved and updated lesson material, and for a small fee you can access all the material. I have worked hard, and done my best to help you understand what I teach.
I hope you will find it helpful :)
Material for this lesson: / lesson-material-42361704

Пікірлер: 125
@tjmariano_yt
@tjmariano_yt 5 жыл бұрын
This is my first ever KZbin comment and I just can't help it, I just wanna say I didn't skip any advertisement to show my support and love for this channel and to you, Daniel. Thank you for being amazing and continue being one. This channel is a blessing. Hearts!
@jackyzibozheng
@jackyzibozheng 4 жыл бұрын
shut the fuck up we dont needa see comments that dont benefit the viewers
@shashwatshandilya7853
@shashwatshandilya7853 4 жыл бұрын
@@jackyzibozheng bro why are u talking like that to her
@notitaadit
@notitaadit 4 жыл бұрын
@@jackyzibozheng Jeez calm down
@thatoneguy6812
@thatoneguy6812 3 жыл бұрын
@@shashwatshandilya7853 yeah, if you look at his channel he has one video and says "I rEaD BoOkS". the also has anime drawings in the background. i have no idea what his problem is tho
@IG7799-c4u
@IG7799-c4u 3 жыл бұрын
@@jackyzibozheng You could follow your own advice. How exactly does your comment "benefit the viewers"?
@mmelimahlobo7656
@mmelimahlobo7656 Жыл бұрын
Man this courss is old but hey its still has tremendous value❤
@cramseynyc
@cramseynyc 3 жыл бұрын
So glad I found you! I’m doing an online JavaScript boot camp and was having so much trouble understanding functions. This video made it so clear! Thank you thank you thank you!
@divinemasculine3730
@divinemasculine3730 3 жыл бұрын
same
@evansotika4761
@evansotika4761 4 жыл бұрын
I've realized how important programming is, but it needs alot of patience and time. Daniel you such a blessing to many coz you have every skill it would take to make a person understand your lesson. Wish I could get a certificate at the end.
@scottonanski4173
@scottonanski4173 3 жыл бұрын
Excellent explanation. Simple, clear, and right to the point. This is the hallmark of a good teacher. I don't think people realize how much easier their learning process is going to be when you have a teacher willing to provide accurate technical terminology for tokens used in code. It allows you to contextualize what you're being taught. I'm so impressed. Thank you!
@Panther-
@Panther- 3 жыл бұрын
Thank you so much, was doing a 6hour java script course, and new to it, one thing I find about some long courses is that sometimes they can get so long,that its good to go to another person and hear them explain it in their own way so it helps you get a better understanding as sometimes others leave stuff out..but great explanation that built upon what the other tutor spoke about
@blurocktech
@blurocktech 4 жыл бұрын
struggled to get a basic grasp of javascript functions for several days before coming to this video and finally it is sinking in. thank you so much for your videos, you're a great teacher.
@CHKotol
@CHKotol 3 жыл бұрын
I love this guy!!!! I 've been wanting to learn how to program for forever and this is the first video of many that actually gave me something useful.
@belinhobeli9569
@belinhobeli9569 5 жыл бұрын
You are so good at explaining. You can be a teacher :-)
@thecoderabbi
@thecoderabbi 4 жыл бұрын
Wow! This is explicit Thank you very much Dani. This is the simplest js tutorial I've seen. Keep being simple✌️
@poojajajerao5944
@poojajajerao5944 4 жыл бұрын
Thanks a lot. It helped me understand what functions are. Nobody explained like you.
@adrianamiquilena8790
@adrianamiquilena8790 5 жыл бұрын
You are a very good teacher. This episode was quite complicated and as a noob there are things I didnt get 100% but Ive been following the previous videos and I will continue with the rest and Im sure it will be worth it and I will be like "ooOOh, this is what he was saying in the last video!". Thanks for uploading these videos and for all your efforts in explaining
@yuriyzadorozhnyi3849
@yuriyzadorozhnyi3849 Жыл бұрын
Привіт Данії з України ! Дякую за цікавий контент і за можливість навчатися у Вас ! У Вас крутий канал !
@pvhtechno4497
@pvhtechno4497 6 жыл бұрын
very helpful bro thank you so much for uploading this...
@dteam3163
@dteam3163 5 жыл бұрын
Man..you r amazing I love the way u explain things I love everything u do I appreciate ur hard work Thank u so much.
@enriquesalomon8197
@enriquesalomon8197 4 жыл бұрын
I love the way you explain bro.
@mrboyban
@mrboyban 3 жыл бұрын
That was great! I was looking for the "re- like" button. Thanks
@mekdesmenji7049
@mekdesmenji7049 2 жыл бұрын
you're smart this is important for me
@renan6827
@renan6827 4 жыл бұрын
Thank you very much. I now understand functions. My struggle now is combine HTML with Javascript
@ehhteekaw6783
@ehhteekaw6783 4 жыл бұрын
i really love teaching, your explanation is really nice
@sathasivam7699
@sathasivam7699 5 жыл бұрын
Yeah this is very useful for us ...I love the way u explain
@israelgonzalez677
@israelgonzalez677 6 жыл бұрын
Loving this course!
@mauromatos3124
@mauromatos3124 3 жыл бұрын
Thank you Daniel for the fantastic content.
@georgelewis7326
@georgelewis7326 6 жыл бұрын
You are a phenomenal teacher! Keep up the good work!
@gustaavs
@gustaavs 2 жыл бұрын
This is so good! Thank you for explaining in such a good way!
@carldindial5369
@carldindial5369 3 жыл бұрын
Excellent. I appreciate the insight.
@gruicsraul05
@gruicsraul05 3 жыл бұрын
very well explained . Thanks a lot !
@dfjama
@dfjama 6 жыл бұрын
Awesome explanation, thanks Daniel
@whysoseriousjoker6727
@whysoseriousjoker6727 6 жыл бұрын
I love how u use your hands to explain things XD
@rajawikiaa
@rajawikiaa 5 жыл бұрын
He has some Mediterranean genes.
@abrahamjaimes7643
@abrahamjaimes7643 5 жыл бұрын
he looked stupid....!!
@sk8er332211
@sk8er332211 4 жыл бұрын
great explanation
@EAGEEYE321
@EAGEEYE321 4 жыл бұрын
if you want to appreciate his work then please don't skip ad. Thank You
@javieraguirre9135
@javieraguirre9135 4 жыл бұрын
man this course is great!
@noemisanchez6889
@noemisanchez6889 5 жыл бұрын
at 7:23 why doesn't it only log "Daniel" but includes the whole sentence? Wouldn't it be calling both name and testExample?
@TACH-ONE-ABISSINYA
@TACH-ONE-ABISSINYA 2 жыл бұрын
you are amazing thank u so much.....
@doubledmusic8104
@doubledmusic8104 4 жыл бұрын
Thank you so much Dani...
@Yolo_Swagins
@Yolo_Swagins 2 жыл бұрын
i saw someon eusing IIFE with () at the end like this: (function() { console.log('IIFE'); })(); So which metod is correct, or are both valid?
@jaycelila6258
@jaycelila6258 6 жыл бұрын
definitely you need more viewers!
@christianf2194
@christianf2194 4 жыл бұрын
You explain code very nicely. I always struggle understanding the meanings behind certain code when it is explained to me by a website.
@mnr100
@mnr100 6 жыл бұрын
Great!!! *Clear explanation*
@GilbertBigelow
@GilbertBigelow 5 жыл бұрын
Greatly appreciated, Thanks!
@Sophia-so6tm
@Sophia-so6tm 2 жыл бұрын
hi, how did you open the website and the console? mine also shows that localhost refused to connect. May you please help me?having a hard time
@nadasaeed7849
@nadasaeed7849 6 жыл бұрын
Thanks a lot! Very helpful
@mehulbhushan8799
@mehulbhushan8799 4 жыл бұрын
You are amazing!
@agnep1630
@agnep1630 5 жыл бұрын
wow now it all makes sense to me, thanks
@FrancisPerez-zf8mv
@FrancisPerez-zf8mv 5 жыл бұрын
Great video very helpful TY!
@anthonyrude
@anthonyrude 3 жыл бұрын
This is well explained for a non programmer as myself. I have some questions on how to best create a copy to clipboard script. If I join your channel would you help me with this?
@aaronargottelopez3488
@aaronargottelopez3488 2 жыл бұрын
Thanks!
@LorenHelgeson
@LorenHelgeson 5 жыл бұрын
Quick question. I have seen that third method used a few times (where everything is wrapped in parentheses), but what is the benefit of using it over the other two. I've seen plenty of uses for anonymous functions, and a named function is pretty self explanatory.
@MrCrowley_666
@MrCrowley_666 4 жыл бұрын
technically it is more efficient for the computer. Can be a bit ugly. I tend to use them for short functions
@carotravaglia
@carotravaglia 5 жыл бұрын
loved it! thanksss
@ashrafulfuad2967
@ashrafulfuad2967 6 жыл бұрын
So much helpful thank you sir so much thanks
@babrakoskei6134
@babrakoskei6134 3 жыл бұрын
huh...now i'm torn between who's the best programming instructor between you and Mosh!
@alexisfrantz7454
@alexisfrantz7454 5 жыл бұрын
Hi! My name is undefined love it xD
@chasegames4676
@chasegames4676 3 жыл бұрын
Omg I just figured it out. You're if Elon Musk and Johnny Depp had a baby!!!! Thats awesome!
@DevlogBill
@DevlogBill 2 жыл бұрын
You explained functions very well. I am a little confused about one thing? I think you called it "immediately invoked expressions"? I am trying to understand this concept. So, by putting the }() at the very end of the code break. The () acts like parameter for the entire function? I think I am explaining this the wrong way. I think I need to practice functions more for me to understand why its used, thank you.
@doragam5681
@doragam5681 5 жыл бұрын
please im stuck at laravel why do you add $request and things like $id inside the () this is the thing that is holding me back the parameters
@Rossboe1
@Rossboe1 6 жыл бұрын
Thanks dude.
@adolfjamesurian6510
@adolfjamesurian6510 4 жыл бұрын
Can u explain why u need to put num on the "function blabla(num)"???????
@adolfjamesurian6510
@adolfjamesurian6510 4 жыл бұрын
When you are making calculator
@patrykkedzierski9719
@patrykkedzierski9719 5 жыл бұрын
Y are good teacher Y have my sub
@brucescottyogaro6741
@brucescottyogaro6741 3 жыл бұрын
You awesome!
@pleasedontsub9700
@pleasedontsub9700 6 жыл бұрын
when would we need to use an immediately invoked function?
@jmido8
@jmido8 6 жыл бұрын
It's used for data privacy. Since it's a function it has it's own local scope and won't pollute the global scope. If you wrap all your code in an IIFE then you keep your variables inside a local scope where it won't conflict with outside variables from things such as libraries and frameworks. Or atleast that's my understanding of it, i'm still a beginner as well.
@pleasedontsub9700
@pleasedontsub9700 6 жыл бұрын
@@jmido8 thanks
@ALAMGIRHOSSAIN-fe1xu
@ALAMGIRHOSSAIN-fe1xu 4 жыл бұрын
nice
@iseeflowers
@iseeflowers 5 жыл бұрын
How come you put console.log() instead of document.write() ?
@Dani_Krossing
@Dani_Krossing 5 жыл бұрын
Document.Write replaces content on the website, where as console.Log is better when testing out JavaScript.
@techexpert2010
@techexpert2010 6 жыл бұрын
thanks a lot
@nandiabuya6503
@nandiabuya6503 3 жыл бұрын
superrrr
@barrettocosgrovo637
@barrettocosgrovo637 5 жыл бұрын
thanks
@geraldfoushee
@geraldfoushee 6 жыл бұрын
Daniel, hi me again....question...and i know i am not on the right video but i watch all your stuff lol...anyway.... for making a website responsive with the
@universal4334
@universal4334 4 жыл бұрын
When you working with grids you shoud create a meta tag
@zombesensenta4091
@zombesensenta4091 4 жыл бұрын
is it possible to use variables instead of functions
@Dani_Krossing
@Dani_Krossing 4 жыл бұрын
You can assign functions to values... but no, you can’t use variables “instead” of functions. :)
@alijawwad7169
@alijawwad7169 5 жыл бұрын
Can you please teach us how to make a JavaScript timer??
@malikd.mcnish6482
@malikd.mcnish6482 3 жыл бұрын
Great Vid, are you Australian btw, if yes fun fact, so Australians sound like Jamaicans in some few words
@tnetroP
@tnetroP 6 жыл бұрын
testExample() is witten in "camel case"
@muramasa7537
@muramasa7537 6 жыл бұрын
function sora(ripper){ var sasa = "Hi and shutup " + ripper; return sasa; }; console.log(sora("names")); var names = "Sam"; Here my prob is , the result shows Hi and shutup names What did i do wrong...
@Destroyer2134
@Destroyer2134 5 жыл бұрын
You use strings as parameter inside your function. If you want to use variable, delete the double quote.
@fadidib8516
@fadidib8516 2 жыл бұрын
Clean Code.hehe
@sandboy1794
@sandboy1794 4 жыл бұрын
when I wrote the quotes on var greeting = "Hello my name is Daniel" it appears yellow and its error its fucking making my brain explode trying to fix it
@austrianinvestor8024
@austrianinvestor8024 5 жыл бұрын
What is "hoisting"?
@josepharenas8905
@josepharenas8905 5 жыл бұрын
It is a behavior of javascript wherein variable declarations (and not assignments) are moved on top of the code when it runs.
@ПророкМухоед
@ПророкМухоед 5 жыл бұрын
JaaavaScript. Cooode. Oooor Beloooow. Retuuuurn.
@JD-kf2ki
@JD-kf2ki 4 жыл бұрын
Dude resembles Elon Musk at when young age.
@samirergaibi874
@samirergaibi874 6 жыл бұрын
Hi mate, nice tutorial! Your IIFE's parantheses are not the same as instructed on MDN, how come both of these examples work and which one is the correct one to use? developer.mozilla.org/en-US/docs/Glossary/IIFE
@Dani_Krossing
@Dani_Krossing 6 жыл бұрын
I think the reason it still works executing it the way I did in the video is because IIFE just needs to have a grouping pair of () and a invoking pair of () at the end. Either before or after closing the grouping parenthesis. Use the one from MDN :) It is better to not interlace the two set of parenthesis, even if it does still work. It makes for cleaner code.
@percentvthinker1664
@percentvthinker1664 2 жыл бұрын
#SelfInvoking
@rupamj_das
@rupamj_das 6 жыл бұрын
1st 😃😃
@acethomas5774
@acethomas5774 4 жыл бұрын
Is there anyone here in the comments section know how to do JavaScript functions for online game I can give you examples of what I’m talking about because the game that I play has many elements to it
@taureon_
@taureon_ 6 жыл бұрын
i made this and it does not work, help var name = "Samuel"; function testExample(b) { var greeting = "Hi! My name is " + b; } console.log(testExample(name));
@ermalermali6466
@ermalermali6466 5 жыл бұрын
i made this and it does not work, help var name = "Samuel"; function testExample(b) { var greeting = "Hi! My name is " + b; return greeting; } console.log(testExample(name));
@josepharenas8905
@josepharenas8905 5 жыл бұрын
@@ermalermali6466 Works just fine to me.
@navaneethankalidoss5010
@navaneethankalidoss5010 5 жыл бұрын
var name = "Samuel"; function testExample(b) { var greeting = "Hi! My name is " + b; return greeting; } console.log(testExample(name)); You have to add return so that the value of var greeting will be stored in function testExample(b).
@Alluriah
@Alluriah 5 жыл бұрын
@@ermalermali6466 should work fine: add it command by command (if using the console log in chrome)so start with var name, then the whole function definition, enter and finally your console.log command; but in your example it only works for name= Samuel that you already defined, if you erase the first line and just let b take on any name then you can at the end go console.log (testExample("Mark")) or console.log (testExample("Jane")) etc and it should all work.
@acethomas5774
@acethomas5774 5 жыл бұрын
SAMUEL GAMING Do you know how to write JavaScript functions setInterval for an online game
@eldrain88
@eldrain88 3 жыл бұрын
I just realized that function is the same as in the math
@williamjamesrapp7356
@williamjamesrapp7356 6 жыл бұрын
I have a BIG ***FUNCTIONS*** question if anyone can help me --- I am building a database driven web site. When a person enters DATA into the database on FORM #1 & FORM #4 -- entering that data is FREE to enter. When a person enters DATA into the database on FORM #2 & FORM #3 -- After Filling out the FORM then instead of pressing SUBMIT -- They press NEXT -- then they are taken to a PAYMENT PAGE FORM -- SAY - PAYPAL or CREDIT CARD ... Then when they FIll Out the Payment method they then press SUBMIT ( HOWEVER ) their data is NOT YET submitted into the database until PAYMENT CONFIRMATION APPEARS ((( THEN THEIR DATA IS SUBMITTED INTO THE DATABASE ))) I am using a LINK to the payment page when they press NEXT AFTER THAT I DO NOT KNOW HOW TO CODE THE FUNCTION OF SUBMISSION TO DATABASE CAN ANYONE HELP ME WITH THIS ???
@ermalermali6466
@ermalermali6466 5 жыл бұрын
i don't think i would make payment,and db access with JS that is not secure at all...your code is literally open source...
@williamjamesrapp7356
@williamjamesrapp7356 5 жыл бұрын
@@ermalermali6466 Thank you for that information -- The PAYMENT PROCESS is through standard Payment systems such as PAYPAL and CREDIT CARD payment processing -- My question is ONCE THE PAYMENT IS MADE ( through approved payment processing ) How do I THEN AFTER PAYMENT IS MADE allow the data to then go into the database ---- I AM WORKING ON A ***WIX*** web site and JS is all WIX will allow for functions.
@cmdrgarbage1895
@cmdrgarbage1895 5 жыл бұрын
@@williamjamesrapp7356 I guess if you're a beginner you want to look into php and SQL
@acethomas5774
@acethomas5774 4 жыл бұрын
Can anyone here in the comments help me with some JavaScript functions for this online game that I play
@tonikaramanliev884
@tonikaramanliev884 4 жыл бұрын
Why is this free?
@gabrielmatos2606
@gabrielmatos2606 3 жыл бұрын
Be a teacher, Make millions, gg.
@hafsakhalil7458
@hafsakhalil7458 4 жыл бұрын
you were too fast i got sleep
@erichernandez38
@erichernandez38 3 жыл бұрын
this man confused me so bad i dont even know he said the value is stored at the top i have no idea but ok
@Dani_Krossing
@Dani_Krossing 3 жыл бұрын
I understand your confusion 😊 But like I said in the sentence directly after the one you are referring to... "Hoisting is something we will talk about in a later episode". So you aren't expected to know what I mean just quite yet when I say "the value is stored at the top". I completely understand how you could have missed that, since I do talk about a lot of "JS theory" in this specific video hehe 😊 No worries, you WILL get to learn more about it in a later episode like I mentioned 🙂
@p.c.principal7324
@p.c.principal7324 5 жыл бұрын
i think im gay
@fieteschwettmann9302
@fieteschwettmann9302 5 жыл бұрын
TheTruthsayer that was a joke! I like how je eplains and what je eplains🤦‍♂️
@hospitalpark4461
@hospitalpark4461 6 жыл бұрын
In all honesty, I find the hands to be a distraction and put something over your image. Your content is very good, just pointing out that I'm trying to learn this material, not look at hands flipping around.
@SabbirHasan-uu7wr
@SabbirHasan-uu7wr 6 жыл бұрын
Same picture every thumbnail doesn't really looks awesome dude
@Dani_Krossing
@Dani_Krossing 6 жыл бұрын
Thanks...
@chescaramos1095
@chescaramos1095 6 жыл бұрын
It's a reminder that it's a tutorial about ___________
@ddotdollaz
@ddotdollaz 6 жыл бұрын
var sabbir = "idiot"; console.log(sabbir.goAway());
@madballer101
@madballer101 2 жыл бұрын
Please help me with my code it isn't working! I am trying to figure out the definition of a woman! function whatIsWoman(){ let woman = "Someone who thinks they are " + woman; return woman; } console.log(whatIsWoman()); // Someone who thinks they are undefined
#34 What are JS Functions? | JavaScript Full Tutorial
13:52
Dev Dreamer
Рет қаралды 14 М.
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19
IL'HAN - Qalqam | Official Music Video
03:17
Ilhan Ihsanov
Рет қаралды 700 М.
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
Try this prank with your friends 😂 @karina-kola
00:18
Andrey Grechka
Рет қаралды 9 МЛН
JavaScript FUNCTIONS are easy! 📞
12:14
Bro Code
Рет қаралды 51 М.
How To Create/Use Functions - JavaScript Essentials
9:34
Web Dev Simplified
Рет қаралды 146 М.
Javascript Functions & Parameters | Javascript Tutorial For Beginners
14:27
JavaScript Functions Crash Course
1:36:54
freeCodeCamp.org
Рет қаралды 199 М.
#39 Understanding JavaScript Scope | JavaScript Full Tutorial
16:11
All The JavaScript You Need To Know For React (More JS To Know)
18:19
#46 How to use Arrow Functions | JavaScript Full Tutorial
13:01
Dev Dreamer
Рет қаралды 9 М.
If statements in JavaScript are easy 🤔
15:58
Bro Code
Рет қаралды 48 М.
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19