This week we will be adding a whole bunch of tools to our tool belt.
Next week we will be practicing those tools.
- welcome to JavaScript
- using JavaScript
JavaScript is a scripting language that enables you to create dynamically updating content, control multimedia, animate images, and pretty much everything else. (Okay, not everything, but it is amazing what you can achieve with a few lines of JavaScript code.)
Including Scripts on the page
- increase the value of a counter (expression)
- change the css class of <p> (statement)
- update the value of the <h1> (expression)
- set the value of a variable (statement)
const x = 5;
const firstName = "Mark";
let dayOfWeek = "Monday";
let numberOfCupsOfCoffee = 1;
var notThis = "hello";const x = 5; // Number
const lastName = "Dewey"; // String
const whatTypeIsThis = "255"; // ???there are more, we will add to this list later
const x = 5;
const y = 10;
const z = x + y; // Should be 15
const a = x - y; // -5
const firstName = "Sherlock";
const lastName = "Holmes";
const fullName = firstName + " " + lastName;
Let's run some JavaScript in the terminal.
Document Object Model
In general, we listen for certain events to fire (click, hover, focus) and we can run chunks of code.
a thing that we can put several lines of code together to execute together.
const sayHello = () => {
console.log("hello")
}
function sayHello () {
console.log("hello")
}document.querySelector()
const h1 = document.querySelector("h1")
const nav = document.querySelector("nav")
const profileImage = document.querySelector(".profile-image")
const userName = document.querySelector("#username")JavaScript in the browser.