javascript - How to get the variable value in the variable in the function from the outside
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-18 10:58:18
0
5
698

How to get the variable value inside the function from outside the function?

function time(){
      var date=''2017'';
}
alert(date);
曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(5)
Ty80

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

phpcn_u1582
var time = function(){
    this._date = '2017';
}
var fn = new time;
console.info(fn._date);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template