Most programming languages delimit the main program section with a keyword such as Main() or main(). JScript.NET and JavaScript are different. Luckily, the main code in JScript.NET is not delimited in any way and you can write the code outside. You can write it before, after, or in between the class definitions.
Here is an example that includes two class definitions followed by the main code section:
// compile with: jsc inheritance.js
class Base {
protected var i : int = 5;
public function PrintInBase() : void {
print("i is " + i);
}
}
class Derived extends Base {
var d : double = 7.3;
public function PrintInDerived() : void {
print("i is " + i + ", d is " + d);
}
}
var b : Base = new Base();
print("b:");
b.PrintInBase();
var d : Derived = new Derived();
print("d:");
d.PrintInBase();
d.PrintInDerived();
Do you have comments on this tip? Let us know.
Related information from SearchDomino.com:
FAQ: JavaScript advice
Tip: Delete documents over the Web using Ajax and JavaScript
Learning Guide: JavaScript for Lotus Notes and Domino
Reference Center: JavaScript tips and resources
This tip was submitted to the SearchDomino.com tip library by member Chandra Teja. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.