var arrayLikeObject = {0:'f',1:'o',2:'g',length:3}; //call foreach, set the callback this value to arraylikeObject [].forEach.call(arrayLikeObject,function(item){ //inside of function this = arrayLikeObject console.log(item + ' total: ' + this.length); },arrayLikeObject); //notice third argument, passing arraylikeObject