Js function

does this syntax

data: function () {
                return data;
            }

same as this ?

function (data) {
                return data;
            }

Hi @winzip the difference is that the first one is part of an object and it will be callable through that object scope e.g. objectName.data() whereas the last one can be called within the same scope (maybe global) in the following way data(), but there is actually something wrong with it, the function needs a name and it doesn’t have one, presumably you wanted to use ‘data’ as the function name and not the parameter like so:

function data() {
	return data;
}

Hope that helps,

Andres

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.