JavaScript coerces between primitives and objects. In this case the number value is coerced to a Number object in order to access the prototype method sayMyNumber. Actually, in this way primitives have access to all the properties and methods defined by their respective object constructors. However, they are different from the objects as they are immutable.
Thus, (34).sayMyNumber(); works; so does (34).toFixed() or (34).toPrecision().
As for 34.sayMyNumber();, as hindmost pointed out, is a syntax error.