base/object
기반 오브젝트.
Base object.
Object
기반 오브젝트.
Base object.
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.
유효한 객체인지 여부 반환.
Returns whether the object is valid.
- targetany
- 검사할 값.Value to check.
반환Returnsboolean undefined 도 null 도 아니면 참.True if it is neither undefined nor null.
파괴. (현재 객체의 멤버 변수 목록을 무효화)
Destroys. (Invalidates the member variables of the current object)
동등성 비교.
Equality comparison.
- otherany
- 비교할 값.Value to compare.
반환Returnsboolean 자신과 같은 참조이면 참. (null 이면 거짓)True if it is the same reference as this object. (false for null)
인스턴스 고유식별자 반환.
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
인스턴스 얕은 복제.
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)
인스턴스 깊은 복제.
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)