Hướng dẫn divide in javascript

  • Skip to main content
  • Skip to search
  • Skip to select language

  • References
    • Overview / Web Technology

      Web technology reference for developers

    • HTML

      Structure of content on the web

    • CSS

      Code used to describe document style

    • JavaScript

      General-purpose scripting language

    • HTTP

      Protocol for transmitting web resources

    • Web APIs

      Interfaces for building web applications

    • Web Extensions

      Developing extensions for web browsers

    • Web Technology

      Web technology reference for developers

  • Guides
    • Overview / MDN Learning Area

      Learn web development

    • MDN Learning Area

      Learn web development

    • HTML

      Learn to structure web content with HTML

    • CSS

      Learn to style content using CSS

    • JavaScript

      Learn to run scripts in the browser

    • Accessibility

      Learn to make the web accessible to all

  • MDN Plus
    • Overview

      A customized MDN experience

    • Documentation

      Learn how to use MDN Plus

    • FAQ

      Frequently asked questions about MDN Plus

  • Already a subscriber?
  • Get MDN Plus

  1. References
  2. JavaScript
  3. JavaScript
  4. Expressions and operators
  5. Division (/)

Related Topics

  1. JavaScript
  2. Tutorials:
  3. Complete beginners
    1. JavaScript basics
    2. JavaScript first steps
    3. JavaScript building blocks
    4. Introducing JavaScript objects
  4. JavaScript Guide
    1. Introduction
    2. Grammar and types
    3. Control flow and error handling
    4. Loops and iteration
    5. Functions
    6. Expressions and operators
    7. Numbers and dates
    8. Text formatting
    9. Regular expressions
    10. Indexed collections
    11. Keyed collections
    12. Working with objects
    13. Using classes
    14. Using promises
    15. Iterators and generators
    16. Meta programming
    17. JavaScript modules
  5. Intermediate
    1. Client-side JavaScript frameworks
    2. Client-side web APIs
    3. Language overview
    4. JavaScript data structures
    5. Equality comparisons and sameness
    6. Closures
  6. Advanced
    1. Inheritance and the prototype chain
    2. Strict mode
    3. JavaScript typed arrays
    4. Memory Management
    5. Concurrency model and Event Loop
  7. References:
  8. Built-in objects
    1. Overview
    2. AggregateError
    3. Array
    4. ArrayBuffer
    5. AsyncFunction
    6. AsyncGenerator
    7. AsyncGeneratorFunction
    8. Atomics
    9. BigInt
    10. BigInt64Array
    11. BigUint64Array
    12. Boolean
    13. DataView
    14. Date
    15. decodeURI()
    16. decodeURIComponent()
    17. encodeURI()
    18. encodeURIComponent()
    19. Error
    20. Deprecatedescape()
    21. eval()
    22. EvalError
    23. FinalizationRegistry
    24. Float32Array
    25. Float64Array
    26. Function
    27. Generator
    28. GeneratorFunction
    29. globalThis
    30. Infinity
    31. Int16Array
    32. Int32Array
    33. Int8Array
    34. Non-standardInternalError
    35. Intl
    36. isFinite()
    37. isNaN()
    38. JSON
    39. Map
    40. Math
    41. NaN
    42. Number
    43. Object
    44. parseFloat()
    45. parseInt()
    46. Promise
    47. Proxy
    48. RangeError
    49. ReferenceError
    50. Reflect
    51. RegExp
    52. Set
    53. SharedArrayBuffer
    54. String
    55. Symbol
    56. SyntaxError
    57. TypedArray
    58. TypeError
    59. Uint16Array
    60. Uint32Array
    61. Uint8Array
    62. Uint8ClampedArray
    63. undefined
    64. Deprecatedunescape()
    65. URIError
    66. WeakMap
    67. WeakRef
    68. WeakSet
  9. Expressions & operators
    1. Overview
    2. Addition (+)
    3. Addition assignment (+=)
    4. Assignment (=)
    5. async function expression
    6. async function* expression
    7. await
    8. Bitwise AND (&)
    9. Bitwise AND assignment (&=)
    10. Bitwise NOT (~)
    11. Bitwise OR (|)
    12. Bitwise OR assignment (|=)
    13. Bitwise XOR (^)
    14. Bitwise XOR assignment (^=)
    15. class expression
    16. Comma operator (,)
    17. Conditional (ternary) operator
    18. Decrement (--)
    19. delete operator
    20. Destructuring assignment
    21. Division (/)
    22. Division assignment (/=)
    23. Equality (==)
    24. Exponentiation (**)
    25. Exponentiation assignment (**=)
    26. Function expression
    27. function* expression
    28. Greater than (>)
    29. Greater than or equal (>=)
    30. Grouping operator ( )
    31. import
    32. import.meta
    33. in operator
    34. Increment (++)
    35. Inequality (!=)
    36. instanceof
    37. Left shift (<<)
    38. Left shift assignment (<<=)
    39. Less than (<)
    40. Less than or equal (<=)
    41. Logical AND (&&)
    42. Logical AND assignment (&&=)
    43. Logical NOT (!)
    44. Logical nullish assignment (??=)
    45. Logical OR (||)
    46. Logical OR assignment (||=)
    47. Multiplication (*)
    48. Multiplication assignment (*=)
    49. new operator
    50. new.target
    51. null
    52. Nullish coalescing operator (??)
    53. Object initializer
    54. Operator precedence
    55. Optional chaining (?.)
    56. Property accessors
    57. Remainder (%)
    58. Remainder assignment (%=)
    59. Right shift (>>)
    60. Right shift assignment (>>=)
    61. Spread syntax (...)
    62. Strict equality (===)
    63. Strict inequality (!==)
    64. Subtraction (-)
    65. Subtraction assignment (-=)
    66. super
    67. this
    68. typeof
    69. Unary negation (-)
    70. Unary plus (+)
    71. Unsigned right shift (>>>)
    72. Unsigned right shift assignment (>>>=)
    73. void operator
    74. yield
    75. yield*
  10. Statements & declarations
    1. Overview
    2. async function
    3. async function*
    4. block
    5. break
    6. class
    7. const
    8. continue
    9. debugger
    10. do...while
    11. empty
    12. export
    13. for
    14. for await...of
    15. for...in
    16. for...of
    17. function declaration
    18. function*
    19. if...else
    20. import
    21. label
    22. let
    23. return
    24. switch
    25. throw
    26. try...catch
    27. var
    28. while
    29. Deprecatedwith
  11. Functions
    1. Overview
    2. The arguments object
    3. Arrow function expressions
    4. Default parameters
    5. getter
    6. Method definitions
    7. Rest parameters
    8. setter
  12. Classes
    1. Overview
    2. Class static initialization blocks
    3. constructor
    4. extends
    5. Private class features
    6. Public class fields
    7. static
  13. Errors
    1. Overview
    2. Warning: -file- is being assigned a //# sourceMappingURL, but already has one
    3. TypeError: invalid Array.prototype.sort argument
    4. Warning: 08/09 is not a legal ECMA-262 octal constant
    5. RangeError: radix must be an integer
    6. SyntaxError: invalid regular expression flag "x"
    7. SyntaxError: return not in function
    8. RangeError: BigInt division by zero
    9. RangeError: BigInt negative exponent
    10. TypeError: X.prototype.y called on incompatible type
    11. ReferenceError: can't access lexical declaration 'X' before initialization
    12. TypeError: can't assign to property "x" on "y": not an object
    13. RangeError: x can't be converted to BigInt because it isn't an integer
    14. TypeError: can't convert BigInt to number
    15. TypeError: can't convert x to BigInt
    16. TypeError: can't define property "x": "obj" is not extensible
    17. TypeError: property "x" is non-configurable and can't be deleted
    18. TypeError: can't redefine non-configurable property "x"
    19. SyntaxError: cannot use `??` unparenthesized within `||` and `&&` expressions
    20. TypeError: cyclic object value
    21. TypeError: can't access dead object
    22. SyntaxError: applying the 'delete' operator to an unqualified name is deprecated
    23. ReferenceError: deprecated caller or arguments usage
    24. Warning: expression closures are deprecated
    25. SyntaxError: "0"-prefixed octal literals and octal escape seq. are deprecated
    26. SyntaxError: Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead
    27. Warning: String.x is deprecated; use String.prototype.x instead
    28. Warning: Date.prototype.toLocaleFormat is deprecated
    29. SyntaxError: test for equality (==) mistyped as assignment (=)?
    30. TypeError: setting getter-only property "x"
    31. SyntaxError: Unexpected '#' used outside of class body
    32. SyntaxError: identifier starts immediately after numeric literal
    33. SyntaxError: illegal character
    34. TypeError: cannot use 'in' operator to search for 'x' in 'y'
    35. RangeError: invalid array length
    36. SyntaxError: invalid assignment left-hand side
    37. SyntaxError: invalid BigInt syntax
    38. TypeError: invalid assignment to const "x"
    39. RangeError: invalid date
    40. SyntaxError: for-in loop head declarations may not have initializers
    41. SyntaxError: a declaration in the head of a for-of loop can't have an initializer
    42. TypeError: invalid 'instanceof' operand 'x'
    43. TypeError: 'x' is not iterable
    44. SyntaxError: JSON.parse: bad parsing
    45. SyntaxError: Malformed formal parameter
    46. URIError: malformed URI sequence
    47. SyntaxError: missing ] after element list
    48. SyntaxError: missing : after property id
    49. SyntaxError: missing } after function body
    50. SyntaxError: missing } after property list
    51. SyntaxError: missing formal parameter
    52. SyntaxError: missing = in const declaration
    53. SyntaxError: missing name after . operator
    54. SyntaxError: missing ) after argument list
    55. SyntaxError: missing ) after condition
    56. SyntaxError: missing ; before statement
    57. TypeError: More arguments needed
    58. RangeError: repeat count must be non-negative
    59. TypeError: "x" is not a non-null object
    60. TypeError: "x" has no properties
    61. SyntaxError: missing variable name
    62. TypeError: can't delete non-configurable array element
    63. RangeError: argument is not a valid code point
    64. TypeError: "x" is not a constructor
    65. TypeError: "x" is not a function
    66. ReferenceError: "x" is not defined
    67. RangeError: precision is out of range
    68. Error: Permission denied to access property "x"
    69. TypeError: "x" is read-only
    70. SyntaxError: redeclaration of formal parameter "x"
    71. TypeError: Reduce of empty array with no initial value
    72. SyntaxError: "x" is a reserved identifier
    73. RangeError: repeat count must be less than infinity
    74. Warning: unreachable code after return statement
    75. SyntaxError: "use strict" not allowed in function with non-simple parameters
    76. InternalError: too much recursion
    77. ReferenceError: assignment to undeclared variable "x"
    78. ReferenceError: reference to undefined property "x"
    79. SyntaxError: Unexpected token
    80. TypeError: "x" is (not) "y"
    81. SyntaxError: function statement requires a name
    82. SyntaxError: unparenthesized unary expression can't appear on the left-hand side of '**'
    83. SyntaxError: unterminated string literal
  14. Misc
    1. JavaScript technologies overview
    2. Lexical grammar
    3. JavaScript data structures
    4. Enumerability and ownership of properties
    5. Iteration protocols
    6. Strict mode
    7. Transitioning to strict mode
    8. Template literals
    9. Trailing commas
    10. Deprecated features

The division operator (/) produces the quotient of its operands where the left operand is the dividend and the right operand is the divisor.

Try it

Syntax

Examples

Basic division

1 / 2              // 0.5

Math.floor(3 / 2) // 1

1.0 / 2.0         // 0.5

Division by zero

2.0 / 0     // Infinity

2.0 / 0.0   // Infinity, because 0.0 === 0

2.0 / -0.0  // -Infinity

Specifications

Specification
ECMAScript Language Specification
# sec-multiplicative-operators

Browser compatibility

BCD tables only load in the browser

See also

  • Addition operator
  • Subtraction operator
  • Multiplication operator
  • Remainder operator
  • Exponentiation operator
  • Increment operator
  • Decrement operator
  • Unary negation operator
  • Unary plus operator