Javascript为什么这个函数返回undefined

时间:2017-09-27 07:38:12

标签: javascript function javascript-objects

查看下面的代码并解释为什么它返回func ListInsertOp func ListInsertOp(binName string, index int, values ...interface{}) *Operation ListInsertOp creates a list insert operation. Server inserts value to specified index of list bin. Server returns list size on bin name. It will panic is no values have been passed. 而不是变量。

undefined

2 个答案:

答案 0 :(得分:4)

这是因为return末尾的新行(自动分号插入)。

尝试:

function aaa() {
  return {
     test: 1
  };
}
console.log(aaa());

答案 1 :(得分:4)

因为你创建了换行符:

function aaa() {
  return {
    test: 1
  };
}
console.log(aaa());

相关问题