Function.prototype.toString()
は、空白とコメントを含むソース コード テキストの正確なスライスを返すようになりました。以下は、古い動作と新しい動作を比較した例です。
// Note the comment between the `function` keyword
// and the function name, as well as the space following
// the function name.
function /* a comment */ foo () {}
// Previously, in V8:
foo.toString();
// → 'function foo() {}'
// ^ no comment
// ^ no space
// Now:
foo.toString();
// → 'function /* comment */ foo () {}'
機能サポート #
- Chrome: バージョン 66 以降でサポート
- Firefox: サポート
- Safari: サポートなし
- Node.js: バージョン 8 以降でサポート
- Babel: サポートなし