Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara BigInt 3/3 | Data Types and Variables
Introduction to JavaScript

book
BigInt 3/3

Comparison with BigInt

We can use the comparison operators like greater than (<) or less than (>) with BigInt numbers just like we do with the numbers, for example.

console.log(2n > 1n);
console.log(5n < 2);
12
console.log(2n > 1n); console.log(5n < 2);
copy
Compito

Swipe to start coding

You are given two BigInt in the following code you have to compare both of them by > and show the result on the console whether revenueOfBankA is greater than revenueOfBankB.

Soluzione

let revenueOfBankA = 923569849n;
let revenueOfBankB = 7684569485n;
console.log(revenueOfBankA > revenueOfBankB);

Note:
Comparison operators will be covered in detail in the upcoming sections, but for now, just keep in mind that they are used to compare values or variables. We will work in detail with all kinds of the operator in the upcoming sections.

Summary

  • BigInt is a data type in JavaScript where we can have integers of arbitrary lengths.

  • We can use math operators with BigInt`just like numbers.

  • We can use the comparison operators < and > with the BigInt numbers just like with the numbers.

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 3. Capitolo 26
let revenueOfBankA = 923569849n;
let revenueOfBankB = 7684569485n;

Chieda ad AI

expand
ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

some-alt