Intializing Variables



The term initializing means to assign some value to the variable. Basically, the actual use of variables comes under the initialization part. In pas2js each data type has some default value which is used when there is no explicitly set value for a given variable.

Compile Time Initialization: It means to provide the value to the variable during the compilation of the program. If the programmer didn’t provide any value then the compiler will provide some default value to the variables in some cases.

Variables are converted without type, because JavaScript lacks a clear type. They are however always initialized, which helps JavaScript engines to optimize.

PAS2JS NOTES:

_____ Although pas2js creates .js files encoded as UTF-8 with BOM, JavaScript strings are UTF-16 at runtime. Keep in mind that one UTF-16 codepoint can need two char, and a visible glyph can need several codepoints. Same as in Delphi.

Pas2JS pascal source code
{ filename: project1.lpr } program project1; {$mode objfpc} uses Classes, SysUtils, JS; type TForm = class end; const c1: integer=3; c2 = 'abc'; c3 = 234; c4 = 12.45; c5 = nil; var v1: string; v2,v3: double; v4 :byte=0; v5 :TForm; v6 :TIdentMapEntry; v7 :string='abcäöü'; v8 :char='c'; v9 :array of byte; begin // Your code here end.