📜  如何在 js 中使用 map 方法创建元素 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:17.645000             🧑  作者: Mango

代码示例2
// A function which returns the last character of a given string
function returnLast(arr) {
  return arr.at(-1);
}

let invoiceRef = 'myinvoice01';

console.log( returnLast(invoiceRef) );
// Logs: '1'

invoiceRef = 'myinvoice02';

console.log( returnLast(invoiceRef) );
// Logs: '2'