In my previous post, I experimented with the new
var, you’ll use
let to create variables (not constants). You might be wondering why we need two ways to create variables. Well,
let differs from
var in one very important way:
let is scoped differently from
var. Let’s take a closer look at what that means.
In programming you can assign values to variables. In some languages, you can also assign values to constants. What’s the difference? The values of variables can vary (which is why they’re called variables), but the values of constants can’t. In other words, you can change the value of a variable all you want, but once you’ve assigned an initial value to a constant, you can’t change it again. Its
value stays constant.
Updated in 2014 for Java 8. It’s been ten years since Eric and I wrote our first Head First book, Head First Design Patterns. Ten years! Wow, time flies by. To celebrate the tenth anniversary of the book, we just wrapped up a special 10th anniversary edition of the book.
A few best practices for when you’re learning the language With every...
The secret to getting your web pages to do your bidding with code is to use...