Skip to content

Instantly share code, notes, and snippets.

@jigewxy
Last active June 28, 2017 06:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jigewxy/ea9500fae205aeb95c7a40cf19337b6a to your computer and use it in GitHub Desktop.
Save jigewxy/ea9500fae205aeb95c7a40cf19337b6a to your computer and use it in GitHub Desktop.
JS Bin[Array-like object]// source http://jsbin.com/kalovug
var x = {'5':'cliff', '6':'19', length:3};
var y = Array.prototype.slice.call(x);
console.log(y);
// result: [undefined, "cliff", "19"]
var a = {'0':'cliff', '1':'19', length:4};
var b = Array.prototype.slice.call(a);
console.log(b);
//result: ["cliff", "19", undefined, undefined]
@jigewxy
Copy link
Author

jigewxy commented Jun 28, 2017

Be aware of the relationship of properties in Number and its position in sliced output.

  1. length property determine the output length.
  2. only properties in number are indexable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment