I'm working on a project which makes heavy use of extension methods to convert strings from the UI-layer into their appropriate object-types in the code-layer: (pseudo-code)
// C#
/*
Converts a String from the UI-layer, formatted according to a user-defined
UI-culture preference (in this case from da-DK) into a Double
*/
Double d = "1.000,50".fromWebStringToDouble(); // 1000.5
To unify the programming experience across C# and JavaScript, I want to modify the prototypes of the String
, Date
and Number
object in JavaScript, to implement similar functionality.
Question is: Is this a good idea? We all know that modifying Array
's prototype seriously cripples the object. But does this horror-scenario apply to the String
, Date
and Number
object?