Skip to content

newListOfObjectFunctions

Wesley de Groot edited this page Nov 19, 2015 · 2 revisions

Weird page name.

var x = {}
x.y = function (d) { console.log(d) }
x.x = 'ok'

And/Or

var y = {
  y: function (d) { console.log(d) },
  x: 'ok'
}

Returns

> x.y('hi')
[Log] hi
undefined // Because of no return value
> x.x
"ok" = $1

And

> y.y('hi')
[Log] hi
undefined // Because of no return value
> y.x
"ok" = $1

Now with return

var xr = {}
xr.y = function (d) { console.log(d); return d }
xr.x = 'ok'

And/Or

var xy = {
  y: function (d) { console.log(d); return d },
  x: 'ok'
}

Returns

> xr.y('d')
[Log] d
< "d" = $3
> xr.x
"ok" = $1

And

> xy.y('d')
[Log] d
< "d" = $3
> xy.x
"ok" = $1

...

Clone this wiki locally