Are you familiar with languages that allow operator overloading? One big problem is achieving a common understanding of what an operator on a object means. For example, why is "Hello world" * 2 = ["Hello world", "Hello world"] and not "Hello worldHello world"?
How’s it going, I'm a Adam, a Full-Stack Engineer, actively searching for work. I'm all about JavaScript. And Frontend but don't let that fool you - I've also got some serious Backend skills.
Location
City of Bath, UK 🇬🇧
Education
10 plus years* active enterprise development experience and a Fine art degree 🎨
As a JavaScript guy, we do have OO but its not well known and a bit of a hack. Although it looks cool, it's exotic, so I will never use the technique for fear of other developers scratching thier heads... That being said a plus operator against a string does have quite a bit of terrible type coercion potentials, all very confusing. I suppose the only way to avoid this is to have specifications, OO is not in the spec for JavaScript
JavaScript is truly object-oriented - you can create "objects" directly without the help of constructor functions or classes. JavaScript doesn't implement class-based object orientation like mainstream OOP languages (which are essentially class-oriented). JavaScript classes are a template for creating objects. (Though in some ways JavaScript is also function-oriented)
Function overloading isn't an OO feature. For example Erlang (a functional language) allows the reuse of a function name as long as the arity (number of accepted arguments) varies. And in C++ you can overload non-member functions so procedural code can use overloaded functions (same name but the parameter type signature varies). Operator overloading tends to be an extension of function overloading.
How’s it going, I'm a Adam, a Full-Stack Engineer, actively searching for work. I'm all about JavaScript. And Frontend but don't let that fool you - I've also got some serious Backend skills.
Location
City of Bath, UK 🇬🇧
Education
10 plus years* active enterprise development experience and a Fine art degree 🎨
Are you familiar with languages that allow operator overloading? One big problem is achieving a common understanding of what an operator on a object means. For example, why is "Hello world" * 2 = ["Hello world", "Hello world"] and not "Hello worldHello world"?
As a JavaScript guy, we do have OO but its not well known and a bit of a hack. Although it looks cool, it's exotic, so I will never use the technique for fear of other developers scratching thier heads... That being said a plus operator against a string does have quite a bit of terrible type coercion potentials, all very confusing. I suppose the only way to avoid this is to have specifications, OO is not in the spec for JavaScript
JavaScript is truly object-oriented - you can create "objects" directly without the help of constructor functions or classes. JavaScript doesn't implement class-based object orientation like mainstream OOP languages (which are essentially class-oriented). JavaScript classes are a template for creating objects. (Though in some ways JavaScript is also function-oriented)
Function overloading isn't an OO feature. For example Erlang (a functional language) allows the reuse of a function name as long as the arity (number of accepted arguments) varies. And in C++ you can overload non-member functions so procedural code can use overloaded functions (same name but the parameter type signature varies). Operator overloading tends to be an extension of function overloading.
OO oporator overloading
Not OOP
dev.to/adam_cyclones/oporator-over...