How to get the variable value inside the function from outside the function?
function time(){ var date=''2017''; } alert(date);
Define global variables, write variable declarations outside the function, and use them directly inside the function
var data; function time(){ data="2017"; } alert(data)
Just return it and it will be fine
It is recommended that the questioner read the relevant knowledge about the scope of variables, which may be of great help.
localStorage
var time = function(){ this._date = '2017'; } var fn = new time; console.info(fn._date);
Define global variables, write variable declarations outside the function, and use them directly inside the function
Just return it and it will be fine
It is recommended that the questioner read the relevant knowledge about the scope of variables, which may be of great help.
localStorage