* Returns ToString(V). * @see https://tc39.es/ecma262/#sec-tostring * @param {any} V JavaScript value. * @param {ConversionOptions} [options] Conversion options. * @returns {string}
(V, options = kEmptyObject)
| 292 | * @returns {string} |
| 293 | */ |
| 294 | function toString(V, options = kEmptyObject) { |
| 295 | if (typeof V === 'symbol') { |
| 296 | // ECMA-262 ToString step 2: Symbol values throw. |
| 297 | throw makeException( |
| 298 | 'is a Symbol and cannot be converted to a string.', |
| 299 | options); |
| 300 | } |
| 301 | |
| 302 | // The String function performs ToString for all non-Symbol primitives and |
| 303 | // objects, including ToPrimitive(V, string). String concatenation is not |
| 304 | // equivalent because it uses ToPrimitive(V, default). Abrupt completions |
| 305 | // and native TypeErrors propagate unchanged. This is an intentional |
| 306 | // diagnostics tradeoff: decorating object conversion failures would require |
| 307 | // maintaining local ECMA-262 ToPrimitive and OrdinaryToPrimitive |
| 308 | // implementations. |
| 309 | return String(V); |
| 310 | } |
| 311 | |
| 312 | /** |
| 313 | * Converts a JavaScript value to a Web IDL integer value. |
no test coverage detected
searching dependent graphs…