javascript - Get variable from a function that has the variable -


javascript,

how variable within variable used through-out script?

<script> var variable = function(snap) {    var header= snap.head();    var name = snap.name(); };  alert(variable.name); </script> 

i want able use variable.name outside function. if possible.

treat "variable" function class. change inner variables properties of function. (and don't name function "variable", it's icky).

var variable = function(snap) {     this.name = snap.name() //  }  var the_var = new variable(snap_func); console.log (the_var.name()); 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -