demonew.pas 624 B

123456789101112131415161718192021222324252627
  1. uses types, js;
  2. Var
  3. O : TJSObject;
  4. S : TStringDynArray;
  5. I : integer;
  6. V : JSValue;
  7. begin
  8. O:=new(['a','text','b',123,'c',true]);
  9. S:=TJSObject.getOwnPropertyNames(O);
  10. Writeln('Object has ',Length(S),' own properties');
  11. for I:=0 to Length(S)-1 do
  12. begin
  13. Writeln(i);
  14. V:=O.Properties[S[i]];
  15. Writeln('Property ',S[i],' : ',V);
  16. end;
  17. S:=TJSObject.Keys(O);
  18. Writeln('Object has ',Length(S),' keys');
  19. for I:=0 to Length(S)-1 do
  20. Writeln('Property ',S[i],' : ',O.Properties[S[i]]);
  21. Writeln('Manual : ');
  22. Writeln('a: ',O['a']);
  23. Writeln('b: ',O['b']);
  24. Writeln('c: ',O['c']);
  25. end.