3 ms·
> x = 4 4 > y = new (x.constructor)(x) [Number: 4] > x.constructor [Function: Number] > y.constructor [Function: Number] > typeof x 'number' > typeof
by freeopinion 8y ago
> x = 4
4
> y = new (x.constructor)(x)
[Number: 4]
> x.constructor
[Function: Number]
> y.constructor
[Function: Number]
> typeof x
'number'
> typeof y
'object'
> x
4
> y
[Number: 4]
Is y a clone of x?
- snek 8y agono its boxed. take `y.valueOf()` and you've got a successful clone.