【发布时间】:2018-10-31 09:29:53
【问题描述】:
我尝试链接一些数组和字符串方法,但它不起作用。如果有人能向我解释为什么这样的功能不起作用,那就太好了:
const scream = text => text.split('').push('!').join('').toUpperCase()
【问题讨论】:
-
查看
push上的文档(它不会返回您推送到的数组,如果您查看抛出的错误应该很清楚) -
push() "返回数组的新长度" - developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…
-
什么是示例文本以及预期内容
-
这看起来是
(text + '!').toUpperCase()的复杂版本
标签: javascript methods fluent chaining