Skip to content

Instantly share code, notes, and snippets.

@jondeandres
Created March 27, 2019 21:36
Show Gist options
  • Save jondeandres/7cdffa439bb3bbb2be50a1042043da46 to your computer and use it in GitHub Desktop.
Save jondeandres/7cdffa439bb3bbb2be50a1042043da46 to your computer and use it in GitHub Desktop.
##################
function foo () {
console.log("Simple function call");
console.log(this === window);
}
foo();
console.log(this === window)
##################
function foo () {
'use strict';
console.log("Simple function call")
console.log(this === window);
}
foo();
##################
function Person(fn, ln) {
this.first_name = fn;
this.last_name = ln;
this.displayName = function() {
console.log(`Name: ${this.first_name} ${this.last_name}`);
}
}
let person = new Person("John", "Reed");
person.displayName();
#################
function foo () {
console.log("Simple function call")
console.log(this === window);
}
let user = {
count: 10,
foo: foo,
foo1: function() {
console.log(this === window);
}
}
user.foo()
let fun1 = user.foo1;
fun1()
user.foo1()
#######################
function Person(fn, ln) {
this.first_name = fn;
this.last_name = ln;
this.displayName = function() {
console.log(`Name: ${this.first_name} ${this.last_name}`);
}
}
let person1 = new Person("John", "Reed");
let person2 = new Person("Paul", "Adams");
person1.displayName.bind(person2)();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment