I assume your code is from React . Since I recently encountered a similar problem related to React .
Let's get back to your question. I think bind plays a conversion function. The code is as follows:
componentDidMount: function() { var _this = this; $.ajax({ url: this.props.url, dataType: 'json', cache: false, success: function(data) { _this.setState({data: data}); } }); },
equally:
componentDidMount: function() { $.ajax({ url: this.props.url, dataType: 'json', cache: false, success: function(data) { this.setState({data: data}); }.bind(this) }); },
As for, I think you can understand that this is a function to bind and why use bind to achieve it.
Todd mark
source share