I would use replaceAll for this meanwhile
replaceAll
var string = 'MyString\u0000\u0000\u0000'; console.log(string.length); // 11 console.log(string.replaceAll('\0', '').length); // 8