Why not simply defining console and console.log() when
it is undefined ?
This would avoid the need to think about using a specific wrapper. WDYT ?
Denis
On Fri, Oct 29, 2010 at 13:42, Marius Dumitru Florea <
mariusdumitru.florea(a)xwiki.com> wrote:
On 10/29/2010 12:09 PM, Jerome Velociter wrote:
On Fri, Oct 29, 2010 at 10:02 AM, Marius Dumitru
Florea
<mariusdumitru.florea(a)xwiki.com> wrote:
+1, but out of curiosity..
On 10/28/2010 08:34 PM, Jerome Velociter wrote:
> Hi devs,
>
> I'd like to commit a console.log wrapper in xwiki.js that does some
> checking before logging, in the spirit of
>
http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
>
> Something like :
>
> var XWiki = {
>
> //snip
>
> /**
> * console#log wrapper for your developer own convenience
> */
> log: function(){
> if(typeof console != "undefined"){
> console.log( Array.prototype.slice.call(arguments) );
What's the point of Array.prototype.slice.call(arguments) ?
Apparently it's a trick to transform the "arguments" array-like object
into an array. See
hhttps://
developer.mozilla.org/en/JavaScript/Reference/Functions_and_function_scope/…
I wasn't aware of this. It's clear now.
I'm not sure what are the exact limitations of logging an array-like
object versus a real array. In firebug, a visible difference is that
you can expand the array as a whole (you have that little "+" on the
left and then have all array properties and methods) , whereas with an
array-like object you only see it's individual elements (that you can
expand as well, individually), but can't expand the array.
Thanks,
Marius
Jerome.
Thanks,
Marius
> }
> },
>
> // snip
>
> }
>
> WDYT ?
>
> Jerome
> _______________________________________________
> devs mailing list
> devs(a)xwiki.org
>
http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs
--
Denis Gervalle
SOFTEC sa - CEO
eGuilde sarl - CTO
_______________________________________________
devs mailing list
devs(a)xwiki.org