Will the following alert "Foo" in all browsers, even when minified?
class Foo
alert(Foo.name)
Nothing is stated in the doc, I know that IE has problems with function names, and I'm confused with the many issues opened about this, like any of these issues !
From within any method of class Foo
that is included in Foo.prototype
, you can insert the line
console.log @constructor.name
and it will write
Foo
to your console log. HTH.
That may depend on which version of the CoffeeScript compiler you're using. In the lastest stable release (1.3.3), a "name" property isn't generated by default.
class Foo
compiles into
var Foo;
Foo = (function() {
function Foo() {}
return Foo;
})();
Since the name
property is non-standard and currently not supported by the IE, you cannot really rely on it cross-browser. Detailed information about this are available at the MDN: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/Name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With