tondrej / chakracore-delphi

Delphi and Free Pascal bindings and classes for Microsoft's ChakraCore library
https://tondrej.blogspot.com/search/label/chakracore
MIT License
136 stars 34 forks source link

JS Basic Units #22

Closed emrahkucukali closed 9 months ago

emrahkucukali commented 9 months ago

Hi, how to use basic javascript units like Math?

tondrej commented 9 months ago

Just use them. For example in ChakraCoreHostSample:

procedure Main;
var
  DataModule: TDataModuleMain;
  Result: JsValueRef;
begin
  ShowInfo;

  DataModule := TDataModuleMain.Create(nil);
  try
    // DataModule.Execute(ParamStrings);
    Result := DataModule.Context.RunScript('Math.round(Math.PI)', '');
    WriteLn(JsStringToUnicodeString(Result));
  finally
    DataModule.Free;
  end;
end;