JavaScript React Basics (retired) Thinking in Components Loops and Lists in JSX

Var vs function

I'm working through this class but in a different course I was studying to create a component you'd use var NAME = React.createClass ..... Is there a difference?

3 Answers

Mikis Woodwinter
Mikis Woodwinter
44,934 Points

Hey Christopher,

It's just two types of architectures for creating a React Component. As you complete the course, the instructor will explain the differences between the two as well as the pros and the cons of each.

Ok cool! I just wasn't sure if there was a difference. I'll just keep up with the course and see what I learn! Thank you!

Alexander Alegre
Alexander Alegre
14,340 Points

That syntax is just for React. Vanilla JavaScript if you want to create an object it would be "var name = new Object();". A function would be "function name = (parameters) {code;}" or you can assign it to a variable by "var x = function...." But it's just syntax differences.

Hope this helps.