locutus
Version:
Locutus other languages' standard libraries to JavaScript for fun and educational purposes
15 lines (14 loc) • 492 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.strlen = strlen;
function strlen(str) {
// discuss at: https://locutus.io/c/string/strlen/
// parity verified: C 23
// original by: Kevin van Zonneveld (https://kvz.io)
// note 1: Returns the length of the string.
// example 1: strlen('hello')
// returns 1: 5
// example 2: strlen('')
// returns 2: 0
return (str + '').length;
}