This file contains hidden or 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 greet(firstName, lastName) { | |
| console.log(`Hello ${firstName} ${lastName}`); | |
| } | |
| // intended usage | |
| greet('Michael', 'Scott'); | |
| const fName = 'Harry'; | |
| const lName = 'Potter'; |
This file contains hidden or 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 canGoToAddressTab(context, event) { | |
| if (!context.dataBooks || context.dataBooks.length < 1) { | |
| return false; | |
| } | |
| return true; | |
| } | |
| function canGoToPaymentTab(context, event) { |
This file contains hidden or 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
| --- a/src/App.js | |
| +++ b/src/App.js | |
| -import React, { useState } from 'react'; | |
| +import React, { useState, useMemo } from 'react'; | |
| import cn from 'clsx'; | |
| function Table(props) { | |
| console.log('render: Table'); | |
| // other old code | |
| } |
This file contains hidden or 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 num1 = 3; | |
| const num2 = 7; | |
| const num3 = 3; | |
| console.log(num1 === num2); // false | |
| console.log(num1 === num3); // true | |
| const arr1 = [1]; | |
| const arr2 = [1]; |
This file contains hidden or 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
| --- a/src/App.js | |
| +++ b/src/App.js | |
| function Table(props) { | |
| console.log('render: Table'); | |
| // other old code | |
| } | |
| +const OptimizedTable = React.memo(Table); | |
| function App() { |
This file contains hidden or 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, { useState } from 'react'; | |
| import cn from 'clsx'; | |
| import { housesData, charactersData } from './staticData'; | |
| import './styles.css'; | |
| function Header(props) { | |
| const { children } = props; | |
| return ( | |
| <header className="app-header"> |
This file contains hidden or 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 car1 = { | |
| color: 'red', | |
| model: 'S', | |
| }; | |
| const car2 = { | |
| color: 'red', | |
| model: 'X', | |
| }; |
This file contains hidden or 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 funcObj() { | |
| return { | |
| ans: 42, | |
| }; | |
| } | |
| function funcArr() { | |
| return [42]; | |
| } |
This file contains hidden or 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 setNativeValue(element, value) { | |
| const valueSetter = Object.getOwnPropertyDescriptor(element, 'value').set; | |
| const prototype = Object.getPrototypeOf(element); | |
| const prototypeValueSetter = Object.getOwnPropertyDescriptor(prototype, 'value').set; | |
| if (valueSetter && valueSetter !== prototypeValueSetter) { | |
| prototypeValueSetter.call(element, value); | |
| } else { | |
| valueSetter.call(element, value); | |
| } |