User:Jeblad/vector.js

/* testpage */

(function( $ ) {   // bla bla assert    mw.assert = function( /* bool, msg, obj */ ) {        // only continue if we have a false as first arg        if (arguments[0]) return;        // turn arguments into an array        var args = Array.prototype.slice.call( arguments );        // try to use an existing console with a proper assert        if ( window.console !== undefined && $.isFunction( window.console.assert ) ) {            window.console.assert.apply( window.console, args );        }        // use our own assert        else {            args.shift;            mw.log.apply( this, args );            throw args[0];        }    }; })( jQuery );

$(function{   $('#bodyContent').prepend(' Foo ');    mw.log('assert' + (console.assert ? 'found' : 'missing'));    mw.assert(true === true);    //console.assert(false === '');    mw.assert(false === true);    mw.log('assert2' + (console.assert2 ? 'found' : 'missing')); });