1

The ${} is template literals. What's {} without the $ sign?

In React:

function App(){
    return(<div temp={3}></div>);
}

(I was looking up the difference and nothing came up. So, I think this question is needed as I couldn't know if I was using JS or JSX.)

Lionel Rowe
  • 5,164
  • 1
  • 14
  • 27
Akshay K Nair
  • 1,107
  • 16
  • 29
  • Does this answer your question? [What do curly braces mean in JSX (React)?](https://stackoverflow.com/questions/43904825/what-do-curly-braces-mean-in-jsx-react) –  Jul 31 '20 at 12:23
  • You use `${}` in string templates like `const k = \`my name is ${name}\`` you use `{}` whenever you want to put some Java code in your JSX code like `
    {name}
    `
    – Nishant Jul 31 '20 at 12:23
  • @Megapteranovaeangliae I was looking up the difference and nothing came up. So, I think this question is needed as I couldn't knew if i was using js or jsx. – Akshay K Nair Jul 31 '20 at 12:28
  • You tagged this [tag:reactjs] so you surely must have had some idea you were looking at something which was not vanilla javascipt? – Jamiec Jul 31 '20 at 12:28
  • @Jamiec Its funny, i don't know anything about reactjs. Its the first time ever. I've heard there's JSX in react but the tutorial I'm following says it only use vanilla javascript. (And even said JSX is hard for beginners and they wont use it) – Akshay K Nair Jul 31 '20 at 12:32
  • Ok well check the links in my answers, it explains JSX is a very easy to understand manner. – Jamiec Jul 31 '20 at 12:33

1 Answers1

4

You're quite correct that javascript uses ${} to make use of template literals within strings surrounded by backticks `

The code you pasted is not javascript, it is JSX and the { and } is how you embed expressions within it.

Jamiec
  • 133,658
  • 13
  • 134
  • 193