What is Javascript

Edwin Diaz
A free video tutorial from Edwin Diaz
Web Developer & Premium Udemy Instructor - 700,000 students
4.5 instructor rating • 47 courses • 738,505 students

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:42:23 of on-demand video • Updated September 2020

  • 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 or a software that translates our English words that we use in programming languages to machine code which are serious and once javascript does not need that Joske is actually interpreted right there in the browser. Javascript controls the browser is lives on the browser. Everything he 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 take it without that means that Jove's who's not powerful Brome Javascript is a fool programming language that is very powerful and 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 the right is also used with servers to hold information from your service superfast brain. 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 key suggestions from Google where you think Google is getting those key words from getting it from the database. And what do you think he's using is using javascript along with Ajax to give 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 are good to go. A browser and a simple code editor like just notepad. Even though I don't recommend Notepad you can just grab your Nope right now if you are in a Windows machine and you can go ahead and save it as a die HD a mail file for example example that HD mail and then you can just write a simple little function like an alert and alert function and all of a sudden you have Joske running. You opened a file in your browser and jackscrews started running right there because Java's who lives in the browser works in a browser and that is its home. Right that's all you need now. Another misconception with Java Script is often that is related to Java. It is not Java. It's 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 them and demonstrate you how you can use javascript. Right now in your computer. So let's go ahead to the code and it started doing this. All right so the first thing that we need is a cool editor to run javascript right in the reason why we need a coeditor 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. If I can find one here. And that's it right. If you have a Windows machine you can grab your notepad and if you don't have a coeditor that is. But if you do it just open it up and if you don't know where you are going to give you a video on how to get one. I lecture so I'm going to save this file to my desktop and government name it. Zem full HD mail make sure that you put that extension right so he send him a document and I'm going to put some of my going to format it as an HD 5. I don't have to I can run javascript with any format they have in the old age. Their mail cold it doesn't really matter. Just who is being around for a while so the first thing that I need to do is include a script tag right just like in the mail tag. We open it and then we close it. Once we have the script back 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 in to the browser so any browser that you use that is a normal browser. I'm not talking about any you know custom made browser. Any normal browser like Firefox Chrome opera or Safari will display the same thing. Hello from the variety. If you run this function all right and if I go here let's see if it opens up my have a browser right here. OK so I'm just going to open in the browser right here. All right and this is actually right here and my other money monitor for some reason or I would go there. That's what he was. I'm sorry. So let's just refresh again. And as you can see here Halo from the body we're going to get a pop up box like this in every browser that you execute this function. Why. Because javascript is built into the browser. All ready. We don't need to run any special programs or any day any software compiler anything to run javascript. It does right there on the browser. So this is one way of actually embedding javascript with a script tag and you can use it over here also on the head of the document and you can tell right here what we're using in the body. But you can use it in the head anywhere you want. And actually let's just say that this song is from the head right here. You said you've no idea how this runs. As you can see here if I refresh I get the first one and then two 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 is going to follow. Now this is another the right way of actually including javascript. Sometimes you do need to include javascript in your HMO like this but the right way of actually doing this is by making an external script javascript file. I have to copy this and show you what I mean and paste this. I'm going to rename it to a script that is and is now officially a javascript file. As you can see here my computer is already giving me a little. Yes I can write in a word. I'm going to drag this in here I'm going to press command on my Mac you can press. If you are using Windows control a and then delete it. Save it command or control us. All right. So we have the javascript but we have no functions and we have nothing here that we need we can use. Another thing is that we need to link the file to our 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 S R C and then the path of that document. Right now the document is right here. This is where the file is right now. So he's in the same path as that example. So I'm not going to write a path that you're going to read the name of in script dodgy. 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 file. There we go. All right. So if I go to my browser now and I refresh I'm going to get this hello from the from the external file. Hello from the head. Hello from body. All right. And the reason why I said security first is because the right is right here. If I move this all the way down to here you can guess where it's going to happen. Refresh from the head refresh from Hello from the body and from the external file arrays 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 is actually going to take this off. And if for some reason you have sun text right here you know I'm just giving you an example if you on some. This actually make some paragraph Tigray here. I'm going to put some touch 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 or less disfunctions executed. So sometimes as you can see there when I click yes this is 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 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 link all my files all the way in the bottom there is a google analytics or something that requires me to put it on the head with 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 and 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. All right. So anyway thank you so much for taking the time to watch this lecture and I'll see you on the next lectures