What is the Voca.js library?
Overview
Voca is a popular JavaScript library that contains multiple utility and helper functions for string-related operations. Voca.js can be used directly inside a browser and also with Node.js.
Voca.js includes multiple helper functions for the following:
change casetrimpadslugifylatinisesprintf'ytruncateescape
Note: Voca.js is licensed under the MIT license. You can find the repo of Voca.js here.
Example
The code below demonstrates how to use Voca.js:
Explanation
Line 9: We include the Voca.js library file from the CDN server. The variable
vaccesses the library function.Line 11: We create a string,
str, with the value,Educative Corporation.Line 13: We use the
upperCasemethod of the Voca.js library to convert thestrto uppercase.Line 14: We use the
camelCasemethod of the Voca.js library to convert thestrto camelcase.Line 15: We use the
kebabCasemethod of the Voca.js library to convert thestrto kebab-case.Line 18: We use the
reversemethod to reverse thestr.Line 21: We assign an
strvariable with a string with HTML tags.Line 23: We use the
escapeHtmlmethod to escape the HTML tags in the string.