search
HomeWeb Front-endFront-end Q&AIs math a built-in function in javascript?
Is math a built-in function in javascript?Jul 06, 2021 pm 03:26 PM
javascriptmathbuilt-in functionsbuilt-in objects

math is a built-in javascript object, not a built-in function. The Math object is used to perform mathematical calculations. It contains properties and methods. Its properties include standard mathematical constants, such as the pi constant PI; its methods constitute a mathematical function library, including geometric and arithmetic operations.

Is math a built-in function in javascript?

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

math is a javascript built-in object.

Built-in objects are objects that have been written in js itself. We can use them directly without defining them; commonly used built-in objects in javascript include:

  • String objects : String object, providing properties and methods for operating on strings.

  • Array object: Array object provides properties and methods for array operations.

  • Date object: Date and time object, which can obtain the date and time information of the system.

  • Boolean object: Boolean object, a Boolean variable is a Boolean object. (No properties and methods available)

  • Number object: Numeric object. A numeric variable is a numeric object.

  • Math object: Mathematical object, which provides properties and methods for mathematical operations.

  • RegExp

  • Error

  • Global

## The #Math object is used to perform mathematical calculations. It also contains properties and methods. Its properties include standard mathematical constants, such as the pi constant PI; its methods constitute a mathematical function library, including geometric and arithmetic operations. These methods and constants of the Math object are static, so when using them, you do not need to create a Math object, but directly use the Math object name to access properties or methods, such as

Math.PI, Math.random().

Some common methods of Math objects are listed below.

MethodDescriptionsin(x)Returns the sine of x , the parameter x is expressed in radianscos(x)Returns the cosine value of x, the parameter x is expressed in radianstan(x)Returns the tangent value of x, parameter x is expressed in radiansacos(x)Returns the arc cosine value of x , the parameter x must be a number between -1.0~1.0asin(x)Returns the arc sine value of x, the parameter x must be -1.0~1.0 The number betweenatan(x)returns the arctangent value of x, the parameter x must be a numerical valueabs(x)Returns the absolute value of x, parameter x must be a numerical valueceil(x)Returns greater than or equal to The minimum integer of x. The parameter x must be a numerical value. #exp(x)Returns the value of the xth act of e. The parameter x is any numerical value or expression. floor(x)log(x)Returns the natural logarithm of x, the parameter x is any value or expressionmax(x1,x2)min(x1,x2)pow(x1,x2)return Random floating point number between round(x) Returns the integer after num is rounded. The parameter x must be a numerical valuesqrt(x)Returns the square root of x. The parameter x must be a number greater than or equal to 0javascript learning Tutorial】
Returns the largest integer less than or equal to x. The parameter x must be a numerical value
Return the maximum value among x1 and x2. The parameters x1 and x2 must be numerical values
Return the minimum value among x1 and x2. The parameters x1 and x2 must be numerical values
[Related recommendations:

The above is the detailed content of Is math a built-in function in javascript?. 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
es6数组怎么去掉重复并且重新排序es6数组怎么去掉重复并且重新排序May 05, 2022 pm 07:08 PM

去掉重复并排序的方法:1、使用“Array.from(new Set(arr))”或者“[…new Set(arr)]”语句,去掉数组中的重复元素,返回去重后的新数组;2、利用sort()对去重数组进行排序,语法“去重数组.sort()”。

使用java的Math.log()函数计算自然对数使用java的Math.log()函数计算自然对数Jul 24, 2023 am 11:10 AM

使用Java的Math.log()函数计算自然对数自然对数(Naturallogarithm)是数学中常见的对数类型之一。在Java编程语言中,可以使用Math.log()函数来计算自然对数。下面将介绍该函数的用法,并给出一些代码示例。Math.log()函数是Java中的一个静态方法,用于计算以e为底的对数。该函数接受一个参数x,返回的结果是x的自然对数

使用math.Log2函数计算指定数字的以2为底的对数使用math.Log2函数计算指定数字的以2为底的对数Jul 24, 2023 pm 12:14 PM

使用math.Log2函数计算指定数字的以2为底的对数在数学中,对数是一个重要的概念,它描述了一个数与另一个数(所谓的底)的指数关系。其中,以2为底的对数特别常见,并在计算机科学和信息技术领域中经常用到。在Python编程语言中,我们可以使用math库中的log2函数来计算一个数字的以2为底的对数。下面是一个简单的代码示例:importmathdef

JavaScript对象的构造函数和new操作符(实例详解)JavaScript对象的构造函数和new操作符(实例详解)May 10, 2022 pm 06:16 PM

本篇文章给大家带来了关于JavaScript的相关知识,其中主要介绍了关于对象的构造函数和new操作符,构造函数是所有对象的成员方法中,最早被调用的那个,下面一起来看一下吧,希望对大家有帮助。

JavaScript面向对象详细解析之属性描述符JavaScript面向对象详细解析之属性描述符May 27, 2022 pm 05:29 PM

本篇文章给大家带来了关于JavaScript的相关知识,其中主要介绍了关于面向对象的相关问题,包括了属性描述符、数据描述符、存取描述符等等内容,下面一起来看一下,希望对大家有帮助。

javascript怎么移除元素点击事件javascript怎么移除元素点击事件Apr 11, 2022 pm 04:51 PM

方法:1、利用“点击元素对象.unbind("click");”方法,该方法可以移除被选元素的事件处理程序;2、利用“点击元素对象.off("click");”方法,该方法可以移除通过on()方法添加的事件处理程序。

Python的Math库:使用方法及常用函数介绍Python的Math库:使用方法及常用函数介绍Apr 24, 2023 pm 11:10 PM

Math库概述math库是Python提供的内置数学类函数库,因为复数类型常用于科学计算,一般计算并不常用,因此math库不支持复数类型,仅支持整数和浮点数运算。math库一共提供了4个数学常数和44个函数。44个函数分为4类,包括16个数值表示函数、8个幂对数函数、16个三角对数函数和4个高等特殊函数。math库中函数数量较多,我们在学习过程中只需要逐个理解函数功能,记住个别常用函数即可。实际编程中,如果需要采用math库,可以随时查看math库快速参考。math库中的函数不能直接使用,需要首

整理总结JavaScript常见的BOM操作整理总结JavaScript常见的BOM操作Jun 01, 2022 am 11:43 AM

本篇文章给大家带来了关于JavaScript的相关知识,其中主要介绍了关于BOM操作的相关问题,包括了window对象的常见事件、JavaScript执行机制等等相关内容,下面一起来看一下,希望对大家有帮助。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.