我希望check
函数在"0"
之下,将hour
附加到10
。
var date = new Date();
var day = date.getDate();
var month = date.getMonth() + 1;
var year = date.getFullYear();
var hour = date.getHours();
var minutes = date.getMinutes();
function check(x) {
if (x < 10) {
x = '0' + x;
}
};
check(hour);
console.log(hour);
但是当我检查console.log(hour);
时,它仍然返回先前的值。为什么会这样?