250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- CSS
- tailwindcss
- 기준
- express.js
- solidity
- web
- evm
- API
- hardhat
- typeScript
- REACT
- CLASS
- Interface
- built in object
- Ethereum
- node.js
- concept
- 삶
- middleware
- error
- Props
- graphQL
- SSR
- nextJS
- Redux
- blockchain
- JavaScript
- useState
- bitcoin
- HTML
Archives
- Today
- Total
ReasonJun
Javascript : (2) (string, number) 본문
728x90
const string1 = 'Hello';
const string2 = 'Hello';
const string3 = `Hello ${string1}`;
console.log(string3); // Hello Hello
const number = -123;
console.log(number + 1); // -122
console.log(number + undefined); // NAN
console.log(typeof (number + 1)); // -122
console.log(typeof (number + undefined)); // number
const a = 0.1;
const b = 0.2;
console.log(a + b); // 0.30000000000000004
// Floating Point Error: An infinite decimal occurred while converting a decimal number to a binary number.
console.log((a + b).toFixed(1)); // 0.3 => string
console.log(typeof (a + b).toFixed(1)); // string
console.log(typeof Number((a + b).toFixed(1))); // number
// bigint
// bigint is an integer of unlimited length.
// Numeric data can be reliably displayed,
// Integers greater than the maximum value of {2^53 - 1} can be expressed.
// Add 'n' to the end of the integer or call 'BigInt()' to create it.
console.log(12345678901234567890123456789012345678901234567890); // 1.2345678901234567e+49
console.log(12345678901234567890123456789012345678901234567890n); // 12345678901234567890123456789012345678901234567890n
console.log(BigInt('12345678901234567890123456789012345678901234567890')); // 12345678901234567890123456789012345678901234567890n
const a = 11n;
const b = 22;
console.log(a + BigInt(b)); // 33n
console.log(typeof (a + BigInt(b))); // bigint
console.log(Number(a) + b); // 33
console.log(typeof (Number(a) + b)); // number
728x90
'Frontend > Javasciprt' 카테고리의 다른 글
javascript : variable (4) (array, shallow copy) (4) | 2023.06.07 |
---|---|
Javascript : Variable (3) (truthy, falsy, object) (0) | 2023.06.07 |
Javascript : Variable (1) (Memory, Data type, !!, null, undefined) (0) | 2023.06.06 |
Javascript : ECMA Script (0) | 2023.06.06 |
JavaScript : Engine (0) | 2023.06.06 |