tags:

views:

62

answers:

2

what does it mean when you set a function like this

setState: function(){  
}
+5  A: 

The code is incomplete, but it looks like you're assigning a function as the value to a property called setState of an object that isn't shown in your code.

An example:

var myObject = {
    prop1: 'abc',
    prop2: function() {
       alert('def');
    }
};

Above, I'm creating a variable called myObject that is an object with two properties, prop1 and prop2. The first one is a string. If I write alert(myObject.prop1) it'll alert "abc".

The second one is a function. If I write myObject.prop2() I'll execute that function, which'll alert "def".

David Hedlund
+2  A: 
T.J. Crowder