vanilladocs
vanillapunch.com
API / base/object

base/object

기반 오브젝트.

Base object.

Object

기반 오브젝트.

Base object.

예제Example상속해서 복제하고 비교하기Inherit, clone and compare
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());
생성자constructorconstructor()#0.0.8 부터since 0.0.8소스source

생성.

Constructor.

정적staticstatic isValidate(target)#0.2.1 부터since 0.2.1소스source

유효한 객체인지 여부 반환.

Returns whether the object is valid.

targetany
검사할 값.Value to check.

반환Returnsboolean undefined 도 null 도 아니면 참.True if it is neither undefined nor null.

메서드methoddestroy()#0.0.9 부터since 0.0.9소스source

파괴. (현재 객체의 멤버 변수 목록을 무효화)

Destroys. (Invalidates the member variables of the current object)

메서드methodequals(other)#0.0.8 부터since 0.0.8소스source

동등성 비교.

Equality comparison.

otherany
비교할 값.Value to compare.

반환Returnsboolean 자신과 같은 참조이면 참. (null 이면 거짓)True if it is the same reference as this object. (false for null)

메서드methodgetInstanceId()#0.0.8 부터since 0.0.8소스source

인스턴스 고유식별자 반환.

Returns the instance's unique identifier.

반환Returnsstring GUID 꼴 고유식별자. (처음 부를 때 만들고 그 뒤로는 같은 글을 돌려준다)Unique identifier in GUID form. (created on the first call, the same string is returned afterwards)

짝Counterpart: vanilla-engine WorldNode.get_instance_id

메서드methodclone()#0.0.8 부터since 0.0.8소스source

인스턴스 얕은 복제.

Shallow clone of an instance.

반환Returnsthis 인자 없이 같은 생성자로 만든 새 객체. (열거되는 자기 필드와 게터, 세터를 함께 가진 프로퍼티를 얕게 옮긴다)A new object made by the same constructor with no arguments. (own enumerable fields and properties with both a getter and a setter are copied shallowly)

메서드methodstructuredClone()#0.0.8 부터since 0.0.8소스source

인스턴스 깊은 복제.

Deep clone of an instance.

반환Returnsthis 인자 없이 같은 생성자로 만든 새 객체. (배열과 평범한 객체는 새로 만들어 옮기고 클래스 객체는 참조를 옮긴다)A new object made by the same constructor with no arguments. (arrays and plain objects are rebuilt, class objects are copied by reference)