/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* * *Date:06February2003 *SUMMARY:Using|instanceof|tocheckiffunctioniscalledasaconstructor * *Seehttp://bugzilla.mozilla.org/show_bug.cgi?id=192105 *
*/ //----------------------------------------------------------------------------- var UBound = 0; var BUGNUMBER = 192105; var summary = 'Using |instanceof| to check if f() is called as constructor'; var status = ''; var statusitems = []; var actual = ''; var actualvalues = []; var expect= ''; var expectedvalues = [];
/* *Thisfunctionistheheartofthetest.Itsetstheresult *variable|actual|,whichwewillcompareagainst|expect|. * *Note|actual|willbesetto|true|or|false|according *towhetherornotthisfunctioniscalledasaconstructor; *i.e.whetheritiscalledviathe|new|keywordornot-
*/ function f()
{
actual = (thisinstanceof f);
}
/* *Callfasaconstructorfromglobalscope
*/
status = inSection(1); new f(); // sets |actual|
expect = true;
addThis();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.