Have you told Joplin what language it is?
The highlighting can't be copied across, the syntax is evaluated by codemirror and highlight.js on the fly by them guessing what language it is unless you tell it explicitly.
In the Markdown editor you can put it on the backticks (e.g
```js
your code here
or if you are using the richtext editor you can double click the code block and add it there.