Skip to content

Property 'includes' of object is not a function #1585

Answered by lahma
croban asked this question in Q&A
Discussion options

You must be logged in to vote

Jint only automatically handles arrays to JS array conversion as it's safe as being fixed size. Either call ToArray() when setting value to engine or modify options object wrapped to set different prototype.

public void CanAddArrayPrototypeForArrayLikeClrObjects()
{
var e = new Engine(cfg => cfg
.AllowClr(typeof(Person).Assembly)
.SetWrapObjectHandler((engine, target) =>
{
var instance = new ObjectWrapper(engine, target);
if (instance.IsArrayLike)
{
instance.SetPrototypeOf(engine.Realm.Intrinsics.Array.PrototypeObject);
}
return instance;
})
);

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@croban
Comment options

@croban
Comment options

Answer selected by croban
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1584 on July 07, 2023 15:43.