reading-notes

JavaScript Basics

JS Intro Introduction to JavaScript - basic output JavaScript input with prompt and confirm Variable How Computers Work - Playlist

JS Intro

JavaScript (JS) is a lightweight, interpreted, or just-in-time compiled programming language with first-class functions. While it is most well-known as the scripting language for Web pages, many non-browser environments also use it, such as Node.js, Apache CouchDB and Adobe Acrobat. JavaScript is a prototype-based, multi-paradigm, single-threaded, dynamic language, supporting object-oriented, imperative, and declarative (e.g. functional programming) styles.

Read more about JavaScript

Basic Use

Basic Inputs & Outputs

Code Does
alert() Creates a pop-up with the alert text inside
document.write() Changes the content on the page to what is inside the document.write() function
console.log() Prints the contents of the console.log() call into the console for us to read
prompt() Shows a pop-up window asking for a user’s input
confirm() Provides a Yes or No confirmation to the user; typically paired with an IF / ELSE statement

Variables

What are Variables?

var x = 5;
var y = 6;
var z = x + y;
console.log(z) >> 11

When to Use const?

const price1 = 5;
const price2 = 6;
let total = price1 + price2;
console.log(total) >> 11