javascript - 在javascript中使用console.log时摆脱新行
问题描述
我正在尝试在学习环境中运行此功能,但它会导致“您的程序输出比预期长”的错误,因为默认情况下 console.log 会生成换行符。有什么办法可以解决这个问题吗?
function calcSquare() {
x = document.getElementsByTagName('input')[0].value;
result = x**2
console.log("The square of", parseInt(x), "is", parseInt(result))
}
解决方案
如果您在节点中,则可以使用process.stdout.write("foo");
. 您可以多次调用它而无需换行。
process.stdout.write('foo');
process.stdout.write('bar');
输出:
foobar
推荐阅读
- android - Facebook 奖励视频广告无法加载
- sql - 如何在不聚合的情况下旋转多个列
- azure - 集合吞吐量问题
- assembly - Arduino中的光传感器组装器
- html - CSS 显示:无/块在 FORM 中不起作用
- amazon-web-services - 413 请求实体在 Nginx 和 Amazon ElasticBeanstalk 中太大
- python - PyCharm- AttributeError:模块“numpy”没有属性“arange”
- nginx - Nginx 1.14 无法访问系统环境变量
- javascript - 不显示标签中的图像
- vba - 范围类的 1004 复制方法失败,较小的数据集上不存在错误