JavaScript runkit_class_emancipate
!No description available for runkit_class_emancipate. @php.js developers: Please update the function summary text file.
1 2 3 4 56 7 8 9 1011 12 13 14 1516 17 18 19 2021 22 23 24 | function runkit_class_emancipate (classname) { // !No description available for runkit_class_emancipate. @php.js developers: Please update the function summary text file. // // version: 909.322 // discuss at: http://phpjs.org/functions/runkit_class_emancipate // + original by: Brett Zamir (http://brett-zamir.me) // % note 1: Function can only obtain classes from the global context // % note 2: We have to delete all items on the prototype // * example 1: function A () {} // * example 1: A.prototype.methodA = function () {}; // * example 1: function B () {} // * example 1: runkit_class_adopt('B', 'A'); // * example 1: runkit_class_emancipate('B'); // * returns 1: true if (typeof this.window[classname] !== 'function') { return false; } for (var p in this.window[classname].prototype) { delete this.window[classname].prototype[p]; } return true; } |
Examples
Running
1
2
3
4
5 | function A () {} A.prototype.methodA = function () {}; function B () {} runkit_class_adopt('B', 'A'); runkit_class_emancipate('B'); |
Should return
1 | true |
Dependencies
No dependencies, you can use this function standalone.
Open syntax issues
php.js uses JsLint to help us keep our code consistent and prevent some common bugs.
Eventually we want all code to pass or at least take into consideration most fixes suggested by JsLint, following this JsLint configuration we’ve decided on.
Authors
Thanks to the following developers, you get to have runkit_class_emancipate goodness in JavaScript.
No comments yet. Be the first!
spread the word:
Use any PHP function in JavaScript
These kind folks have already donated: Anonymous and Shawn Houser.
<your name here>