We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
实现函数:将对象小驼峰式的属性名转下划线如:userName -> user_name
The text was updated successfully, but these errors were encountered:
function transform(str) { let res = ""; for (let i = 0; i < str.length; i++) { if (str[i] >= "A" && str[i] <= "Z") { res += "_" + str[i].toLowerCase(); } else { res += str[i]; } } return res; } console.log(transform("strAbc"));
Sorry, something went wrong.
str.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
let userName = "userName"; userName = userName.replace(/([a-z])([A-Z])/g, function(text, $1, $2){ return $1 + "_" + $2.toLowerCase(); }) console.log(userName)
No branches or pull requests
实现函数:将对象小驼峰式的属性名转下划线如:userName -> user_name
The text was updated successfully, but these errors were encountered: