"Behaves similar to" or "behaves similarly to"?

In casual speech you can probably get away with similar, but you may sound uneducated to some. Similarly is the correct adverb form, and it does not sound weird. I would always write similarly in this case. The same is true for different and differently.


As a side note, this sentence lacks subject-verb agreement:

Objects in JavaScript behaves similarly to a regular associate array.

It should be:

Objects in JavaScript behave similarly to regular associate arrays.

(Also, the correct term is associative array)