Loading...
(function(){<br />
let canvas = document.createElement('canvas'),<br />
ctx = canvas.getContext('2d'),<br />
w = canvas.width = innerWidth,<br />
h = canvas.height = innerHeight,<br />
particles = [],<br />
properties = {<br />
bgColor : 'rgba(17, 17, 19, 1)',<br />
particleColor : 'rgba(255, 40, 40, 1)',<br />
particleRadius : 3,<br />
particleCount : 60,<br />
particleMaxVelocity : 0.5,<br />
lineLength : 150,<br />
particleLife : 6,<br />
};<br />
<br />
document.querySelector('body').appendChild(canvas);<br />
<br />
window.onresize = function() {<br />
w = canvas.width = innerWidth;<br />
h = canvas.height = innerHeight;<br />
}<br />
<br />
class Particle {<br />
constructor() {<br />
this.x = Math.random()*w;<br />Loading...
A number in a program is a numeric literal.
Integer literals
1) Decimal numbers- 3, 0, 1000
2) Hexadecimal literals — start with 0x or 0X, followed by hexadecimal digits.
3) In ES6 and later — binary and octal literals with prefixes 0b and 0o (0B and 0O)
Floating-point numbers: 2.18, .676, 8, 07e12, 1.7e-34.
Overflow happens when a result exceeds the largest representable number (positive or negative). It becomes Infinity or -Infinity.
Loss of precision occurs when a result is closer to zero than the smallest representable number. In this case, 0 is returned.If it happens with a negative number, -0 is returned.
Positive zero and negative zero are equal in strict comparison, but differ in division behavior.
Division by zero returns Infinity or -Infinity.Exception: 0 / 0 returns NaN (Not a Number).
Occurs in cases such as:
NaN is not equal to anything — even itself.
To check if a value is NaN, use:
Number.isFinite() returns true if the value is a number and not Infinity, -Infinity, or NaN.
isFinite(number) returns true if the value can be converted to a finite number or already is one.
A numeric type for integers.
It is written as a number with an n suffix and may use 0o, 0x, or 0b prefixes.
BigInt() converts a number into a BigInt value.
Arithmetic works similarly to normal numbers, but operations between Number and BigInt are not allowed.
Comparisons between normal numbers and BigInt values work correctly.