Operands to the
+
operator should be both numbers or both strings334 static getComponentPorts(params: Map<string, any>, minttypestring: string): Array<ComponentPort> {
335 const threeduftypesting = ComponentAPI.getTypeForMINT(minttypestring);
336 if (threeduftypesting === null) {
337 throw new Error("Component Ports of: " + threeduftypesting + " not found in library");338 }
339 const definition = ComponentAPI.library[threeduftypesting].object;
340 const params_to_pass: { [index: string]: any } = {};
Description
It is recommended to use operands of the same type while adding values as mismatched operand types might result in unexpected output.
When doing addition with operands of different types, the output sometimes results in simple concatenation instead of addition.
1 + '2'
While the user may expect this to result in 3
(by integer addition) it will instead result in '12'
(by string concatenation) .
Bad Practice
var foo = '5.5' + 5;
var foo = 1n + 1;
Recommended
var foo = parseInt('5.5', 10) + 10;
var foo = 1n + 1n;