- Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
String.prototype.replace
passes position and input arguments to replacer functions and the return value from RegExp.prototype.exec
has "index" and "input" properties; JSON.parse
could behave similarly.
const input = '\n\t"use\\u0020strict"'; let spied; const parsed = JSON.parse(input, (key, val, context) => (spied = context, val)); parsed === 'use strict'; // → true spied.source === '"use\\u0020strict"'; // → true spied.index === 2; // → true spied.input === input; // → true
As noted by @rbuckton, this could be useful for error reporting.
Metadata
Metadata
Assignees
Labels
No labels