markus_ja
markus_ja

Reputation: 2951

How to remove a property from JS object

How can I remove a property from a variant object in Smart Pascal?

In JavaScript I can remove a property with the delete keyword delete obj['myProp'].

How to do it in Smart Pascal?

Upvotes: 3

Views: 132

Answers (1)

gabr
gabr

Reputation: 26840

Smart allows you to directly execute JavaScript code by reusing Delphi's asm syntax.

asm
  delete @obj['myProp'];
end;

The @obj syntax is necessary if you are referring to a Smart Pascal entity because the actual name may be something else than obj due to obfuscation. During compilation, @obj is replaced with the actual name of the entity.

Upvotes: 4

Related Questions