Home  >  Article  >  Web Front-end  >  What is the usage of math.sqrt in vue

What is the usage of math.sqrt in vue

WBOY
WBOYOriginal
2022-03-23 15:13:134615browse

In vue, the "math.sqrt" method is used to return the square root of a number. It is a built-in method of math. If the set number is a negative number, the returned result is NaN. The syntax is "math.sqrt( value)".

What is the usage of math.sqrt in vue

The operating environment of this article: Windows 10 system, Vue version 2.9.6, DELL G3 computer.

What is the usage of math.sqrt in vue

sqrt() method returns the square root of a number.

The syntax is:

Math.sqrt(x)

If x is a negative number, NaN is returned.

Examples are as follows:

  var a = Math.sqrt(0);
  var b = Math.sqrt(1);
  var c = Math.sqrt(9);
  var d = Math.sqrt(64);
  var e = Math.sqrt(-9);

Output results:

0
1
3
8
NaN

Expand knowledge:

Math built-in methods

// Math的内置方法
// 1 random()返回0~1的数字,不包含1
console.log(Math.random());
// 2 round()返回一个四舍五入的数字
console.log(Math.round(1.6)); // 2
// 3 abs()
console.log(Math.abs(-2.566)); // 2.566
// 4 floor()
console.log(Math.floor(2.3)); // 2
// 5 ceil()
console.log(Math.ceil(2.1)); // 3
// 6 max() min
console.log(Math.max(1,2,3,7,8,9,5)); // 9
console.log(Math.min(1,2,3,7,8,9,5)); // 1
// 7 PI
console.log(Math.PI); // 3.141592653589793
// 8 pow(底数,次方)
console.log(Math.pow(2,3)); 8
// 9 sqrt()
console.log(Math.sqrt(4)); // 2

[Related recommendations: "vue.js tutorial"】

The above is the detailed content of What is the usage of math.sqrt in vue. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn