Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>No, it's impossible without reassigning a [[prototype]] to a function object. IE does neither support the nonstandard <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto" rel="nofollow"><code>__proto__</code> property</a> nor the ES6 method <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf" rel="nofollow"><code>Object.setPrototypeOf</code></a>.</p> <p>The only custom callable objects are functions which you create with function expressions/declarations or the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function" rel="nofollow"><code>Function</code> constructor</a>. However, all of these methods will create function objects which have their [[prototype]] <a href="http://es5.github.io/#x13.2" rel="nofollow">set to</a> the builtin <a href="http://es5.github.io/#x15.3.4" rel="nofollow"><code>Function.prototype</code> object</a>.</p> <hr> <blockquote> <p>F will be used as a constructor (in a compiled to javascript language). But the code is going to be more complex. The core idea is that there will be one more line <code>F.prototype = F</code> after that, so all objects created from F will see the attributes of their class; i.e. <code>f = new F(); F.foo = 123; print(f.foo);</code></p> </blockquote> <p>Don't do that. While F is a (constructor) function, your instances are not, so there's no reason to let them inherit from it. Just comile your class attributes to <code>F.prototype.foo = 123;</code>. Or compile any accesses to static properties (where "instances see class attributes") to use the <code>F</code> object instead, so <code>print(F.foo)</code>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload