Technology stocks are racing toward their best year in a decade, underscoring investors’ interest in companies offering everything from memory chips to social-media platforms.

Investors have favored shares of rapidly growing, relatively pricey companies over their more low-valued counterparts for much of the more-than-decadelong bull market.

Although...