js: capitalize realizes the capitalization of the first letter of the string

Share a small piece of code, input a string, and output a string with the first letter capitalized

Code

function capitalize(value) {
    
    
  return value.charAt(0).toUpperCase() + value.slice(1)
}

// 代码测试
console.log(capitalize('hello'));
// Hello

Implementation code reference:

  1. https://cn.vuejs.org/guide/components/v-model.html#handling-v-model-modifiers

Guess you like

Origin blog.csdn.net/mouday/article/details/131890030
Recommended