This guide is for anyone who wants to get into programming, and/or anyone who has chosen web development as their introduction to programming
JavaScript is ideal for beginners because the syntax is pretty intuitive. If you were to see
if(smart === true) {
thought = "I think therefore I am";
}
else {
thought = "hurr durr";
}
You would probably have some idea of what was going on (if you don't, don't worry, you will after this guide).
To Quote the MDN Documentation:
"JavaScript is a cross-platform, object-oriented scripting language used to make webpages interactive."
For those of you who don't know that that means (let's say most of you). JavaScript is The Programming language of the Internet. It's built to work in browsers, and has built-in tools to interact with websites.
You can use stuff you do in JavaScript to affect the HTML or CSS of a given webpage (if you don't know what those are, don't worry, they won't come up later, but def look them up, they're pretty important).
The syntax of how to do that will be outside the scope of this guide, but trust me, that's what JavaScript is used for more than half the time
So, the easist way to get access to JavaScript is to open up the developer console on your browser (ctrl + shift + j in chrome). You can even do it on this page! Go ahead, I'll wait...
If you want a blank slate to code JavaScript in, you can type in "about:blank" into your browser address window. Either way, try inputting the following code into the console
console.log("Hello World!");
once you hit enter, the next line should show the string "Hello World!"
if it does, you're ready to code!
Variables are one of the fundamental building blocks of JavaScript. They are ABSOLUTELY NECCESSARY to understanding JavaScript as a whole. Luckily, they're pretty simple as a concept
Think of variables as boxes where you can store computer data. you can declare them (or put data into the box)
var foo = 1;
and you can re-declare them (or take out what's in there, and put something else there)
foo = "bar"
Whenever you use these variables in your code, you're essentially dumping the contents of the box right where you wrote the variable name. Try this out!
var one = 1;
var two = 2;
var result = one + two;
console.log(result);
You should see the number '3' in your console after these lines run. And this example works to show you that variables in JavaScript work a lot like the variables you know and love in math! (yaaaaaaaaaay, math!).
variables can contain various different types of data. such as:
- numbers
- "strings" (or words)
- booleans (either true or false)
- undefined (essentially nothing)
- null (also nothing)
- symbol (this is a really advanced concept, don't worry about it)
- Functions
- Objects (the "object-oriented" part of JavaScript)
If you would like to learn more about the ins and outs of JavaScript, you can visit the MDN JavaScript Guide