这里我有一个功能nArray
。此函数必须返回 bigArray(JSON 对象),但函数不返回 bigArray...
function nArray() {
//CODE IS HERE
return bigArray;
}
console.log(nArray);
$('pre').html(JSON.stringify(nArray, null, 4));
问题是什么?
这里我有一个功能nArray
。此函数必须返回 bigArray(JSON 对象),但函数不返回 bigArray...
function nArray() {
//CODE IS HERE
return bigArray;
}
console.log(nArray);
$('pre').html(JSON.stringify(nArray, null, 4));
问题是什么?
nArray
是一个函数,所以你需要通过添加括号来执行它:
console.log(nArray());
$('pre').html(JSON.stringify(nArray(), null, 4));
目前,您只是传递对该函数的引用。
你实际上并没有调用你的函数。做这个:
console.log(nArray());
// ^^-----------note the parentheses
$('pre').html(JSON.stringify(nArray(), null, 4));
// ^^-----------and here
关于您的小提琴,我看不到其中的任何<pre>
元素,因此尝试设置.html()
a的最后一行代码$('pre')
不会做任何事情。