React lifecycle methods
constructor()
componentWillMount()
render()
componentDidMount()
componentWillReceiveProps(nextProps) - setState() can be called
shouldComponentUpdate(nextState,nextProps,context)
componentWillUpdate(nextProps,nextState)
render()
componentDidUpdate()
componentWillUnmount()
Basic ajax syntax
var request = new XMLHttpRequest()
request.open('POST','/url')
request.setRequestHeader('Content-type','application/json')
request.addEventListener('load', function(){
if(request.status == 200){
var data = JSON.parse(request.responseText)
}
})
request.send()
splice,slice
- string|array - slice(startIndex,endIndex)
- string - substr(startIndex,length)
- array - splice(startIndex,length,[replace])