Edited for clarification:

function Num(str) { 
  return str;
}

which returns when the input is 2^15

13

I want to know how I can keep it from evaluating str and just return 2^15 instead of returning 13.

有帮助吗?

解决方案

var string = "2^15"; // wrap in double quotes to treat it as a string

As a sidenote, avoid calling your variables 'string', since it is a reserved keyword in a lot of languages and reduces readability.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top