Are you wanting to write your own scriptable C++ XPCOM components or
do you just want to know how to manipulate them from JavaScript?
In any case, the other fellow's relpy pointing out the nsSample
component is a good place to start. Beware that nsSample illustrates
how to implement an XPCOM component in C++ and in JavaScript so
the sample HTML page can be used to test out either.
Just seeing the C++ implementation and then seeing the component
re-implemented in JavaScript was confusing to some.
-rick