Python的以下等价物是什么(Javascript):
function wordParts (currentPart, lastPart) {
return currentPart+lastPart;
}
word = ['Che', 'mis', 'try'];
console.log(word.reduce(wordParts))
而这个:
var places = [
{name: 'New York City', state: 'New York'},
{name: 'Oklahoma City', state: 'Oklahoma'},
{name: 'Albany', state: 'New York'},
{name: 'Long Island', state: 'New York'},
]
var newYork = places.filter(function(x) { return x.state === 'New York'})
console.log(newYork)
最后,这:
function greeting(name) {
console.log('Hello ' + name + '. How are you today?');
}
names = ['Abby', 'Cabby', 'Babby', 'Mabby'];
var greet = names.map(greeting)
谢谢大家!
https://docs.python.org/2/library/functions.html
首先是:
它们都是相似的,Lamdba函数通常在python中作为参数传递给这些函数。
减少:
过滤器:
地图:
Docs
相关问题 更多 >
编程相关推荐