Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/string/index.ts>count

A JavaScript extension package for building strong and modern applications.
Latest
function count
import { count } from "https://deno.land/x/ayonli_jsext@v0.9.72/string/index.ts";

Counts the occurrence of the sub-string in the string.

Examples

Example 1

import { count } from "@ayonli/jsext/string";

console.log(count("hello world", "o")); // 2
console.log(count("hello world", "i")); // 0

Parameters

str: string
sub: string

Returns

number