You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: guides/release/components/helper-functions.md
+47-31Lines changed: 47 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -184,32 +184,12 @@ Next to local helpers, ember provides a way to use global helpers. We define glo
184
184
</div>
185
185
</div>
186
186
187
-
To implement the helper, we write a JavaScript function that takes its arguments as an _array_. This is because helpers can also receive _named_
188
-
arguments, which we'll discuss next.
187
+
To implement the helper, we define and export a regular JavaScript function:
189
188
190
189
```js {data-filename="app/helpers/substring.js"}
191
-
import { helper } from'@ember/component/helper';
192
-
193
-
functionsubstring(args) {
194
-
let [string, start, end] = args;
195
-
returnstring.substring(start, end);
196
-
}
197
-
198
-
exportdefaulthelper(substring);
199
-
```
200
-
201
-
We can tighten up the implementation by moving the [destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment) into the function's signature.
0 commit comments