Javascript node.js-将使用';空格。重复';在浏览器中也是如此

Javascript node.js-将使用';空格。重复';在浏览器中也是如此,javascript,node.js,reactjs,buffer,spaces,Javascript,Node.js,Reactjs,Buffer,Spaces,我试图从Node.js response对象返回下面的字符串,以便通过这种方式在缓冲区变量之间手动添加一些预定义的空格来响应应用程序 const space = ' '; const nextLine = '\r\n'; const nodeResp = Buffer.concat([ Buffer.from(` This ${nextLine}`), Buffer.from(` is ${nextLine} `), Buffer.from(` a ${nextLine

我试图从Node.js response对象返回下面的字符串,以便通过这种方式在缓冲区变量之间手动添加一些预定义的空格来响应应用程序

const space = ' ';
const nextLine = '\r\n';

const nodeResp = Buffer.concat([
    Buffer.from(` This ${nextLine}`),
    Buffer.from(` is ${nextLine} `),
    Buffer.from(` a ${nextLine}`),
    Buffer.from(`Sample ${space.repeat(84)} : yess ${nextLine}`),
    Buffer.from(`React ${space.repeat(85)} : nooo ${nextLine}`),
    Buffer.from(`App ${space.repeat(87)} : yess ${nextLine}`),
    Buffer.from('From Node.')]);

  res.set('Content-Type', 'text/plain').send(nodeResp);
“space.repeat”方法会在浏览器和分辨率之间返回相同的空间吗

我的意思是,上述代码的输出在所有分辨率/浏览器上都是相同的,或者在不同环境/操作系统的不同空间中显示结果

我正在学习NodeJS,在这方面需要一些帮助

有人能在这个问题上指导我吗


提前感谢。

这里使用的字符串原型的repeat方法,只要重复的变量没有改变,就会得到相同的结果。这里使用的字符串原型的repeat方法,只要重复的变量没有改变,就会得到相同的结果。