Javascript [ Object ]

양혜정·2024년 4월 6일
0

javascript_web

목록 보기
9/81

Object

오리지널 기법

  • 함수명 : function(){return ...}
  • 선언할 때 함수니까 반드시 () 을 써서 사용해야 한다.
const 객체명 = {
  	...
	info:function(){
    	return this.id + " " + this.name;
    }
}
document.getElementById("아이디명").innerHTML = 객체명.info();

ECMA 6 기법

  • 함수명(){return ...}
const 객체명 = {
  	...
	info(){
    	return this.id + " " + this.name;
    }
}
document.getElementById("아이디명").innerHTML = 객체명.info();

필드값 변경 가능 ( 객체는 변경 불가 )

  • const 객체명으로 선언된 객체는 다른 객체로 변경할 수 없으나 객체의 필드값은 변경 가능

정리

  • 05_object -> object.html, object.js

0개의 댓글

관련 채용 정보