While implementing Drag and Drop functionality, often times we pass some data from the element we are dragging to the element in which we are dropping it in.

If you are implementing any game, then you may want to pass an object containing stats of dropping element through DataTransfer. We can use only strings in setData method of DataTransfer. So, in-order pass an object, we first need to stringify the JavaScript object into a JSON string. After receiving the data, we need to again parse it back to the JavaScript object.


Copy to Clipboard