웹 실습

new Date사용한 내장객체화와 그를 활용한 출력 getDay(),getDate()

life... 2022. 4. 6. 05:41

function Song(singer,title,release){

this.singer=singer;

this.title=title;

this.release=new Date(release);

//new Date 자바스크립트 내장객체를 사용해주면

//자바스크립트에서 사용되는 시스템 날짜가 표기되어 나타난다.

console.log(this);

}

 

인스턴스화

 

const song1= new Song("bts","dna","2020-01-03");

const song2= new Song("eminem","world","2002-03=03");

 

console.log(song1.release.getDate())

getDate날짜가 나온다.

getDay 요일이 나온다. => 1 월요일 7일요일