Name: Anonymous 2016-12-09 22:15
...is just one type you have no control over.
var x = 4; // x is a Number
x = []; // x is an Array
x
is. typeof [1, 2, 3] // "object"
var x = [1, 2];
x.anus = "haxed";
Object.keys(x); // ["0", "1", "anus"]
[1, 2, 3].constructor // function Array() { [native code] }
new Array().constructor // function Array() { [native code] }
[].__proto__ === Array.prototype // true
Object.prototype.toString([1, 2]) // "[object Array]"
(function() {
// Looks like an array...
arguments[0] // "hello"
arguments[1] // "there"
arguments.length // 2
// But isn't really
arguments.constructor; // function Object() { [native code] }
Object.prototype.toString(arguments); // "[object Object]"
arguments.__proto__ // Object.prototype
}('hello', 'there'))
x
has the same type whether it's equal to 4 or to [] - otherwise it would issue an error when you triedvar x = 4
var y = x[0]
data Any = A Int | B String | C (Array Int) | ...