我得到了一个关于函数编写的测验:
/* ====== can not modify this line below till next dividing line ========= */
function foo() {
var obj = {
x : 1,
y : 2,
bar : bar()
}
function bar() {
/* ====== can not modify this line above ================================= */
/* so how can I get obj.x and obj.y here and returns their sum ..? */
/* ====== can not modify this line below till next dividing line ========= */
}
return obj;
}
console.log( …Run Code Online (Sandbox Code Playgroud)长话短说,php中有太多的套接字I / O函数似乎在做同样的事情。
所以我想知道fread()和stream_get_contents()和之间有什么区别stream_socket_recvfrom()吗?
此外fwrite()和stream_socket_sendto(),他们都长得一样,应该选择我?
感谢您查看我的问题,我将为您提供任何建议〜
我有这样的数组["aaa","aaa","bbb","ccc"].
我需要的是将它转换为这样的形式:
{ "aaa" :
{ "aaa" :
{ "bbb" :
{ "ccc" : 1 }
}
}
}
Run Code Online (Sandbox Code Playgroud)
我知道eval可以做到这一点,但有没有更漂亮的解决方案?
感谢您阅读我的帖子.
长话短说,我将展示代码。
一些.html
<html><script src="some.js"></script></html>
Run Code Online (Sandbox Code Playgroud)
一些.js
window.onload = () => console.log( "onload" );
(async (url, cb) => cb( await ( await fetch(url) ).json() ))
( "some.json", () => console.log( "in async" ) );
Run Code Online (Sandbox Code Playgroud)
和 some.html 输出:
onload
in async
Run Code Online (Sandbox Code Playgroud)
我已经完成了一些工作,例如在实际获取中加载图像,所以fetch().then()对我来说不起作用。
现在我的问题是如标题所示,如何让“onload”等待“fetch”完成?