Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

Adding items to a JS array using CallFunction doesn't add #70

@danpetitt

Description

@danpetitt

Trying to add items to a Javascript Array fails to add the item for some reason:

var jsTextToInsert = JavaScriptValue.FromString( "String to add to array" );

var arrayObject = JavaScriptValue.GlobalObject.GetProperty( JavaScriptPropertyId.FromString( "myArray") );
var pushFunctionObject = arrayObjectGetProperty( JavaScriptPropertyId.FromString( "push" ) );
var result = pushFunctionObject.CallFunction( JavaScriptValue.GlobalObject, jsTextToInsert );

var length = (int)arrayObject.GetProperty( JavaScriptPropertyId.FromString( "length" ) ).ToDouble();
Debug.Assert( length == 1 );

I can add items to the array using an alternative indexed property approach but it would be nice the 'push' function worked:

JavaScriptValue indexValue = JavaScriptValue.FromInt32( length );
arrayObject.SetIndexedProperty( indexValue, jsFileName );

Any ideas what I am doing wrong, or is this an issue; calling other functions works fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions