# base/object (vanilla.js 0.4.0)

> https://vanillapunch.com/docs/vanilla.js/0.4.0/api/base/object/

기반 오브젝트.

## Object

기반 오브젝트.

예제: 상속해서 복제하고 비교하기

```js
import { Object } from "./build/vanilla.js";

class Inventory extends Object {
	constructor() {
		super();
		this.itemNameList = [];
	}
}

const inventory = new Inventory();
inventory.itemNameList.push("sword");
const shallowCopy = inventory.clone();
const deepCopy = inventory.structuredClone();
inventory.itemNameList.push("shield");
console.log(shallowCopy.itemNameList.length, deepCopy.itemNameList.length);
console.log(inventory.equals(inventory), inventory.equals(deepCopy), Object.isValidate(null));
console.log(inventory.getInstanceId() === inventory.getInstanceId());
```

- `constructor()` (constructor, since 0.0.8): 생성.
- `destroy()` (method, since 0.0.9): 파괴. (현재 객체의 멤버 변수 목록을 무효화)
- `equals(other)` (method, since 0.0.8): 동등성 비교.
  - `other` any: 비교할 값.
  - returns boolean: 자신과 같은 참조이면 참. (null 이면 거짓)
- `getInstanceId()` (method, since 0.0.8): 인스턴스 고유식별자 반환.
  - returns string: GUID 꼴 고유식별자. (처음 부를 때 만들고 그 뒤로는 같은 글을 돌려준다)
- `clone()` (method, since 0.0.8): 인스턴스 얕은 복제.
  - returns this: 인자 없이 같은 생성자로 만든 새 객체. (열거되는 자기 필드와 게터, 세터를 함께 가진 프로퍼티를 얕게 옮긴다)
- `structuredClone()` (method, since 0.0.8): 인스턴스 깊은 복제.
  - returns this: 인자 없이 같은 생성자로 만든 새 객체. (배열과 평범한 객체는 새로 만들어 옮기고 클래스 객체는 참조를 옮긴다)
- `static isValidate(target)` (static, since 0.2.1): 유효한 객체인지 여부 반환.
  - `target` any: 검사할 값.
  - returns boolean: undefined 도 null 도 아니면 참.
