Skip to content

Instantly share code, notes, and snippets.

View moiz-frost's full-sized avatar
🧠

Abdul Moiz Sheikh moiz-frost

🧠
View GitHub Profile
@moiz-frost
moiz-frost / car.js
Created September 3, 2019 10:11
Creating an object using object.create()
var car = Object.create(Object.prototype, {
year: {
value: '2010',
writable: true,
enumerable: true,
configurable: true },
make: {
value: 'Honda',
writable: true,
enumerable: true,
@moiz-frost
moiz-frost / car.js
Created September 3, 2019 10:13
Printing car object properties
console.log(Object.getOwnPropertyDescriptors(car));
// Output
/*{ year:
{ value: '2010',
writable: true,
enumerable: true,
configurable: true },
make:
@moiz-frost
moiz-frost / car_binding.js
Created September 3, 2019 19:08
Binding this context
function printCar() {
console.log(this)
}
var car = {
speed: 240
}
printCar = printCar.bind(car)
@moiz-frost
moiz-frost / arrow_this.js
Created September 3, 2019 20:32
Printing this with arrow functions
printThis = () => {
console.log(this);
}
var car = {
year: 2015,
printThis: printThis
}
printThis(); // will print the global/window object
@moiz-frost
moiz-frost / call.js
Created September 7, 2019 19:53
call()
function printHP() {
console.log(this);
}
var car = {
year: '2010',
make: 'Honda',
color: 'White',
transmission: 'Manual',
horsePower: 140,
alert(1);