2

For example given a string "43.44", is there any way to convert it to a float without casting or using parseFloat?

2 Answers 2

5

You could use an implicid type casting with an unary plus +.

var string = "43.44",
    number = +string;
    
console.log(number);
console.log(typeof number);

Sign up to request clarification or add additional context in comments.

Comments

0

you can do

let str = '43.44'

let val = (1 * str);
console.log(val);
console.log(typeof val)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.