feature / variable | constant | immutable |
---|---|---|
cannot be modified | ✔️ | ✔️ |
can be assigned at constructor | ❌ | ✔️ |
define at file level | ✔️ | ❌ |
gas price compared to regular variables | lowest | lower |
supported types | strings + value types | only value types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function calcProperties(p6) { | |
const p5 = Math.floor(p6 / 4.5); | |
const p4 = Math.floor(p5 / 4.5); | |
const p3 = Math.floor(p4 / 4.5); | |
const p2 = Math.floor(p3 / 4); | |
const p1 = Math.floor(p2 / 5); | |
console.log(p1.toLocaleString(), p2.toLocaleString(), p3.toLocaleString(), p4.toLocaleString(), p5.toLocaleString(), p6.toLocaleString()) | |
} | |
function calcFoods(f6) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"rootDir": "./src", | |
"outDir": "./public", | |
"target": "es5" | |
}, | |
// this setting forces TS not to compile any file out of 'src' folder | |
"include": ["src"] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.7; | |
contract ArrayReplaceLast { | |
uint[] public arr; | |
function remove(uint _index) public { | |
arr[_index] = arr[arr.length - 1]; | |
arr.pop(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract Array { | |
uint[] arr; | |
function remove(uint _index) private { | |
require(_index < arr.length, "index out of bound"); | |
for (uint i = _index; i < arr.length - 1; i++) { | |
arr[i] = arr[i + 1]; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h1 { | |
display: flex; | |
flex-direction: row; | |
} | |
h1:before, h1:after{ | |
content: ""; | |
flex: 1 1; | |
border-bottom: 1px solid; | |
margin: auto; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.wrapper::after { | |
content: ""; | |
clear: both; | |
display: block; | |
} | |
/* The modern way of solving this problem is to use the value flow-root of the display property. */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html { | |
font-family: sans-serif; | |
} | |
table { | |
border-collapse: collapse; | |
border: 2px solid rgb(200,200,200); | |
letter-spacing: 1px; | |
font-size: 0.8rem; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* variables declared here - these are the colors for our pages, as well as the font stacks and sizes. */ | |
:root { | |
--black: #171321; | |
--dkblue: #0d314b; | |
--plum: #4b0d49; | |
--hotmag: #ff17e4; | |
--magenta: #e310cb; | |
--aqua: #86fbfb; | |
--white: #f7f8fa; | |
--font-size: 1.3rem; |