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
Post a Comment