3 ms·
%s – string %i or %d – integer %o or %O – object %f – float Why were these ever specific types, instead of just one option that looks at the parame
by lights0123 6y ago
%s – string
%i or %d – integer
%o or %O – object
%f – float
Why were these ever specific types, instead of just one option that looks at the parameter type?
- sombremesa 6y ago> parameter type laughs in JS
- yunohn 6y agoProbably as a remnant of C's printf? Python has the same for its string formatting.
- okbake 6y agoI could see both, but things like integer vs float couldn't be determined from the type, since you just have the single `number` type. That being said, you could just convert to an int on the value you're passing in rather than having the interpolation do it for you. Same thing with object vs string, you could pass in `obj.toString()` instead of just `obj` with an `%s`