At the link below (MDN site) it says "String generics are non-standard, deprecated and might get removed in the future. Note that you can not rely on them cross-browser without using the shim that is provided below."
Are the methods they are referring to the methods listed in the shim they provide below this statement? This is the only reference to the phrase "String generics" I have seen so it's confusing me.
Also the same question for Array generics as the site mentions a similar situation for them as well.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#String_generic_methods
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#Array_generic_methods
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With