0

I have an array as follows

["http://wallpaper-gallery.net/top/wallpapers-6.jpeg", "http://wallpaper-gallery.net/top/wallpapers-8.jpg", "http://wallpaper-gallery.net/top/wallpapers-10.jpg"]

I want to serialize it similar to serialize() method in jquery to get the following

links=http%3A%2F%2Fwallpaper-gallery.net%2Ftop%2Fwallpapers-6.jpeg%0D%0Ahttp%3A%2F%2Fwallpaper-gallery.net%2Ftop%2Fwallpapers-8.jpg%0D%0Ahttp%3A%2F%2Fwallpaper-gallery.net%2Ftop%2Fwallpapers-10.jpg

How can i achieve this in javascript in an efficient manner

1 Answer 1

3

Use encodeURIComponent:

var links = ["http://wallpaper-gallery.net/top/wallpapers-6.jpeg", "http://wallpaper-gallery.net/top/wallpapers-8.jpg", "http://wallpaper-gallery.net/top/wallpapers-10.jpg"];
console.log("links="+encodeURIComponent(links.join("\r\n")));

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.