Skip to content

Instantly share code, notes, and snippets.

@sohel-rana
Last active December 21, 2015 20:48
Show Gist options
  • Select an option

  • Save sohel-rana/6363521 to your computer and use it in GitHub Desktop.

Select an option

Save sohel-rana/6363521 to your computer and use it in GitHub Desktop.
Using anonymous self excuting function for object property in javascript
var object = {
name: 'Sohel',
value: function(){
//anonymous self executing function
//split the websites
var websites = "http://www.lewishamilton.com http://www.twitter.com/lewishamilton http://instagram.com/lewishamilton www.youtube.com/lewishamilton https://plus.google.com/+LewisHamilton/posts";
var websiteArray = [];
$.each(websites, function(index, w) {
// format the web url as link
w = '<a target="_blank" href="' + w + '">' + w + '</a>';
//store it on the array
websiteArray.push(w);
});
var websitesHtml = websiteArray.join('<br/>');
return websitesHtml;
}()
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment