给出了各种对象,例如:
const myObj = [['a','b','c','d'], ['e','f','j','h'], ['i','j','k','l'], ['m','n','o','p']];
您需要在网站页面上显示它们。我编写了这个函数来将对象转换为字符串:
const objToString = () => {
let a = '[';
let l = myObj.length;
for (let i of myObj){
a += '[ ' + i + ' ]';
l -= 1;
if(l > 0){
a += ','
}
}
a += ']'
return a + '<br> to create a table from an object';};
你能告诉我是否有更简单的方法吗?由于通常的 toString() 不起作用 (((
可能是最简单的方法
输出应该是什么?