Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
Cómo convertir entre camelCase PascalCase snake_case kebab-case (JS)

Tal vez a alguien le resulte útil: cómo convertir entre camelCase PascalCase snake_case kebab-case (JS)

about 4 years ago · Santiago Gelvez
2 answers
Answer question

0

'use strict' const log = console.log.bind(console); const toCamel = val => val.trim().replace(/([-_ ]+)./g, $ => $.at(-1).toUpperCase()); const toKebab = val => toCamel(val).replace(/[AZ]+(?![az])|[AZ]/g, ($, o) => (o ? "-" : "") + $.toLowerCase()) const toSnake = val => toCamel(val).replace(/[AZ]+(?![az])|[AZ]/g, ($, o) => (o ? "_" : "") + $.toLowerCase()) const toPascal = val => toCamel(val).replace(/^./, $ => $.toUpperCase()); const testCase = [ 'StackOverflow', 'camelCase', 'alllowercase', 'JSONdata', ' aaa--------bbb-ccc', 'aaa_______bbb__ccc_dddddddddd', 'aaa bbb -ccc', 'ddd-eee-fff', ]; log(testCase.map(toCamel));
about 4 years ago · Santiago Gelvez Report

0

Puede usar el paquete lodash.

 _.kebabCase('Foo Bar'); // => 'foo-bar' _.snakeCase('Foo Bar'); // => 'foo_bar' startCase(camelCase(str)).replace(/ /g, '');
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!