i have problems getting name of constructor when using es6 classes in firefox. in chromium works fine, firefox seem have kind of bug? in firefox empty string back. knows of workaround?
class myclass {} let = new myclass(); console.log(a.constructor.name);
i think bug (according comment below).
it appears specifying explicit constructor exhibits correct behavior in firefox (even latest version 48).
class myclasswithconstructor { constructor() { console.log("explicit constructor") } } class myclasswithoutconstructor {} $('#with').click(function() { let tmp = new myclasswithconstructor(); alert("myclasswithconstructor name = " + tmp.constructor.name); }) $('#without').click(function() { let tmp = new myclasswithoutconstructor(); alert("myclasswithconstructor name = " + tmp.constructor.name); })
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button id=with>with constructor</button> <button id=without>without constructor</button>
here's link jsfiddle: https://jsfiddle.net/jc7g5crp/
Comments
Post a Comment