Omirion Posted January 15, 2011 Share Posted January 15, 2011 Hey guys an example. var obj = { string:'aa', func:function(){ var st = this.string //do stuff with st } } Link to comment https://forums.phpfreaks.com/topic/224535-is-redeclaring-variables-redundant/ Share on other sites More sharing options...
.josh Posted January 15, 2011 Share Posted January 15, 2011 well it depends... if you just use string then it is accessible to other methods within your object. What you are doing there is creating a copy that is local and accessible only to that specific function. IOW it is a question/matter of variable scope requirements. Link to comment https://forums.phpfreaks.com/topic/224535-is-redeclaring-variables-redundant/#findComment-1159930 Share on other sites More sharing options...
Omirion Posted January 15, 2011 Author Share Posted January 15, 2011 kk thanks for the heads up. Link to comment https://forums.phpfreaks.com/topic/224535-is-redeclaring-variables-redundant/#findComment-1159947 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.