33 lines
637 B
JavaScript

"use strict";
var p = "David";
const david = {
// this is not block, this the object literal
firstName: "David",
year: 1986,
calcAge: function () {
console.log(this);
console.log(new Date().getFullYear() - this.year);
const self = this;
const isMillenial = function () {
console.log(self);
console.log(self.year >= 1981 && self <= 1996);
};
isMillenial();
},
greet: () => {
console.log(this);
console.log(`Hey ${this.firstName}`);
},
};
david.calcAge();
// arguments keyword
const addExpr = function (a, b) {
console.log(arguments);
console.log(a + b);
};
addExpr(5, 3);