when passing an array to Ox.values, return a clone, not the original array
This commit is contained in:
parent
9cc9a167f8
commit
30e59f5538
1 changed files with 3 additions and 3 deletions
|
@ -313,8 +313,8 @@ Ox.map <f> Transforms the values of an array, object or string
|
||||||
objects and strings.
|
objects and strings.
|
||||||
> Ox.map([2, 1, 0], function(v, i) { return v == i; })
|
> Ox.map([2, 1, 0], function(v, i) { return v == i; })
|
||||||
[false, true, false]
|
[false, true, false]
|
||||||
> Ox.map({a: 'a', b: 'a', c: 'a'}, function(v, k) { return v == k; })
|
> Ox.map({a: 'b', b: 'b', c: 'b'}, function(v, k) { return v == k; })
|
||||||
{a: true, b: false, c: false}
|
{a: false, b: true, c: false}
|
||||||
> Ox.map('foo', function(v) { return v.toUpperCase(); })
|
> Ox.map('foo', function(v) { return v.toUpperCase(); })
|
||||||
'FOO'
|
'FOO'
|
||||||
> Ox.map([,], function(v, i) { return i; })
|
> Ox.map([,], function(v, i) { return i; })
|
||||||
|
@ -537,7 +537,7 @@ Ox.values <f> Returns the values of a collection
|
||||||
Ox.values = function(collection) {
|
Ox.values = function(collection) {
|
||||||
var ret, type = Ox.typeOf(collection);
|
var ret, type = Ox.typeOf(collection);
|
||||||
if (type == 'array') {
|
if (type == 'array') {
|
||||||
ret = collection;
|
ret = Ox.clone(collection);
|
||||||
} else if (type == 'object') {
|
} else if (type == 'object') {
|
||||||
ret = [];
|
ret = [];
|
||||||
Ox.forEach(collection, function(value) {
|
Ox.forEach(collection, function(value) {
|
||||||
|
|
Loading…
Reference in a new issue