News for hackers. Stuff that matters.
Re:Console.log with style by niggler on Friday April 12, 2013 @04:20PM (#5540763)
You can just parse (new Error).stack:

    var __LINE__ = (new Error).stack.split("\n")[1].match(/:([0-9]+):/)[1];
Re:Console.log with style by tracker1 on Friday April 12, 2013 @08:52PM (#5542045)
I do something similar for logging my node apps... in .Net I use reflection for essentially the same.
Re:Console.log with style by cristiantincu on Friday April 12, 2013 @05:52PM (#5541287)
`(new Error()).stack` is non-standard. But that’s a nice hack, nevertheless.
Re:Console.log with style by niggler on Friday April 12, 2013 @05:56PM (#5541316)
The underlying construct (console.log processing "%c" and styles) is nonstandard to begin with.
Re:Console.log with style by cristiantincu on Friday April 12, 2013 @06:08PM (#5541374)
Yes. It will not break, though.

Unless you’re running it on an old IE that doesn’t host the `window.console` object.