文字顺序排列
const bands = ['The Plot in You', 'The Devil Wears Prada', 'Pierce the Veil', 'Norma Jean', 'The Bled', 'Say Anything', 'The Midway State', 'We Came as Romans', 'Counterparts', 'Oh, Sleeper', 'A Skylit Drive', 'Anywhere But Here', 'An Old Dog'];
const strip(bandName){
return bandName.replace(/^(a |the |an )/i,'').trim();
}
const sortedBands = bands.sort((a,b)=> strip(a)>strip(b)?1:-1)
document.querySelector('#band').innerHTML=sortedBands.map(item =>
`<li>${item}</li>`
).join('');
>>: #18 用免费 Serverless 及 JavaScript 写 Telegram 聊天机器人!
当我们正准备将企业AD帐号透过传送门(Azure AD Connector)运送到Microsoft...
目的 当一个行为需要经过多道步骤时,可以将步骤串在一起。 说明 该模式常见於两种情境: 行为不一定一...
执行环境(Execution context) 我们上一篇有提到 若在 callMe 宣告任何变数 ...
阵列 阵列是一群具有相同名称或资料型态的变数集合。 由於整个阵列中的变数均具有相同的名称,因此若要存...
Filter 在海量的数据中如果想要快速找到特定关键字的资料,我们需要filter这个很实用的功能...