8 个有用的JS技巧(推荐)(2)

const user = { name: 'John', surname: 'Doe', details: { email: 'john@doe.com', displayName: 'SuperCoolJohn', joined: '2016-05-05', image: 'path-to-the-image', followers: 45 } } const printUserInfo = (user) => { const text = `The user is ${user.name} ${user.surname}. Email: ${user.details.email}. Display Name: ${user.details.displayName}. ${user.name} has ${user.details.followers} followers.` console.log(text); } printUserInfo(user); // outputs 'The user is John Doe. Email: john@doe.com. Display Name: SuperCoolJohn. John has 45 followers.'

译者:前端小智

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/35fea733ad518b678cff465fee39a01f.html