Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Number constructor issue #89

Closed
f-xyz opened this issue Jul 5, 2015 · 2 comments
Closed

Number constructor issue #89

f-xyz opened this issue Jul 5, 2015 · 2 comments

Comments

@f-xyz
Copy link

f-xyz commented Jul 5, 2015

It changes Number constructor behavior and breaks Chai.js assertion library's.

Example code: 1.js

'use strict';

require('core-js');

var numberObject = new Number(1);

console.log(numberObject); // [Number: 1]
console.log('\n');

console.log(numberObject.constructor(numberObject)); // [Number: 1], should be 1
console.log(Number(numberObject)); // 1
console.log(Number.prototype.constructor(numberObject)); // 1
console.log('\n');

console.log(typeof numberObject.constructor(numberObject)); // object, should be number
console.log(typeof Number(numberObject)); // number
console.log(typeof Number.prototype.constructor(numberObject)); / number
console.log('\n');

console.log(numberObject.constructor === Number); // true
console.log(numberObject.constructor === Number.prototype.constructor); // true
console.log('\n');

console.log(Number.toString()); // function Number() { [native code] }
console.log(numberObject.constructor.toString()); // function Number() { [native code] }
console.log('\n');

console.log(1 instanceof Number); // false
console.log(Object.prototype.toString.call(1)); // [object Number]
console.log(numberObject instanceof Number); // true
console.log(Object.prototype.toString.call(numberObject)); // [object Number]
console.log('\n');

Output of node 1.js

[Number: 1]

[Number: 1] // should be 1
1
1

object // should be number
number
number

true
true

function Number() { [native code] }
function Number() { [native code] }

false
[object Number]
true
[object Number]
@zloirock
Copy link
Owner

zloirock commented Jul 5, 2015

Thanks.

@f-xyz
Copy link
Author

f-xyz commented Jul 5, 2015

So fast and on Sunday! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants