javascript - How to access an object literal property from another property? -


this incredibly simple , google-fu not strong enough. apologies if duplicate.

consider following object literal:

var config = {     url: 'http://google.com',     message: 'you must go <a href="' + url + '">google</a> search!' }; 

i error saying url not defined. how access url element message element?

i think can wrap config object, e.g.

var config = (function() {   var _url = 'http://google.com';   return {     url : _url,     message : 'you must go <a href="' + _url + '">google</a> search!'   } })(); 

Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -