How do I wrap a function in Javascript?

前端 未结 6 1719
南笙
南笙 2020-12-12 16:48

I\'m writing a global error handling \"module\" for one of my applications.

One of the features I want to have is to be able to easily wrap a function with a t

6条回答
  •  旧巷少年郎
    2020-12-12 17:04

    Object.extend(Function.prototype, { Object.extend in the Google Chrome Console gives me 'undefined' Well here's some working example:

        Boolean.prototype.XOR =
    //  ^- Note that it's a captial 'B' and so
    //      you'll work on the Class and not the >b " true.XOR( false ) );
    

    so instead of Object.extend(Function.prototype, {...}) Do it like: Function.prototype.extend = {}

提交回复
热议问题