Last active
December 21, 2015 20:48
-
-
Save sohel-rana/6363521 to your computer and use it in GitHub Desktop.
Using anonymous self excuting function for object property in javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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