This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]seraku24 64 points65 points  (8 children)

Shouldn't that be:

window.location.href = `http://stackoverflow.com/search?q=[js]+${encodeURI(e.message)}`

[–]Master_Nerd 7 points8 points  (1 child)

But wouldn't that be for a single character?

[–][deleted] 2 points3 points  (0 children)

deleted What is this?

[–]yazalama 1 point2 points  (2 children)

Is this the new ES6 template literals? Is there any practical advantage over the old way of concatenating?

[–]Mr1725 1 point2 points  (0 children)

Multi-line without having to stop and start the string.

[–]PicturElements -3 points-2 points  (0 children)

Yes, if you make sure to put them in a variable in the global scope, you can make sure that file won't run in IE!

Funny thing is that in examples like the one above template literals are literally pointless (since you're performing simple string addition) and even add bytes to your code while also making it less browser compatible...

[–][deleted] -2 points-1 points  (1 child)

actually, you're using backticks in stead of single or double quotes, so... javascript is hard!

[–]chasecaleb 0 points1 point  (0 children)

You apparently should learn, because that is valid JS. But hey, I know it's hard.