A function is about the same as a method in Java. So what's the big deal about what you wrote? You moved the { up one line??? Oooooooo man that's impressive.
you are a very good teacher and i really enjoy learning from your videos but can you please STOP using alert boxes for examples and do other examples than that. thanks
There would be no differences if what you want to do is that simple.
Using function would make a difference if you want to do something more complex.
Like:
function sayhi(){
var name = promt("what is your name?");
document.write("Hi " + name + "!");
}
sayhi(); sayhi();
function is used for something that is not as simple as the example. This example is just to give you some understanding about how to use and how to construct a function.
@MrCritic17 It would do the same job...Every language works the same. They execute the code line by line, depending if it is in a function or not. When your browser open a page the javascript is not executed on the load automaticly IF it is in a function, else if your javascript is not in a function it will be executed on the load of your page. Functions need to be called and in this tutorial he actually call the function on the load but usually we call function on an evenement
@drkmaster0 He's saving it to an .html file that he already has loaded into his browser. After he saves the file, he just refreshes the page to reload the code.
You're awesome!!! :D
crafter681 3 weeks ago
@ 3.53 its not embarrassing dude...we all learn from our mistake....its a lesson for all of us too ^_^ keep rocking!!!
futureprogrammer27 1 month ago
Keep up the great work....
nirjonahmed 2 months ago
This has been flagged as spam show
Gim3 Th8mbs \./p 7o\./ n00bs. G3t A 1ife y0r n0t 1337.
Reply if you can read this!
colll78 3 months ago
Gim3 T8mbs \./p 7o\./ n00bs. G3t A 1ife y0r n0t 1337.
Reply if you can read this!
colll78 3 months ago
Hey now brown cow!
Sagichnich95 4 months ago
superb fogtalk99%
FOGTALK 4 months ago
hahah nice video
Balsam0506 4 months ago
@314rce shutup kid I was just telling him how I do it
xxcky1 5 months ago
Because I do Java I write my stuff as:
function bob(){
blahblah
}
xxcky1 6 months ago
@xxcky1
A function is about the same as a method in Java. So what's the big deal about what you wrote? You moved the { up one line??? Oooooooo man that's impressive.
314rce 5 months ago
@314rce Shutup kid
xxcky1 5 months ago
@xxcky1 Excellent comeback. Very well-crafted.
314rce 5 months ago
@314rce You're a complete idiot
DarkGhoul45 1 month ago
@xxcky1 I do the same thing.
RASHTG 5 months ago
what program are you using for javascript?
izandjukicBRE 8 months ago
@izandjukicBRE notepad++ :) hope i helped
THEXMAN4509 7 months ago
How to spam your friends, no virus, just for fun :P
Type this in the browser website bar (without the enters):
javascript:function cake(){alert("GOTHA N000000000000B"); cartman();} function cartman(){alert("Seriously, you SUCK!"); cake();} cake();
Note that this nearly only work on windows internet explorer or any firefox version later than 4.01
cACTIfARM 9 months ago
tnx bro
ellaniemontebon 9 months ago
please upload videos for svgs and write and read a file using java script
gelliravikumar018 10 months ago
thank dude, I wish you also have a assembly language tutorial.
greatveemonGFX 11 months ago
I love these tutorials!!!
emnic1 11 months ago
2 people are brown cows
noelsoong777 1 year ago 6
Thanks. Learned Python, a little PHP (will go learn more), some CSS (wish you would make more), and now learning Javascript! Great teacher!
amah4444 1 year ago
you are a very good teacher and i really enjoy learning from your videos but can you please STOP using alert boxes for examples and do other examples than that. thanks
chathamfatboy12 1 year ago
@chathamfatboy12
alert("He does it as a way to visually show what the code is doing and to make debugging easy");
you could also use it to write a trace function for examining your code later on.
edmondxmosoon 10 months ago
lol u wrote say and got embarressed?!?!?!?!? OMG I MISSPELL SO MUCH ITS SAD!!!! dont u guys?
drju984 1 year ago
the synt. for function is ....... function ^^ hahaha
DaFaProductionz 1 year ago
WOOHOO!!!!1 NUMBER 11TH VIDEO, AND I STILL HAVEN'T LEARNED ANYTHING COOL. BUT YOU KNOW WHAT, I HAVE LEARNED SO THANK YOU VERY MUCH!!! : )
MrJangIes 1 year ago
you can name it asdfjkl if you wanted to :D
noelsoong777 1 year ago
your toturials are great, thank you so much!
Parinazshahrzad 1 year ago
Is there a difference between...
var sayhi="how now brown cow";
alert(sayhi);
alert("are you still watching this?");
alert(sayhi);
and what you / he did?
MrCritic17 1 year ago
@MrCritic17
There would be no differences if what you want to do is that simple.
Using function would make a difference if you want to do something more complex.
Like:
function sayhi(){
var name = promt("what is your name?");
document.write("Hi " + name + "!");
}
sayhi(); sayhi();
function is used for something that is not as simple as the example. This example is just to give you some understanding about how to use and how to construct a function.
TheCTCentury 1 year ago 14
Comment removed
B1KMusic 1 month ago
Comment removed
B1KMusic 1 month ago
@TheCTCentury
A more extreme example:
function hello(x){
for(i=0;i<x;i++){
document.write("There are deep lacerations where ALIENS HAVE TAKEN OVER HIS BWODY! HU-WHAAAAAT!?")
}
}
hello(9001)
it's over 9000
B1KMusic 1 month ago
@MrCritic17 No there isn't. But when you start coding and have longer functions other than just one alert then they come in handy.
OceanicViewStudios 1 year ago
@MrCritic17 It would do the same job...Every language works the same. They execute the code line by line, depending if it is in a function or not. When your browser open a page the javascript is not executed on the load automaticly IF it is in a function, else if your javascript is not in a function it will be executed on the load of your page. Functions need to be called and in this tutorial he actually call the function on the load but usually we call function on an evenement
marcky89869 1 year ago
embarrassing, you last spelt false as flase.
oliverjamescarr 1 year ago
This:
()
is not two empty parameters lol...... :P
iTheEliteOne 1 year ago
this function script will save 2 things, time and memory for the computer, thanks
mms1911 1 year ago
How do you view your javascript? I notice you hit save, then refresh that page, and it appears but how did you make it appear there?
drkmaster0 1 year ago
@drkmaster0 He's saving it to an .html file that he already has loaded into his browser. After he saves the file, he just refreshes the page to reload the code.
mikemcculley 1 year ago
THANKS!!!!
Riddlerx333x 1 year ago
Alerty :) hehe, nice video tutorials!
QuentinMLintz 1 year ago
thats a great tutorial, very clear and precise. Your mistake actually really works in explaining how to call a function! :)
baldmanwithBIGlegs 1 year ago
so... in other words...
a function acts like a variable for a bunch of code?
JustaFreak15 1 year ago
@JustaFreak15 Yes...pretty much. :)
Seryosin 1 year ago
if (commandhere)
{
//scriptsgohere
}
lygersarereal 2 years ago
i dont get how you can code like this:
if( blabla)
{
code
}
i find it way easier to code like so:
if(blabla){ code;
}
anyways good tuts, keep it up.
flash4real 2 years ago
because its the right way to lay your code out
stevieb6966 1 year ago
Comment removed
BackRaw 1 year ago
@flash4real lol, the first look much better (with adding 4 spaces to indent the code) IMO.
BackRaw 1 year ago
tab :)
rastube100 2 years ago
dude how do you do the indentation in notepad++?
vineety 2 years ago
Dude you are awesome! :D I have learned so much from you its just great, you could seriously teach a class man. Keep up the great work!
Kaephuin 2 years ago 31
you can't have a semicolon after something like
function one()
right?
Wowccraft 2 years ago
prety much the same as varibles then, right?
Matthew2225 3 years ago
nope
VampieGames 2 years ago
no you use functions for holding javascript code, you use variables for a value
fireguy1919 2 years ago
do you have to end a function call with a semicolon?
TehRealGamer 3 years ago
The semicolon isn't really needed but it's good programming practice to use it when it's called for.
Alimistar 3 years ago
Nice vids man but iv got one question=)
Do i have to make every different (not the same) function again for making mouse over button menu with javascript,
or there is a little bit easier way
If i have to
Andju72 3 years ago
idk
Stardust342 2 years ago