Anders
Anders

Reputation: 8577

What is the order of execution for method decorators?

Consider the following JavaScript code:

class Example {

    @foo
    public methodOne() {}

    @bar
    public methodTwo() {}

}

In what order will foo and bar be executed? Do note that I am not interested in how variou JS engines implement it, but what is the correct way according to the spec. I need to know if I can rely on this behaviour being consistent across JS engines.

It would also be interesting to know if TypeScript decorators behave the same way.

Upvotes: 1

Views: 2264

Answers (1)

basarat
basarat

Reputation: 275867

In what order will foo and bar be executed?

In order of appearance. So foo then bar.

Upvotes: 2

Related Questions