"string and array generics methods will be deprecated in the future" Code Answer

5

generic means "referring to all", and in this case it means the methods which are independent from the instances, i.e.

var foo = 'bar';
string.split(bar, 'a'); // "generic" method, non-standard, will throw referenceerrors
bar.split('a'); // instance method, standard

it is very unlikely you've written any code in the non-standard way as it already won't work on most people's browsers.


if you were using this way of accessing bar a method for type foo to use them on foo-like things, go via foo.prototype.bar.call instead, i.e.

var baz = {length: 2, 0: 'fizz', 1: 'buzz'}; // array-like
array.slice(baz, 0, 1); // bad
array.prototype.slice.call(baz, 0, 1); // good
By maximkou on September 19 2022

Answers related to “string and array generics methods will be deprecated in the future”

Only authorized users can answer the Search term. Please sign in first, or register a free account.