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
{ | |
"files.autoSave": "onFocusChange", | |
"editor.fontLigatures": true, | |
"editor.fontFamily": "Fira Code SemiBold, Consolas, 'Courier New', monospace", | |
"editor.fontSize": 20, | |
"editor.wordWrap": "wordWrapColumn", | |
"editor.tabSize": 2, | |
"prettier.requireConfig": false, | |
"prettier.semi": false, | |
"editor.codeActionsOnSave": { "source.fixAll": true }, |
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
import React from "react" | |
import DisplayAllProps from "./DisplayAllProps" | |
import ChildComponent from "./ChildComponent" | |
const ParentComponent = (props) => ( | |
<section> | |
<h1>ParentComponent's props:</h1> | |
<DisplayAllProps {...props}></DisplayAllProps> | |
<ChildComponent {...props}></ChildComponent> |
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
// Every symbol created with Symbol() is unique. | |
console.log(Symbol() === Symbol()) // false | |
console.log(Symbol("✨") === Symbol("✨")) // false | |
// Calling Symbol.for() makes a global symbol. | |
console.log(Symbol.for("✨") === Symbol.for("✨")) // true | |
// You can check for a symbol using typeof. | |
console.log(typeof Symbol()) // "symbol" |
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
Array size: | 10 items | 1,000 items | 100,000 items | 1,000,000 items | |
---|---|---|---|---|---|
.includes() | Fastest | Fastest | 47.07% slower | 46.77% slower | |
.filter() | 97.16% slower | 99.99% slower | 97.69% slower | 97.66% slower | |
.some() | 84.81% slower | 99.98% slower | 95.11% slower | 95.01% slower | |
for loop | 84.2% slower | 99.62% slower | Fastest | Fastest | |
.find() | 85.74% slower | 99.98% slower | 95.19% slower | 95.06% slower |
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
const uniqueObjectsOneLiner = [ | |
...new Set(objectsArray.map((o) => JSON.stringify(o))), | |
].map((string) => JSON.parse(string)) | |
console.log(`${uniqueObjectsOneLiner.length} objects`) | |
// Output: 2 objects | |
console.log(...uniqueObjectsOneLiner) | |
// [ { id: 1, emoji: "🎸" }, { id: 2, emoji: "🎷" } ] |
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
// Export default const in JavaScript and TypeScript | |
const Banana = () => (<div>🍌</div>) | |
export default Banana // Has to be on a separate line |
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
// Default exports in JavaScript and TypeScript | |
function Banana() { | |
return <div>🍌</div> | |
} | |
const price = 1.33 | |
// In this example, price is a named export: | |
export { Banana as default, price } |
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
// Named exports in JavaScript and TypeScript | |
function Banana() { | |
return <div>🍌</div> | |
} | |
const price = 1.33 | |
export { Banana, price } | |
// These are equivalent to the export syntax above: |
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
type ReactNode = | |
| ReactElement | |
| string | |
| number | |
| ReactFragment | |
| ReactPortal | |
| boolean | |
| null | |
| undefined |
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
import { ReactNode } from "react" | |
type ILayout = { | |
pageInfo?: { name: string; description: string } | |
children: ReactNode | |
} | |
export default ILayout |
NewerOlder