Haskell的Javascript中缀操作符 [英] Haskell's infix operator for Javascript
问题描述
Javascript中是否有等价的构造?如果没有,你将如何创建一个?
下面是对中缀操作符在Haskell中做什么的简单解释:
JavaScript没有列表类型,但它有 Array
您可以使用...
var newArr = [val] .concat(arr);
或者,您可以使用 unshift()
前置到一个数组,但它会改变原始数据。
JavaScript没有:
运算符,运算符重载或者看起来像运算符的方法,所以你不能得到和Haskell类似的语法。
Is there an equivalent construct in Javascript. If not, how would you create one?
Here's a straightforward explanation of what the infix operator does in Haskell:
What does the : infix operator do in Haskell?
JavaScript doesn't have a list type, but it has Array
s.
You can use...
var newArr = [val].concat(arr);
Alternatively, you could use unshift()
to prepend to an array, but it mutates the original.
JavaScript doesn't have a :
operator, operator overloading or methods that look like operators, so you can't get a similar syntax as Haskell.
这篇关于Haskell的Javascript中缀操作符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!