Skip to content

Instantly share code, notes, and snippets.

erik.weight = 185
erik.weight //=> 185
const erik = { weight: '155lbs', height: '6 4'};
const key = 'baby’s first constant';
key = 'changed!'; //=> Uncaught TypeError: Assignment to constant variable..........
} // Defining our block
let secret = ‘skedaddle’
let secret = ‘password’
//=> Uncaught SyntaxError: Identifier ‘secret’ has already been defined.
{
if(age > 12) {
let dogYears = age * 7
console.log(‘You are ${dogYears} dog years old!’)
}
//=> dogYears not available here
if(age > 12) {
const dogYears = age * 7
console.log(‘You are ${dogYears} dog years old!’)
}
//=> dogYears not available here
function setWidth() {
var width = 100;
console.log(width);
}
/// width not available here
var width = 100;
console.log (width); //=> 100
var width = 200
console.log (width); //=> 200
var width = 100;
console.log (width); //=> 100
function Person(firstname, lastname) {
this.firstname = firstname
this.lastname = lastname
}
var john = new Person(‘john’, ‘doe’);
var sally = new Person(‘sally’, ‘white’);
//=> Person { Firstname: “John”, Lastname: “Doe” }
//=> Person { Firstname: “Sally”, Lastname: “White” }