// decorator lights is a function which receives the class as an argument let lights = function(tree) { // The behaviour of the class is modified here tree.treeLights = 'Christmas lights' } @lights // the decorator is applied here class ChristmasTree {} console.log(ChristmasTree.treeLights); // logs Christmas lights
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter