This course has been updated! We now recommend you take the Complete Intro to Web Development, v2 course.

Check out a free preview of the full Introduction to Web Development course:
The "An Introduction to Programming" Lesson is part of the full, Introduction to Web Development course featured in this preview video. Here's what you'd learn in this lesson:

Nina is back to talk about JavaScript. Unlike HTML which is static and never changes, JavaScript is interpreted by your browser and can behave dynamically. Nina outlines some basic JavaScript topics like statements, comments, and how to see things happening in the code.

Get Unlimited Access Now

Transcript from the "An Introduction to Programming" Lesson

[00:00:00]
>> [MUSIC]

[00:00:03]
>> Nina Zakharenko: We're going to start talking about JavaScript, and this is purely an introduction to programming, aimed towards people who haven't really done it at all. So how is JavaScript different from HTML? Well, HTML is purely presentational, there's nothing dynamic about it, there's nothing that changes. We talked about client server, server sends back HTML, there it is, the browser displays it.

[00:00:32] Javascript is different, Javascript is a programming language, and what that means is it's interpreted by your browser, so there are variables, and things change, and there's a line of execution.
>> Nina Zakharenko: So what can we use JavaScript for? And there are a ton of different applications. It's been around for quite a long time.

[00:00:57] Fun fact, it was created in ten days. Which is like that [NOISE] for programming language. So we can use JavaScript for anything from creating something like a pop-up. You ever got one of those on an annoying website? To something like a full-fledged video game. The basic composition of JavaScript is a statement.

[00:01:19] So each line in JavaScript is an instruction and when the browser reads it, it executes that line of code. So for the duration of these slides, I'll be showing code in this different font and syntax highlighted, so that will help you differentiate between what's code and what isn't.

[00:01:41] So,
>> Nina Zakharenko: What's this weird semi-colon thing going on at the end of a statement? So if you think of a JavaScript statement like a sentence, then the semi-colon is a period, it means that this line is done. And you'll be seeing a bunch of these. The other thing that you'll see in JavaScript is comments.

[00:02:08] So one-line comments start with two forward slashes at the end. And comments are not code, but can co-exist with code. So they're not executed by the browser, they are only read by humans, so, only meant for yourself or other people, so notes. You can also do multi-line comments and they are a forward slash and a star, what you wanna write, then they are ended with a star and another forward slash.

[00:02:44] If you have syntax highlighting in your editor, you'll see that comments are a different color. So some rule of thumbs about comments, don't try to overuse them in code that you're sharing. So, if you have a really complex piece of code, feel free to comment it, but don't just put comments in willy nilly if other people are going to read it, cuz they should be able to infer what's going on from your code.

[00:03:14] If you do go back and update your code and you have a bunch of comments, make sure you update them so that if someone goes out and reads your code, they're not reading the comments and getting the wrong picture of what's going on. So, there are a few ways that we can see results when we write JavaScript.

[00:03:33] The first way is that super annoying pop up, the second way is we can output directly to the html page, the third way is that we can display it in that console that we talked about in the beginning.