Skip to content

Instantly share code, notes, and snippets.

@imaginate
Created July 4, 2016 22:43
Show Gist options
  • Save imaginate/92bb8a326ed6b6b10546a54ff65a83e0 to your computer and use it in GitHub Desktop.
Save imaginate/92bb8a326ed6b6b10546a54ff65a83e0 to your computer and use it in GitHub Desktop.
function example(a, b) {}
example.length === 2; // returns => true
example(1, 2, 3);
// a === 1
// b === 2
// arguments[0] === 1
// arguments[1] === 2
// arguments[2] === 3
function outer() {
var that = this;
var inner1 = function inner1() {}; // this !== that
var inner2 = inner1.bind(that); // this === that
}
var str, str2;
var num, num2;
var bool, bool2;
var obj, obj2;
var func, func2;
str = 'string';
num = 5;
bool = true;
obj = {};
func = function(){};
// str => new primitive
// num => new primitive
// bool => new primitive
// obj => same object reference
// func => same object reference
str2 = str; // new place in memory
num2 = num; // new place in memory
bool2 = bool; // new place in memory
obj2 = obj; // same place in memory
func2 = func; // same place in memory
is.empty(obj); // return => true
is.empty(obj2); // return => true
is.empty(func); // return => true
is.empty(func2); // return => true
obj2.prop = true;
func.prop = null;
is.empty(obj); // return => false
is.empty(obj2); // return => false
is.empty(func); // return => false
is.empty(func2); // return => false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment