Reputation: 2619
I saw the next code:
const cardSource = {
beginDrag(props) {
return {
text: props.text
};
}
};
Typically I use {} for jsx block code or to build objects. cardSource makes me feel uneasy. Is beginDrag a member of cardSource? If so, can I use the call: cardSource.beginDrag()?
Upvotes: 0
Views: 44
Reputation: 13095
Is beginDrag a member of cardSource?
Yes. This is equivalent to :
const cardSource = {
beginDrag: function beginDrag(props) {
return {
text: props.text
};
}
};
If so, can I use the call: cardSource.beginDrag()?
Yes.
Upvotes: 1