You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Template literals are lowered to + concatenation, calling valueOf instead of toString #1477
Obfuscating an untagged template literal such as `Today: ${when}` should convert each substituted expression to a string using ToString (calling toString before valueOf, or passing the "string" hint to Symbol.toPrimitive), matching the runtime behavior of the original code (e.g. printing Today: Tue Nov 14 2023). Lowering template literals to ''.concat(...) preserves ES5 compatibility while calling ToString on each argument.
Current Behavior
JavaScriptObfuscator.obfuscate rewrites untagged template literals into '...' + expr binary expressions across all presets. For objects that define both valueOf and toString (such as Moment.js/Day.js instances or Decimal wrappers) or Symbol.toPrimitive, + invokes ToPrimitive with the "default" hint instead of ToString ("string" hint), so the obfuscated code calls valueOf instead of toString and prints Today: 1700000000000.
Steps to Reproduce
Define an object with both valueOf and toString (or Symbol.toPrimitive) and interpolate it inside a template literal.
Obfuscate the code with JavaScriptObfuscator.obfuscate(code).
Execute both the original and obfuscated code and compare their output.
JavaScript Obfuscator Edition
JavaScript Obfuscator Open Source
Your Environment
Obfuscator version used: 5.10.0
Node version used: v24.14.1
Stack trace
N/A (wrong runtime output, no exception thrown)
Minimal working example that will help to reproduce issue
constJavaScriptObfuscator=require('javascript-obfuscator');constcode=`var when = { valueOf() { return 1700000000000; }, toString() { return "Tue Nov 14 2023"; } };console.log(\`Today: \${when}\`);`;eval(code);// Output: Today: Tue Nov 14 2023eval(JavaScriptObfuscator.obfuscate(code).getObfuscatedCode());// Output: Today: 1700000000000
Activity
Fixes for 1471-1477
sanex3339 commentedon Nov 12, 2026
Released as 5.10.1