1
我想使用Ramda使點自由函數大寫字符串數組,但我是新來的,它不工作。大寫與拉姆達字符串數組
const list = ['a', 'b', 'c', 'd', 'e']
const fn = R.compose(R.toUpper, R.map)
console.log('result', fn(list))
讓我Uncaught TypeError: function n(r){return 0===arguments.length||w(r)?n:t.apply(this,arguments)} does not have a method named "toUpperCase"
我也試過
const fn = R.compose(R.toUpper, R.map(list))
console.log('result', fn())
,但得到了同樣的錯誤。
我該如何使用拉姆達來做到這一點?
真棒電話了!什麼時候應該使用R.compose? – 1252748
當你需要連續調用一個函數時。在'trim' [demo]後面說'toUpper'(http://ramdajs.com/repl/?v=0.24.1#?const%20list%20%3D%20%5B%27%20a%20%27% 2C%20%27%20b的%27%20%2C%20%27%20℃%20%27%2C%20%27%20d的%20%27%2C%20%27%20E%20%27%5D% 0Aconst%20fn%20%3D%20R.map%28%0A%20%20R.compose%28R.toUpper%2C%20R.trim%29%0A%29%0Aconsole.log%28%27result%27%2C% 20fn%28list%29%29) –