Hallo Martin.
Der Vergleichsoperator ergibt bereits das Ergebnis true oder false, so dass
myOption.selected = (testArr[i]==testSel);
nicht nur kürzer, sondern IMHO auch übersichtlicher und effizienter ist.
Womit du natürlich absolut recht hast. (Klar, was sollte ein Vergleich auch sonst zurück geben.)
Deine etwas schwerfällige Formulierung mit dem Fragezeichen-Operator erinnert mich an Ausdrücke wie if (variable==true), bei denen ich mich regelmäßig veräppelt fühle: Ist es wahr, dass die Variable wahr ist?
In diesem Falle ist die verkürzte Schreibe in der Tat nützlich, danke.
Einen schönen Sonntag noch.
Gruß, Ashura
--
sh:( fo:} ch:? rl:( br: n4:~ ie:{ mo:| va:) de:> zu:} fl:( ss:) ls:[ js:|
„It is required that HTML be a common language between all platforms. This implies no device-specific markup, or anything which requires control over fonts or colors, for example. This is in keeping with the SGML ideal.“
[HTML Design Constraints: Logical Markup]
sh:( fo:} ch:? rl:( br: n4:~ ie:{ mo:| va:) de:> zu:} fl:( ss:) ls:[ js:|
„It is required that HTML be a common language between all platforms. This implies no device-specific markup, or anything which requires control over fonts or colors, for example. This is in keeping with the SGML ideal.“
[HTML Design Constraints: Logical Markup]