这个响应头构造函数会输出什么?

来自 安全响应头
Node 24 入门 2分钟

这个响应头构造函数会输出什么?

JavaScript
function headers({ https }) {
  const result = {
    'X-Content-Type-Options': 'nosniff',
  };
  if (https) {
    result['Strict-Transport-Security'] = 'max-age=31536000';
  }
  return result;
}

console.log(Object.keys(headers({ https: false })).length);
console.log(Object.keys(headers({ https: true })).length);
在试验场中打开
报告错误