Javascript Tutorial For Beginners
ProgrammingKnowledge · 102 lessons · Free on YouTube
Java Swing GUI Programming Tutorial | Java Swing (Graphical User Interface) Tutorial
About this course
in this whole series we are going to be learning Java scripts and the reason is simple because JavaScript rocks it's arguably the most popular language
around today and it's running in pretty much every web browser so if you're using your iPhone to view a website or your iPad or your Android or Chrome or a super old version of Internet Explorer
it's pretty much going to be running JavaScript and what it does and JavaScript basically adds function to your website to your HTML and CSS so say I want to keep track of how many times
this button has been clicked two times three times four times that's JavaScript or say I want to click this and it shows some super-secret hidden content that's also JavaScript or say I'm working on a
form and I want it to do something my name is will hey wills a great name well thank you this computer's brilliant that's all JavaScript so we're going to get into
kind of the basics of JavaScript and the good news is his javascript is a programming language so once you learn it you've actually learned some computer programming so before we add it to our
actual web page let's kind of start off with some programming basics and JavaScript so what I want you to do is get google chrome download and install it if you're gonna be a web developer
it's a really good browser to use and go view developer JavaScript console the shortcut key for this on Mac is command option J or on Windows it's ctrl shift J and that's gonna bring up your console
here and what the console does is it allows me to code directly into my web page now none of this gets saved onto my web page it's just kind of happening real time and it's the best way to learn
and to play around with code so you can see I can type one here and it says one I could type one plus two hey I kind of got a calculator going on three plus 354 357 so the first thing
that we need to learn with programming is you need to learn what a variable is now it's a big word but variable basically means we're creating a container that's going to store a value
for later on so remember in algebra when you'd say like x equals 1 so what's X plus 1 well that's 2 well if x equals two what's X plus one well that's three basically of variables
that we're giving a number a name and how you do that in JavaScript is you use the letters var for variable so I could say ver x equals one so now every time I type X it's gonna say well that's one so
X plus two well that equals three because that's as far as JavaScript is concerned there's no difference between saying X plus two and saying one plus two because we said X equals one so I
could go there x equals one there y equals two and I could say X plus y and that equals three so now it probably feels like you're in your math class and for those of you guys who hated math
you're like no this is gonna be terrible I promise this is not about math so maybe a better example is let's say their name equals will and you can use single or double quotes for this but if
you're going to use letters you have to use quotes like I said you can use double quotes if you want so now whenever I say name it's gonna spit out will so now I can do alert and then I
can open up and I can say name and I can close out my parenthesis and I hit enter and it's gonna say will so I could also say alerts and I could just do some quotes right now hi will and then hit
enter so it says hi will alerts kind of a cool function that does this little alert window this will work in pretty much any browser so that's kind of what a variable is now there's some types of
variables types that's a very important word to remember javascript has about seven types to it and most most every computer language has a lot of the same types at the very beginning you'll
notice that you remember I did a number there x equals three that's a number type so I can do math with that I can do X plus three and it's going to know that this is the actual number three now if I
do that with quotes equals three zero then that does not know that it's the number 30 anymore I actually whenever you use quotes it becomes a string type and string means that all
these different digits are strung together so it just knows that this is the number three followed by the number zero it doesn't know that it's the number thirty so if I say X plus 10 well
now it's just three zero one zero javascript is smart enough to not give you an error it's just gonna say you just added a number in a string let's just lump it together into one big
string so if I say ver y equals 30 without quotes now Y is the number 30 so y plus 10 is going to be 40 so that's your string type and that's your number type I'm going to teach you one more
command and you're free to create a basic program for yourself that command is prompt I do prompt I open and close my parentheses and hit enter and that's going to open up this window here so now
I can say will and it's going to return will so I could go that really didn't do anything yet so I like to go there name equals prompt and then I can go will and so now if I ever say name name is stored
as will so I could go very name equals prompt and now if I hit a semicolon I can add a second command alerts name so there we go I'm gonna go will it's gonna say okay
and then it alerted will awesome so let me go one more thing let's make this a little bit more their name equals prompt their last name equals prompt alert name plus let me do a comma plus last name
there we go so let's go we'll stir and then it's gonna say will comma stern alright probably would have made more sense to do a space except for that prompt isn't helping me out because it's
not telling me what to do it just gives me this little thing so you can actually enter a prompt message in here what's your first name there you go and now it
asks me what is your first name I'm gonna say my first name is will so let's fix this little program I've written here their name equals what what is your first name and I'm getting quite a long
line here but that's okay what is your last name and you see a looped around here and then I'm actually going to turn that into a space so it loops around it what is your first name we'll what is
your last name we'll Stern so there you go and now you can write your first basic JavaScript computer program and if you were to do some homework before going on to the
next lesson I'd say create a prompt and alert based program that asks for some user information and then spits out a combination of that information just
like I did here I alerted a name plus a last name or maybe make an addition program where you say you know give me one number give me another number and say the sum of those two numbers is blah
blah blah that's your first homework assignment and let's get into the next lesson
THERE IS ALWAYS MORE