Unlimited Wordpress themes, plugins, graphics & courses! Unlimited asset downloads! From $16.50/m
FREELessons:18Length:1.8 hours

Next lesson playing in 5 seconds

  • Overview
  • Transcript

1.2 Working With JavaScript

Hello, and welcome to the first lesson of this course, where you’ll learn how to work with JavaScript. If you’re not yet familiar with JavaScript, let’s run through a quick intro.

1.2 Working With JavaScript

Hello and welcome to the first lesson of this course where you'll learn two things. What is JavaScript and how to work with it. Let's begin. JavaScript is a programming language and if you ever took a computer science class in high school or in college maybe, you might have learned Pascal or C or C++. Well those are also programming languages P.H.P. is also a programming language. Now JavaScript can run locally in your browser and that's usually what it does but it can also run on a server using node J.S. regardless of how you run it. JavaScript is a one of the three core technologies used to produce content for the worldwide web and the other two being of course HTML and CSS. Now every modern browser supports JavaScript by default, you don't need any plugins to run it so that makes it a really good choice for adding a little bit of interactivity to your website or your web application. And that's a very quick intro to JavaScript. Now, how exactly do you run it? When it comes to writing and running JavaScript code, you can do it in three different ways. The first way is in the browser console. So, I have Firefox here opened and this right here is the console and for example, I can type stuff like alert. I can specify a message and hit that and I get an alert box or I can do a console log. Something else a different message and that will log to my console. So this is very quick way to check things for example check a variable value. Maybe debug your code or do very simple operation so for example I can do stuff like five plus four and it gives me nine. I can do arithmetic operations I can do operations so if I say one is higher than five it gives me false, all sorts of stuff. And the second way is by writing it inline in your HTML document. And first you can for example go to an element and say stuff like OnClick for example and type your JavaScript code. So lets do an alert here, and say clicked, then refresh and when I hit this it gives me an alert or you can use script tags, so script also adds this type text JavaScript we can leave it but it's not necessary. So you can just do script, script and then inside you can type your JavaScript code so for example console, log, 10 times 5. And that's going to give us 50 on the console. Finally the third way of running and writing and running JavaScript is by using a dedicated JavaScript file. So for example I'm gonna create a new file here called script.js. And I'm gonna do a console log from here that says this a log from a dedicated js file. And then we actually have to load that JavaScript file. And we're gonna do it in the footer of our document. We're gonna say script. We're gonna delete this, and we're gonna specify a source to script.js. We're not gonna type anything inside the script. Only setting it's S-R-C. So now refresh and we have that log entry and these are the three methods you can use for writing JavaScript. Now for the upcoming lessons go ahead and pick the one that you feel most comfortable with. Personally I'm not a big fan of the first one because while it is good for quick checks and very simple things it's not very suitable for large blocks of code. Instead I'll be using the second and the third depending on the lesson. In the next lesson you'll learn everything there is to know about variables, I'll see you there.

Back to the top