Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision |
programmieren:javascript:js_function_exists [2021/03/16 09:02] – jgehrke | programmieren:javascript:js_function_exists [2024/05/07 08:50] (current) – jgehrke |
---|
</code> | </code> |
| |
Verändert nach folgender Quelle: [[https://stackoverflow.com/questions/1042138/how-to-check-if-function-exists-in-javascript|Stackoverflow Beitrag(1)]], [[https://stackoverflow.com/questions/8592047/check-if-a-function-exists-with-its-name-in-a-string|Stackoverflow Beitrag(2)]] und [[https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Array/includes|MDN » array.includes()]] | Verändert nach folgender Quelle: [[https://stackoverflow.com/questions/1042138/how-to-check-if-function-exists-in-javascript|Stackoverflow Beitrag (1)]], [[https://stackoverflow.com/questions/8592047/check-if-a-function-exists-with-its-name-in-a-string|Stackoverflow Beitrag (2)]] und [[https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Array/includes|MDN » array.includes()]] |
| |
| **Alternative wie es underscore.js macht** |
| Dieser Code ist auch gut und genauer in der Kontrolle, ich bin mir nur nicht sicher ob jede Function auch wirklich einen Constructor und ein Apply hat. |
| |
| <code javascript> |
| is_function = function( obj ) { |
| return !!(obj && obj.constructor && obj.call && obj.apply); |
| }; |
| </code> |
| |
| Quelle: [[https://stackoverflow.com/questions/5999998/check-if-a-variable-is-of-function-type|Stackoverflow Beitrag (3)]] |