结合字符串/对象进行打印

时间:2018-02-02 20:48:28

标签: javascript jquery

如何将fNameTD + lNameTD组合在一起?

let fNameTD = $('<td>').text(employees[i].FirstName);
let lNameTD = $('<td>').text(employees[i].LastName);

1 个答案:

答案 0 :(得分:0)

您可以将字符串与+连接起来,类似于我在下面的操作:

&#13;
&#13;
let employees = [{
  firstName: 'Bill',
  lastName: 'Jones'
}, {
  firstName: 'Tom',
  lastName: 'Davis'
}];

for (let i = 0; i < employees.length; i++) {
  let fullNameTd = employees[i].firstName + ' ' + employees[i].lastName;
  console.log(fullNameTd);
}
&#13;
&#13;
&#13;