There might be situations where you need to create a CSV using some data available within JS layer and allow a user to download it. So you need to construct the CSV file on the fly and then allow the user to download the file.
Data-URI scheme helps in achieving this. You can specify the contents and file name of the file to be downloaded and attach these properties to an anchor element.
This is how you can do it:
This works on Chrome and Firefox.
35.0.1916.99 version of Chrome has a bug, which can be tracked here.