Question about object.method in JavaScript
javascript, methods, oop
Solution
In JavaScript, everything is an object, even functions and integers. It is perfectly OK to think of methods on numbers and strings. For example:
>>> (3.123).toString()
"3.123"
Problem
This is a follow-up question to this one. Take a look at these two examples: ``` var number1 = new Number(3.123); number1 = number1.toFixed(2); alert(number1); var number2 = 3.123; number2 = number2.toFixed(2); alert(number2); ``` I realize they both end up with the same value, but is it correct thinking to refer to a method of a primitive value? (In other words, 3.123.method as opposed to object.method?)