I\'d like for something like 5 + 6
to return \"56\"
instead of 11
.
enter code here
var a = 9821099923;
var b = 91;
alert ("" + b + a);
// after concating , result is 919821099923 but its is now converted
into string
console.log(Number.isInteger("" + b + a)) // false
you have to do something like below:-
var c= parseInt("" + b + a)
console.log(c); // 919821099923
console.log(Number.isInteger(c)) // true
Use
var value = "" + 5 + 6;
to force it to strings.
You can return a number by using this trick:
not recommended
[a] + b - 0
Example :
let output = [5] + 6 - 0;
console.log(output); // 56
console.log(typeof output); // number
var value = "" + 5 + 6;
alert(value);