如何在 Javascript 中获取字符串的第一个字符
Use s.charAt(0)
示例:
first_char_js_example.js
const s = "banana";
const firstChar = s.charAt(0); // == 'b'
// 这将打印 'b'
console.log(firstChar);Check out similar posts by category:
Javascript
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow