나는 이런 식으로하려고합니다.Javascript 객체 관련
/* Code start */
function getCurrentTime()
{
var date = new Date(),
time = date.getTime();
return time;
}
var jsObject = {
"imageOne":"SomeText"+getCurrentTime(),
"imageTwo":"someOtherText"+getCurrentTime()
}
setInterval(function(){
console.log(jsObject.imageOne);
}, 3000);
/* Code end */
타이머가 실행될 때마다 getCurrentTime()을 실행하고 최신 시간을 가져와야합니다. 어떻게해야합니까?
"imageOne": function() {
return "SomeText" + getCurrentTime();
},
과 :
이console.log(jsObject.imageOne());
정말 필요한 경우, 당신은 ()
과를 생략 할 수 있습니다 당신이 일을 실행하고 다른 결과 각 시간을 얻을 필요가있는 경우
이 함수를 호출하기 위해, 당신은 게터 필요 9691520/938089? javascript-can-we-have-self-invoking-function-modules-assigned-to-variables). –