[英]Javascript result of anonymous function in or
is it possible to get the result of an anonymous function like so: 有可能得到一个匿名函数的结果,如下所示:
myarray[myelement] = myarray[myelement] || function() { return "result" };
Basically i want to assign the value of the function if the array element does not exist 基本上我想在数组元素不存在时分配函数的值
Invoke the function using ()
: 使用
()
调用函数:
myarray[myelement] = myarray[myelement] || function() { return "result" }();
JS Fiddle: http://jsfiddle.net/Lbgk7/ JS小提琴: http : //jsfiddle.net/Lbgk7/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.