Implied variable typing (JavaScript)
You can associate a variable with a data type to document your code and direct content assist.
The syntax for variable typing is as follows:
variablename:datatype
The
following code from a computed field implies that db
is
a NotesDatabase
object:var db:NotesDatabase = session.getCurrentDatabase();
return db.getFileName()
The implied data type has no effect
at run time. If your code states db:Foo
or db:NotesStream
, db
is
still treated as a NotesDatabase
object at run time.
The return value of session.getCurrentDatabase()
determines
the type.If no data type association is provided, content assist determines a type from the context, if possible. If a data type association is provided, content assist uses the specified type. In most cases, content assist works the same whether or not an association is provided. Occasionally, specification of the data type provides necessary direction.
Note: Take
care to specify the correct data type as an association. If you specify
the wrong data type, content assist uses that wrong data type.