0

Starting to learn javascript but am confused as to how to define a class. Is the following a way to define a class?

var bar = function (a, b) { var product = a*b; var sum = a+b; return function() {return product / sum}; }; 

I think that it is just a function but was told that it was also a class.

0

1 Answer 1

0

This would be a plain function

function (a, b) { var product = a*b; var sum = a+b; return product / sum; }; 

This would be more like a class in java because you're assigning a function to an object:

var bar = function (a, b) { var product = a*b; var sum = a+b; return function() {return product / sum}; }; 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.