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 case

  • trim

  • pad

  • slugify

  • latinise

  • sprintf'y

  • truncate

  • escape 

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:

Console
Use Voca.js

Explanation

  • Line 9: We include the Voca.js library file from the CDN server. The variable v accesses the library function.

  • Line 11: We create a string, str, with the value, Educative Corporation.

  • Line 13: We use the upperCase method of the Voca.js library to convert the str to uppercase.

  • Line 14: We use the camelCase method of the Voca.js library to convert the str to camelcase.

  • Line 15: We use the kebabCase method of the Voca.js library to convert the str to kebab-case.

  • Line 18: We use the reverse method to reverse the str.

  • Line 21: We assign an str variable with a string with HTML tags.

  • Line 23: We use the escapeHtml method to escape the HTML tags in the string.

Free Resources