pretty simple, how do i make my scope work in this example. the first reference of scope logs to the deck function, but the second one logs to the global window. how do i make the second refer to the deck like i want it to.
thanks!
http://jsbin.com/neqevo/1/edit?js
function Deck(){
this.suits = [ // this is an array now
{
'suit': 'diamonds',
'symbol': '♦',
'color': 'red'
}
]; // close suits
this.cardValues = [
{
'name': 'ace',
'face': 'A',
'value': 1
}
]; // close cardValues
this.cards = [];
console.log(this);
this.suits.forEach(function(currentSuit){
var scope = this;
console.log(scope);
// scope doesn't work.
// obviously, scope references window
// so how do i get it to refer to the deck like it's supposed to.
// i looked into using call and apply, and even though the concepts
// made sense i couldn't figure it out.
// fuck this is frustrating!
});
}