gpt4 book ai didi

javascript - 将计算后的 javascript 函数返回到终端

转载 作者:行者123 更新时间:2023-12-02 21:31:15 25 4
gpt4 key购买 nike

我正在尝试将已评估的函数返回到终端。我尝试使用 window.onload()console.log(); alert(); 但 URL 未被评估并发送到终端。

我使用命令phantomjs test.js运行下面的代码

var webPage = require('webpage');
var page = webPage.create();

function testlink() {
return(["h","t","t","p","s",":","\/","\/","i","b","m",".","c","o","m"]);
}

window.onload = testlink;
console.log(testlink);
alert(testlink);

而不是得到(这就是我想要的)

https://ibm.com

我明白

function testlink() {
return(["h","t","t","p","s",":","\/","\/","i","b","m",".","c","o","m"]);
}

Ps:我使用的是 Ubuntu 18.04 和 phantomjs 2.1.1

最佳答案

尝试使用 console.log(teSTLink()) 而不是 console.log(teSTLink)

如果我们想连接该数组中的所有字符,只需返回:

["h","t","t","p","s",":","\/","\/","i","b","m",".","c","o","m"].join("")

或者,如果您不想更改函数,请执行 console.log(teSTLink().join(""))

关于javascript - 将计算后的 javascript 函数返回到终端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60623872/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com