I am getting a Number that stored as a String from localstorage.
const numb = localstorage.getItem('value');
Now I want to convert it to a Number.
How can I achieve this.
example
"5"
to 5
I am getting a Number that stored as a String from localstorage.
const numb = localstorage.getItem('value');
Now I want to convert it to a Number.
How can I achieve this.
example
"5"
to 5
in order to change string to the number in angular, we can use "+" before our string to convert them to the string. for example we have :
let x = "32";
let y = +x;
console.log(typeof y); //number
console.log(typeof x); //string
you can use parseInt()
to achive this.
parseInt(numb)
or you can use +
operator too
+numb