While object keys are deterministically-ordered in some runtime environments, it's still not safe to perform operations on values held in two separate objects, accessing them by a correlated numeric index.
According to the information in your comment, it sounds like you don't know the name of the property holding the value that you want to target in each object, but you do know that the name is the same in both objects, so a safer approach would be:
TS Playground
/** Given that values in the objects are correlated by property key: */
function getDiff <
K extends PropertyKey,
T extends Record<K, number>,
>(minuend: T, subtrahend: T, key: K): number {
return minuend[key] - subtrahend[key];
}
type NumberValues = Record<string, number>;
declare const localScore: NumberValues;
declare const score: NumberValues;
const [key] = Object.keys(localScore); // destructure first enumerable property key
const diff = getDiff(score, localScore, key); // number, but possibly negative
const absoluteDiff = Math.abs(diff);