Error guides

Global this, instanceof and prototypes on V8

Global this now includes everything

Rhino ran your code in a private context, so Object.keys(this) at the top level listed only your globals. On V8 your functions sit beside SpreadsheetApp, GmailApp, Math, Date…

// Dispatch by name — Rhino-era
function run(name) { return this[name](); }
function listJobs() { return Object.keys(this).filter(function (k) { return /^job_/.test(k); }); }

// V8 — keep an explicit registry
var JOBS = { daily: jobDaily, weekly: jobWeekly };
function run(name) { return JOBS[name](); }
function listJobs() { return Object.keys(JOBS); }

instanceof fails inside libraries

On V8 a project and its libraries run in different global contexts, so a Date created by the caller is not instanceof Date inside the library.

// Library
function isDate(d) { return Object.prototype.toString.call(d) === '[object Date]'; }  // not: d instanceof Date
function isList(a) { return Array.isArray(a); }                                        // not: a instanceof Array

Adding methods to built-in prototypes

Array.prototype.sum = function () {…} is enumerable, so it appears in every for…in over arrays (including getValues() rows), and on V8 it isn't visible to objects that come from another project or library. Prefer a helper, or make it non-enumerable:

function sum(a) { return a.reduce(function (s, x) { return s + (+x || 0); }, 0); }

Object.defineProperty(Array.prototype, 'sum', { value: function () { return sum(this); }, enumerable: false });

Use for (var i = 0; i < rows.length; i++) or for…of for arrays — not for…in.

How V8Shift handles it

Object.keys(this), for (k in this) and this[name]() inside global functions, built-in prototype assignments, __proto__-style accessors and instanceof Date/Array/Object are flagged with the fix for each.

Have a whole project to migrate? Paste your .gs or upload a zip for a free V8 compatibility report — every occurrence of this pattern with file and line, plus an auto-rewritten project.
Related errors