Skip to content

Instantly share code, notes, and snippets.

function foo() {
console.log(arr.map( i => i + this.a ));
}
var arr = [1,2,3];
var obj = {
a: 2,
foo: foo
};
function foo(a) {
this.a = a;
}
var bar = new foo( 2 );
console.log( bar.a ); // 2
function foo() {
console.log( this.a );
}
var obj = {
a: 2
};
var foo2 = foo.bind(obj);
function foo() {
console.log( this.a );
}
function doFoo(fn) {
fn();
}
function doFoo2(fn, that) {
fn.call(that);
function foo(type) {
console.log( type + this.a );
}
var obj = {
a: 2,
};
foo.call(obj, 'Call: '); // Call: 2
foo.apply(obj, ['Apply: ']); // Apply: 2
function foo() {
console.log( this.a );
}
var obj = {
a: 2,
foo: foo
};
obj.foo(); // 2
@kikar
kikar / notThis.js
Last active March 11, 2016 10:51
Not this
function foo(num) {
console.log( "foo: " + num );
this.count++;
}
foo.count = 0;
foo(1); // foo: 1
foo(5); // foo: 5
foo(10); // foo: 10
@kikar
kikar / keybase.md
Created April 11, 2014 11:12
Verify my indentity

Keybase proof

I hereby claim:

  • I am kikar on github.
  • I am kikar (https://keybase.io/kikar) on keybase.
  • I have a public key whose fingerprint is 4BBB 1E1F 3CE1 BB29 D220 4233 EB63 5FEB 0113 CAB4

To claim this, I am signing this object: