It works, but like this it only removes 1 instance of a null-byte. You need to do it with Regular Expressions and the g modifier
var string = 'MyString\u0000\u0000\u0000';
console.log(string.length); // 11
console.log(string.replace('\0', '').length); // 10
console.log(string.replace(/\0/g, '').length); // 8