상세 컨텐츠

본문 제목

[자바스크립트] 해볼것

카테고리 없음

by esoesmio 2023. 5. 17. 21:24

본문

const myArray = ['zero', 'one', 'two'];
myArray.myMethod = function (sProperty) {
  console.log(arguments.length > 0 ? this[sProperty] : this);
};

myArray.myMethod();  // "zero,one,two" 기록
myArray.myMethod(1); // "one" 기록
const myArray = ['zero', 'one', 'two'];

myArray.myMethod = function (sProperty) {
    console.log(arguments.length > 0 ? this[sProperty] : this);
};



setTimeout(function(){myArray.myMethod()}, 2.0*1000);    // 2초 후 "zero,one,two" 기록
setTimeout(function(){myArray.myMethod('1')}, 2.5*1000); // 2.5초 후 "one" 기록

 

댓글 영역