What is Javascript

A free video tutorial from Edwin Diaz
Web Developer & Premium Instructor - 800,000 students
Rating: 4.4 out of 5Instructor rating
47 courses
833,457 students
What is Javascript

Learn more from the full course

Javascript for Beginners Learn by Doing Practical Exercises

JavaScript for Beginners : Work closely with me doing exercises & learn more. I make Javascript easy for you guaranteed.

03:49:09 of on-demand video • Updated January 2022

Learn to write JavaScript functions
Learn to write Javascript arrays
Learn to write Javascript loops
Learn to write Javascript math operations
Learn to write Javascript condition structure (if statements)
Learn to about Javascript variables
Extra code based on the instructor experience as a bonus
English [Auto]
What is JavaScript? JavaScript is the most popular programming language in the world and is often called a scripting language because it doesn't need a compiler. A compiler is a translator, a software that translates our English words that we use in programming languages to machine code, which are zeros and ones. JavaScript does not need that. JavaScript is actually interpreted right there in the browser. JavaScript controls the browser. It lives on the browser. Everything it does is in the browser. You cannot save JavaScript and take it with you like you do with other programming languages now because we can't take it us. That means that JavaScript is not powerful from JavaScript is a full programming language that is very powerful, is very high in demand right now for jobs and JavaScript. You can do anything with JavaScript. Don't let people tell you that you cannot is actually one of the most popular languages in the world, but is actually one of the most powerful languages in the world. Programming languages. Don't get me wrong right. Is also use with servers to load information from your service super fast. Right now, let me just give you an example. If you go to Google and you start typing in a keyword, let's say, for example, you type in JavaScript and all of a sudden you get some keyword suggestion from Google where you think Google is getting those keywords from, is getting it from the database. And what do you think he's using is using JavaScript along with Ajax to get you that information and display it to the user? JavaScript is really powerful. The only thing that you need for JavaScript to run JavaScript is a browser. If you have a browser, you're good to go eyebrow's in a simple co-editor like just notepad. Even though I don't recommend no bad, you can just grab your nobut right now if you own a Windows machine and you can go ahead and save it as the email file, for example, example that HTML and then you can just write a simple little function like alert and alert function and all of a sudden you have JavaScript running. You opened a file in your browser and JavaScript started running right there because Josh, who lives in the browser, works in the browser and that is its home. Right? That's all you need. Now, another misconception with Java script is, is often that is related to Java. It is not. Java is actually really far away from Java in the sense that the syntax is very different. All right. JavaScript works in the browser. Java is a general-purpose language. You can use it for many different things, right? It's not more powerful or less powerful than Java. They work totally different. So anyways, that's another topic. I just wanted to introduce you to JavaScript. And let me show you let me demonstrate you how you can use JavaScript right now in your computer. So let's go ahead to the code and let's start doing this. All right. So the first thing that we need is a code editor to run JavaScript. Right. And the reason why we need a co-editor is because we need to save a file and we need to include JavaScript in the file. So let's go and open up a window for a Kawada, if I can find one here and. That's it, right, if you have a Windows machine, you can grab your notepad if you don't have a to, that is. But if you do, just open it up. And if you don't, don't worry. I'm going to give you a video on how to get one a lecture. So I'm going to save this file to my desktop and I'm going to name it example and make sure that you put that extension right. So he's an e-mail document, and I'm going to put some I'm going to format it as an HMO five. I don't have to. I can run JavaScript with any format, even the old HTML code. It doesn't really matter. JavaScript being around for a while. So the first thing that I need to do is include a script tag. Right, just like an the tag, we open it and then we close it once we have the script and then we can run JavaScript, I'm just going to make. I'm going to call a simple function, call alert, and this function is built into the browser, so any browser that you use that is a normal browser and I'm not talking about any custom made browser, any normal browser like Firefox, Chrome, Oprah or Safari will display the same thing. Hello from the body if you run this function. All right. And if I go here, let's see if it opens up. I might have a browser right here. OK. So I'm just going to. Opening the browser right here. All right. And this is actually right here in my older monitor for some reason. All right, we go there. That's where he was. I'm sorry. So let's just refresh again. And as you can see here, hello from the body. We're going to get a pop up box like this in every browser that you execute is function Y because JavaScript is built into the browser already. We don't need to run any special programs or anything, any software compiler, anything to run JavaScript. It does it right there on the browser. So this is one way of actually embedding JavaScript with a script and you can use it over here. Also on the head of the document, as you can tell right here, where we're using it in the body. But you can use it in the head anywhere you want. And actually, let's just say that this one is from the head right here, just to give you an idea how this runs. And as you can see here, if I refresh, I get the first one. And until I click here, it doesn't give me the next one. So it goes from top to bottom. All right. Programming languages do that. They work from the top to the bottom. So this one is going to execute first and then this one's going to follow. Now, this is not the right way of actually including JavaScript. Sometimes you do need to include JavaScript in your e-mail like this. But the right way of actually doing this is by making an external script. JavaScript file, I got a copy this thing to show you what I mean. I'm going to page this. I'm going to rename it to Script Dodgiest, and that is now officially a JavaScript file. As you can see here, my computer is already giving me a little JS icon there right at a word. I'm going to drag this in here. I'm going to press Commenee on my Mac. You can press if you're using windows, control A and then delete it. Save it. Command or control was. All right. So we have the Dow screen, but we have no functions. We have nothing here that we need, we can use. Another thing is that we need to link that file to our e-mail file so that way it works. The way we do that is the same way we do with stylesheets. We come here to the head or the bottom of the document. In this case, we're going to use the head. We're going to write a script, a normal script. Tag and SIRC. And then the path of that document right now, the document is right here, this is where the fire is right now. So he's in the same path as that example. So I'm not going to write a path. I'm just going to write the name of it. Script A. Yes. And let me just go ahead and write a function here that is the same function. But I'm just going to say something different so you can see from the external. Five. There we go. All right. So if I go to my browser now and I refresh, I'm going to get this halo from the from the external file, halo from the head, halo from body. All right. And the reason why they said security first is because your right is right here. If I move this all the way down to here, you can guess what is going to happen refreshed from the head, refresh from Halo, from body and from the external file. All right. It's going to execute last because we are placing it all the way in the bottom. Now, let me just give you a quick tip now. Let's say, for example, if you have that document. And let me just I'm going to come in this, actually, I'm going to take this off. And if for some reason you have some tax right here. You know, I'm just giving you an example, if you got some some this actually make some. Paragraph tag right here, and I'm going to put some stats here. All right. So, for example, you have some. Content there and you refresh, you won't be able to see your content in your file unless dysfunctions execute it. So sometimes, as you can see there when I click, yes, it's available. Sometimes it's better to actually grab the script tag and put it all the way in the bottom of the document. If I refresh, then I can see the document. All right, so that's one way of actually being able to see your content before you execute the functions and the JavaScript functions. Right. So make sure that you link this all the way to the bottom of your document. Most of the time, that's what I do. I think all my files all the way in the bottom there, unless it's a Google analytics or something that requires me to put it on the head or something that is not going to affect how my content is display or how long my page is going to take to load, because it really depends on that. If you put a lot of script tags and lot of code here on the head of your document is going to take a long time for your page to load. So keep that in mind when you are linking files. Right. So anyway, thank you so much for taking the time to watch this lecture and I'll see you on the next lecture's.