Note that there are some explanatory texts on larger screens.

plurals
  1. POInherit properites in javascript "object"
    primarykey
    data
    text
    <p>Folks, can you please help me with this questions.</p> <pre><code>var Module = function ( options ) { var settings = { selector: 'body', declaration: function () { return{ init: function () { console.log( 'nodule initialize' ); }, destroy: function () { console.log( ' module destroyed' ); } } } }; this.declaration = options.declaration || settings.declaration; this.selector = options.selector || settings.selector; }; var Registration = function ( options ) { this.selector = options.selector || **strong text**; this.declaration = options.declaration } app.utils.extend( Module, Registration ); var m_registration = new Registration( { declaration: function ( f ) { return { init: function () { }, destroy: function () { } } } } ); </code></pre> <p>My main questions, how i can inherit <strong>Module.selector</strong> properties in m_registration, if we haven't need quantity arguments passed when we are creating instance of <strong>Registration</strong></p> <p>My realisation of function app.utils.extend():</p> <pre><code>var app.utils.extend = function ( from, to ) { var F = function () { }; F.prototype = from.prototype; to.prototype = new F(); to.prototype.constructor = to; to.superclass = from.prototype; } </code></pre> <hr> <p><strong>Update</strong>:</p> <p>If we are using these method:</p> <pre><code>var Registration = function ( options ) { Module.call(this, { selector : options.selector }); this.declaration = options.declaration } </code></pre> <p>How we can use inheritance if we really dont know from what instance this class extended or inheritance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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