Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

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.