How to create a new primitive or object where I can use the operators used in Number?
I want to create a new object like Number, with a different name, another properties and where I can to use the operators i.e. 4+5
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can override an objects
valueOfprototype to create your own primitive:See examples and more info here: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/valueOf