๐ŸŒŽ
web.dev
  • ๐ŸŒweb.dev
    • ๐Ÿšงtodo
    • ๐Ÿงชlab
    • ๐Ÿšธlegend
    • ๐Ÿ—’๏ธtemplate
    • ๐ŸŽนshortcuts
    • ๐Ÿ“—reference
      • ๐Ÿ“˜JS spec
      • ๐Ÿ“™javascript.info
      • ๐Ÿ“™Eloquent JavaScript
      • ๐Ÿ“™JavaScript: The Definitive Guide
      • ๐Ÿ“—book
        • ๐Ÿ“—You Don't Know JS: series (v.1)
        • ๐Ÿ“—You Don't Know JS: series (v.2)
          • ๐Ÿ“—YDKJS: Scope & Closures (v.2)
        • ๐Ÿ“—Functional-Light JavaScript
      • ๐Ÿ”ฐwebsite
        • ๐Ÿ”ฐfreeCodeCamp
    • โค๏ธfav
  • โš™๏ธtools
    • ๐Ÿ”ฐtooltip
    • ๐Ÿ”ฐsyntax highlighting
  • ๐Ÿ”ฐHTML
    • ๐Ÿ”ฐelement
      • ๐ŸŽ›๏ธ<select>
      • <form>
      • ๐Ÿท๏ธ<hr>
      • <figure>
      • <input>
        • type="range"
        • type="radio"
    • block vs. inline
    • Semantic Elements
  • ๐Ÿ”ฐCSS
    • โญbox model
      • height
      • border
      • outline
      • ๐Ÿ”ธmargin
        • layout with margin
        • default margin
        • ๐Ÿ”ธnegative margin
        • margin collapsing
      • ๐Ÿ’Šbox-sizing
    • ๐Ÿ”ฐlayout
      • ๐Ÿ”นposition
        • ๐Ÿ”ธpositioned ancestor
        • ๐Ÿ”ธnearest positioned ancestor
      • ๐Ÿ”นtop
      • ๐Ÿ”นdisplay
        • ๐Ÿ”ธblock
          • inset
        • ๐Ÿ”ธinline
        • ๐Ÿ”ธflex
          • ๐ŸšงFlexbox
            • flex-wrap
            • justify-content
            • align-content
            • flex
            • container properties
          • ๐Ÿ”ธflex-direction
          • ๐Ÿ”ธalign-items
        • ๐Ÿ”ธinline-block
        • ๐Ÿ”ธinline-flex
        • ๐Ÿ”ธnone
      • ๐Ÿ”ธformatting context
      • Layout System
        • Lorem
        • Spacer
        • VStack
        • HStack
        • Box
        • VCenter/HCenter
        • Dark Theme
      • โœจexamples
        • Email Form
      • ๐Ÿ”ฐCSS grid
      • vertical-align
      • float
      • vertical centering
        • center with "transform"
        • center with "flex"
      • Block Formatting Context
    • ๐Ÿ”ฐvalues
      • ๐Ÿ”ฐunits
        • ๐Ÿ”ฐ็›ธๅฐๅ–ฎไฝ
          • ๐Ÿ”ธpercentage (๏ผ…)
          • ๐Ÿ”ธrem
          • ๐Ÿ”ธem
      • ๐Ÿ”ฐcolors
        • HSL
      • ๐Ÿ”ฐgradients
        • radial-gradient()
    • ๐Ÿ”ฐvariables
    • ๐Ÿ”ฐfunctions
      • ๐Ÿ”นcalc()
    • ๐Ÿ”ฐselectors
      • select direct children by JS
      • basic selectors
      • attribute selectors
      • ๐Ÿ”ฐcombinators
      • pseudo-class
      • ๐Ÿ”ธpseudo-element
      • custom selectors
    • ๐Ÿ”ฐproperties
      • get/set CSS props
      • Logical Properties
      • overflow
    • ๐Ÿ’กTips
    • CSS import
    • Responsive Design
    • CSS Rules
      • CSS reset
    • Design
      • ๐Ÿ”ฐCSS shadows
    • โœจexamples
      • styling <details>
      • undefined tag
      • modal dialog
      • nav bar
      • glowing buttons
    • Cascade
      • Order
      • Specificity
      • Inheritance
    • Stacking Context
    • Font
      • Font Awesome
      • font-family
    • Text
    • List
  • ๐Ÿ’JS
    • ๐Ÿ’กtips
      • fill 2D array
    • ๐Ÿงštechnique
    • โญfeature
      • โญ๏ธ ES5
      • โญ๏ธ ES6 (2015)
      • โญ๏ธ ES2017
      • โญ๏ธ ES2016
      • โญ๏ธ ES2018
      • โญ๏ธ ES2020
    • ๐Ÿ”ฐconcept
      • ๐Ÿ”ฐexecution context
        • ๐Ÿ“˜this
          • โ—"this" determined on call siteโ—๏ธ
        • ๐Ÿ”ฐrunning execution context
        • ๐Ÿ”ฐlexical environment
          • ๐Ÿ”ฐenvironment record
          • ๐Ÿ”ธ[[Environment]]
          • โ—lexical environment optimizaton
        • ๐Ÿ”ฐcall stack
      • ๐Ÿ”ฐcontext
        • ๐Ÿ”ฐglobal context
        • ๐Ÿ”ฐclass body context
      • ๐Ÿ”ฐenvironment
        • โš™๏ธJS engine
          • ๐Ÿ”ฐmode
            • ๐Ÿ›ก๏ธstrict mode
              • ๐Ÿ›ก๏ธeval has its own scope in strict mode
              • โœ…always use strict mode
            • โ—sloppy mode
              • โ—accidental global variable in sloppy modeโ—๏ธ
              • โ—modify current scope at runtimeโ—๏ธ
            • โš–๏ธstrict vs. sloppy
          • ๐Ÿ”ฐv8
        • ๐Ÿ”ฐNode.js
      • ๐Ÿ”ฐassociated array
      • ๐Ÿ”ฐparser
    • ๐Ÿ”ฐcompilation
      • ๐Ÿ”ฐlexing
      • ๐Ÿ”ฐparsing
      • ๐Ÿ”ฐcode generation
      • ๐Ÿ”ฐJS is compiled
      • ๐Ÿ”ฐcompile-time
      • ๐Ÿ”ฐruntime
    • ๐Ÿ”ฐgrammar
      • ๐Ÿšฉdirective
        • ๐Ÿ“œ'use strict'
      • *๏ธtoken
        • ๐Ÿ—๏ธkeyword
          • ๐Ÿ”reserved word
            • โ—reserved word as property name is allowedโ—๏ธ
          • ๐Ÿ”‘contextual keyword
        • ๐Ÿ”ฃpunctuator
          • *๏ธhash (#)
          • ๐Ÿ”ฃsemicolon (;)
            • ๐Ÿ”ฐautomatic semicolon insertion
            • ๐Ÿ”ฐstatements that must end with ";"
          • ๐Ÿ”ฃdot (.)
          • ๐Ÿ”ฃcomma (,)
          • ๐Ÿ”ฃcolon (:)
          • ๐Ÿ”ฃplus (+)
          • ๐Ÿ”ฃequal (=)
          • ๐Ÿ”ฃ3 dots (...)
          • ๐Ÿ”ฃbrackets []
          • ๐Ÿ”ฃbraces {}
          • ๐Ÿ”ฃparentheses ()
          • ๐Ÿ”ฃquestion dot (?.)
          • ๐Ÿ”ฃquestion (?)
        • ๐Ÿ†”identifier
          • ๐Ÿ†”special identifier
          • โš–๏ธidentifier vs. string
          • โš–๏ธidentifier vs. keyword
          • โ—undeclared identifier
          • ๐Ÿ”ฐstatic binding
          • ๐Ÿ”ฐdynamic binding
        • โœก๏ธliteral
          • ๐Ÿ”ฐtrailing comma
      • ๐Ÿ”ฐcomment
      • ๐Ÿˆฏdeclaration
        • โ—redeclaration
        • ๐Ÿˆฏlexical declaration
      • ๐Ÿ“œstatement
        • ๐Ÿ“ฆexpression
          • ๐Ÿ“ฆprimary expression
          • ๐Ÿ“ฆinvocation expression๏ผšf()
            • ๐Ÿ“ฆmethod invocation
          • ๐Ÿ“ฆleft-hand side expression
        • ๐Ÿ”loop
          • ๐Ÿ”while
          • ๐Ÿ”do...while
          • ๐Ÿ”for loops
            • ๐Ÿ”for
              • ๐Ÿ”ฐ"for-init" scope
              • ๐Ÿ”ฐ"for-init" block
            • ๐Ÿ”for-in
            • ๐Ÿ”for-of
              • โ—arrays are iterated "live"โ—๏ธ
              • ๐Ÿ”ฐfor-of with objects
              • ๐Ÿ”ฐfor-of with strings
              • โš–๏ธfor-of vs. forEach
            • ๐Ÿ”for-await
            • โš–๏ธfor-in vs. for-of vs. in
            • ๐Ÿ“˜arr.forEach()
        • ๐Ÿ”€control flow
          • โคด๏ธjump
            • โคด๏ธreturn
            • โคด๏ธcontinue
            • โคด๏ธbreak
            • โš–๏ธcontinue vs. break
          • ๐Ÿ”€branch
            • ๐Ÿ”€if
            • ๐Ÿ”€switch
              • ๐Ÿ”€case clause
        • ๐Ÿ“œother statement
          • ๐Ÿ“œblock
            • ๐Ÿ”ฐblock scope
          • ๐Ÿ“œlabel
          • ๐Ÿ›‘with
          • ๐Ÿ“œempty statement
        • โ›”statement expectedโ—๏ธ
      • ๐Ÿšงoperator
        • ๐Ÿšงtable of operators
        • ๐Ÿ“–terms for operator
          • ๐Ÿ”ฐarity
          • ๐Ÿ”ฐassociativity
          • ๐Ÿ”ฐlvalue
          • ๐Ÿ”ฐdividend
          • ๐Ÿ”ฐdivisor
          • ๐Ÿ”ฐnon-numeric operand
          • ๐Ÿ”ฐshort-circuiting
        • ๐Ÿ”ดassignment
          • โญdestructuring assignment
            • ๐Ÿ”ฐdestructuring array
            • ๐Ÿ”ฐdestructuring iterable
            • ๐Ÿ”ฐobject destructuring
            • ๐Ÿ”ฐnested destructuring
              • ๐ŸŒŸnested default values
            • ๐Ÿ”ฐdestructuring arguments
          • โž•assignment (=)
        • ๐Ÿ”ดarithmetic operator
          • โญ•unary arithmetic operator
            • ๐Ÿšงunary plus (+)
          • โญ•binary arithmetic operator
            • โž•add/concate (+)
            • โž•division (/)
            • โž•remainder (%)
              • ๐Ÿ’พmodulo(a, b)
              • ๐Ÿ’พmod(a, b)
              • โš–๏ธremainder vs. modulo vs. mod
            • โž•exponentiation (**)
          • โญ•bitwise operator
            • ๐ŸŒŸ2's complement
            • ๐Ÿ’พbitview()
            • โž•bitwise not (~)
              • ๐Ÿ”ฐdouble tilde (~~)
              • โš–๏ธ(~~) vs. Math.trunc()
        • ๐Ÿ”ดrelational operator
          • ๐Ÿ”ฐequality & inequality operator
            • โž•sloppy equality (==)
            • โž•strict equality (===)
          • ๐Ÿ”ฐcomparison operator
          • โž•in
          • โž•instanceof
        • ๐Ÿšงlogical operator
          • โž•nullish coalescing (??)
          • โญ•unary logical operator
          • โญ•binary logical operator
        • โญ•unary operator
          • โž•void
        • โญ•binary operator
          • โž•comma operator (,)
        • โญ•ternary operator
          • โž•conditional operator (?:)
        • ๐Ÿ”ฐspread operator (...)
        • โž•rest operator (...)
      • ๐Ÿ”ฐstatement vs. declaration
    • ๐Ÿ”ฐscope
      • ๐Ÿ”ฐlexical scope
      • ๐Ÿ”ฐstatic scope
      • ๐Ÿ”ฐdynamic scope
      • โš–๏ธstatic vs. dynamic scoping
      • ๐Ÿ”ฐscope chain
      • โš–๏ธlexical environment vs. scope
      • ๐Ÿ”ฐtop-level scope
      • ๐ŸŒŸglobal scope
        • ๐Ÿ“˜global object
          • ๐Ÿท๏ธglobalThis
          • ๐Ÿ„window
            • ๐Ÿ”ธwindow.name
            • ๐Ÿ”ธwindow.navigator
          • ๐Ÿ„global
          • ๐Ÿ”ธeval
          • ๐Ÿ”ธglobal object property
        • ๐Ÿ’พisCurrentlyInGlobalScope()
        • ๐Ÿ”ฐglobal variable
          • ๐Ÿ”ฐglobal let
            • โ—global let shadows global object property
          • ๐Ÿ”ฐglobal var
        • ๐Ÿ”ธDOM element with "id"
      • ๐Ÿ”ฐmodule scope
      • ๐Ÿ”ฐfunction scope
      • ๐Ÿ”ฐfunction name scope
      • ๐Ÿ”ฐparameter scope
      • ๐Ÿ”ฐhoisting
        • ๐Ÿ”ฐfunction hoisting
          • โ—function hoisting firstโ—๏ธ
        • ๐Ÿ”ฐvariable hoisting
          • ๐Ÿ”ฐvar hoisting
            • โ—function expression not hoisted
          • ๐Ÿ”ฐlet/const/class hoisting
      • โš–๏ธcontext vs. scope
    • ๐Ÿ’value
      • ๐Ÿ”ฐtype
        • ๐Ÿ’falsy
        • ๐Ÿ“–terms for type
          • ๐Ÿ”ฐstatically typed
          • ๐Ÿ”ฐdynamically typed
        • ๐Ÿ”ฐtype conversion
        • ๐Ÿ”ฐtype name
          • โž•typeof
          • ๐Ÿ’พbaseTypeName()
          • ๐Ÿ’พtypeName()
          • ๐Ÿ’พcustom type name
        • ๐Ÿ”ฐnested type
        • ๐Ÿ‘”type functions
          • ๐Ÿ’พfunctionDefinition()
          • ๐Ÿ’พisObject()
          • ๐Ÿ’พisPrimitive()
          • ๐Ÿ’พisFunction()
          • ๐Ÿ’พisClass()
      • ๐Ÿฆ primitive
        • ๐Ÿ’nullish
        • ๐Ÿ”ธundefined
        • ๐Ÿ”null
        • ๐Ÿ”ขNumber
          • ๐Ÿ”ฐfloating-point
          • ๐Ÿ”ฐintegers
          • ๐Ÿ”ดspecial number
            • ๐Ÿ”ขInfinity
            • ๐Ÿ”ขNaN
            • ๐Ÿ”ขNumber.EPSILON
            • ๐Ÿ”ขNumber.MAX_VALUE
            • ๐Ÿ”ขNumber.MAX_SAFE_INTEGER
          • ๐Ÿ‘”Number+ext
            • ๐Ÿ’พn.toHex()
            • ๐Ÿ’พn.isEqual()
            • ๐Ÿ’พisNumber()
          • ๐Ÿ‘”Random
            • randomInt()
            • randomFloat()
          • ๐Ÿ‘”Quaternion
        • ๐Ÿ”ขBigInt
        • ๐Ÿฆ Boolean
        • ๐Ÿ”คString
          • ๐Ÿ”ฐraw string
          • ๐Ÿ”ฐescape sequence
          • template literal
            • tagged template
            • tag function
          • ๐Ÿ”ฐString methods
            • str.map()
            • ๐Ÿ’พstr.capitalize()
            • str.countLetters()
            • ๐Ÿ’พstr.htmlToElement()
            • str.kebabToCamelCase()
            • ๐Ÿ“˜str.match()
              • โœจsplit into course names
            • ๐Ÿ“˜str.matchAll()
              • โœจmatchAll() using named groups
              • โœจwords in sentence
            • str.random()
            • str.removeWhitespaces()
            • ๐Ÿ“˜str.replace()
              • ๐Ÿ”ฐreplacer function
              • โœจminus one
            • ๐Ÿ’พstr.replaceWhitespaces()
            • str.reverse()
            • str.shuffle()
            • ๐Ÿ’พstr.slice2()
            • ๐Ÿ’พstr.splice()
            • str.escapeHTML()
            • str.toDatasetPropName()
            • ๐Ÿ’พstr.words()
            • str.wordCounts()
            • String.fromCharCodes()
          • ๐Ÿ‘”String extension
            • ๐Ÿ’พstr.isKeyword
            • ๐Ÿ’พstr.isReservedWord
            • ๐Ÿ’พstr.isPunctuator
          • ๐Ÿ”ฐUnicode
            • ๐Ÿ”ฐcode point
            • ๐Ÿ”ฐgrapheme cluster
            • ๐Ÿ”ฐcode plane
            • ๐Ÿ”ฐcharacter encoding
              • ๐Ÿ”ฐUTF-16
                • ๐Ÿ”ฐcode unit
                • ๐Ÿ”ฐsurrogate pair
                • ๐Ÿ”ฐscalar
        • ๐Ÿ”บSymbol
          • ๐Ÿ”บSymbol.iterator
        • ๐Ÿ”ฐprimitive wrapper
      • ๐Ÿ„object
        • ๐Ÿ”ธproperty
          • ๐Ÿšฉattribute
            • ๐Ÿ„property descriptor
            • ๐Ÿ’พownPropertyFlags(obj)
          • ๐Ÿ”ธgetter/setter
          • ๐Ÿ”ธproperty name
            • โญcomputed property name
          • โญshorthand property
          • ๐Ÿ”ธinternal property
          • ๐Ÿ”ฐproperty access
            • ๐Ÿ“ฆproperty access expression
            • โž•dot notation (.)
              • โš–๏ธdot notation vs. decimal point
            • โž•bracket notation []
            • โž•optional chaining (?., ?.[])
              • โ“is Optional Chaining Supported?
              • ๐Ÿ’พobj.prop(path)
            • โž•optional invocation ?.()
              • is Optional Chaining Supported?
              • obj.prop(path)
            • ๐ŸŒŸchaining rules
              • โœจjane.boyfriend?.money.more
          • ๐Ÿ”ฐproperty creation/deletion
            • ๐Ÿ“˜Object.defineProperty()
            • โž•delete
              • โ—unqualified identifier for delete
          • ๐Ÿ”ฐproperty testing
          • ๐Ÿ”ฐproperty enumeration
        • ๐Ÿ”ฐcreating objects
          • โœก๏ธobject literal
            • โ—object literal is not a blockโ—๏ธ
          • โž•new
            • ๐Ÿ”ธnew.target
            • โš–๏ธcallable vs. constructable
          • โ“‚๏ธObject.create()
            • โœจ"pure" object
            • โœจguard against accidental modifications
        • ๐Ÿ”ฐextending objects
          • ๐Ÿ“˜Object.assign()
            • โ›”๏ธ Object.assign causing TypeError
            • โ—๏ธObject.assign copies with getter/setter
          • inheritance
            • ๐Ÿ”ธ__proto__
            • class A vs. class A extends Object
          • mixin
            • ๐Ÿ’พmergeWithoutOverride()
            • ๐Ÿ’พ.assignDescriptors()
            • mixin inheritance
            • โœจmixin: HandleEvents
          • ๐Ÿ’พ add default properties
          • extending built-in classes
        • ๐Ÿ”ฐconverting objects
          • ๐Ÿ”ฐserializing objects
          • ๐ŸŒŸobject -> primitive conversion
            • ๐Ÿ”˜prefer-string
            • ๐Ÿ”˜prefer-number
            • ๐Ÿ”˜no preference
          • โ“‚๏ธ.toString()
          • โ“‚๏ธ.valueOf()
          • ๐Ÿ’พvalueToString()
        • โ“‚๏ธmethod
          • ๐Ÿ’ [[HomeObject]]
          • ๐Ÿ”ฐpolymorphism
        • ๐Ÿ”ธprototype
          • ๐Ÿ”ฐprototype chain
            • ๐ŸšงprintPrototypeChain()
      • ๐Ÿ„function
        • ๐Ÿ”ฐcreating functions
        • ๐Ÿˆฏfunction declaration
          • โ—function in block (FiB)
          • โ—function redeclaration
          • ๐Ÿ“˜function declaration instantiation
        • ๐Ÿ”ฐfunction expression
          • โ—read-only identifier
          • ๐Ÿ”ฐnamed function expression
          • ๐Ÿ”ฐas variable
          • ๐Ÿ”ฐIIFE
        • ๐Ÿ”ฐarrow function
          • โ—arrow function as methodโ—๏ธ
          • ๐Ÿ”ฐarrow function as argument
          • โ—arrow function as class fieldโ—๏ธ
          • โ—arrow function returning object literal needs (...)โ—๏ธ
          • ๐Ÿ”ฐarrow function expression
        • ๐Ÿ”ฐclosure
          • โ—scopes matter with closures
          • ๐Ÿ’กprivate property by closure
          • โœจclosure examples
            • โœจclosure: to close over or not
            • โœจclosure: manage grades
            • โœจclosure as object
        • ๐ŸŒฟsorts of function
          • ๐Ÿ”ฐcallback
          • ๐Ÿ”ฐhigher-order function
            • ๐Ÿ’พnot(f)
            • ๐Ÿ’พpipe(f, g, ...)
            • ๐Ÿ’พpartial(f, a, b ...)
            • ๐Ÿงšdecorator
              • ๐Ÿ’พsaveCallHistory(f)
              • ๐Ÿ’พdelay(f, s)
              • ๐Ÿ’พbenchmark(f)
              • ๐Ÿ’พdebounce(f, s)
              • ๐Ÿ’พthrottle(f, s)
              • โš–๏ธdebounce vs. throttle
              • ๐Ÿงšmemoization
                • ๐Ÿงšmemoize by decorator
                  • ๐Ÿ’พmemoize(f)
                • ๐Ÿงšmemoize by closure
          • ๐Ÿ”ฐpredicate
          • ๐Ÿ”ฐnested function
          • ๐Ÿ”ฐrecursive function
            • โœจfindSolution()
            • ๐Ÿ’พdeepEqual()
        • ๐Ÿ”ฐfunction boundary
        • ๐Ÿ”ฐfunction overloading
        • ๐Ÿ”ฐfunction forwarding
        • ๐Ÿ”ธreturn value
        • ๐Ÿ”ธfunction name
          • ๐Ÿ”ฐanonymous function
        • โš–๏ธparameter vs. argument
        • ๐Ÿ”ธargument
          • โ—arguments are passed by valueโ—๏ธ
        • ๐Ÿ”ธparameter
          • ๐Ÿ”ธdefault parameter
          • ๐Ÿ”ธrest parameters
            • ๐Ÿ”ธrest parameters as object
          • ๐Ÿ”ธdestructured parameter
          • โš–๏ธsimple vs. non-simple parameter
          • โ—deplicate parameters
        • ๐Ÿ”ธprototype
        • ๐Ÿ”นconstructor
      • ๐Ÿ„class
        • ๐Ÿ”ฐinitialization
          • ๐Ÿ”นstatic block
        • ๐Ÿ”ธmember
          • ๐Ÿ”ธclass field
          • ๐Ÿ”ธprivate member
          • ๐Ÿ”ธstatic member
            • ๐Ÿ”ฐinit static property
          • private/protected members
          • ๐Ÿ”ธgetter/setter
          • ๐Ÿ”ธmethod
          • ๐Ÿ”ธbound method
        • ๐Ÿ”ฐcreating class
          • ๐Ÿ”ฐdelegation
        • ๐Ÿ”ฐinheritance
          • ๐Ÿ“˜super
          • derived class init
          • override constructor
          • override methods
          • override class fields
        • โœจexamples
          • โœจComplex
          • โœจTypedMap
          • โœจBag
      • ๐Ÿ“˜built-in objects
        • ๐Ÿ“˜Object
          • ๐Ÿ”ธObject.prototype
          • ๐Ÿ’พObject extension
            • ๐Ÿ’พobj.mergeWith()
        • ๐Ÿ“˜Function
        • ๐Ÿ“˜Array
          • ๐Ÿ”ธelement
            • ๐Ÿ”ธelement index
              • โ—element index is stringโ—๏ธ
          • ๐Ÿ”ธarray length
          • ๐Ÿ”ธarray object property
          • ๐Ÿ„sparse array
            • ๐Ÿ”ฐhow array methods deal with "holes" ?
          • ๐Ÿ”ฐarray-like
            • ๐Ÿ‘”Object+arrayLike
          • ๐Ÿ”ฐcreating arrays
            • โœก๏ธarray literal
              • ๐Ÿ”ฐundefined element
          • ๐Ÿ”ฐaccessing elements
          • ๐Ÿ”ฐiterating elements
          • ๐Ÿ“˜array methods
            • ๐Ÿ“˜arr.entries
            • ๐Ÿ“˜arr.filter()
            • ๐Ÿ“˜arr.flatMap()
            • ๐Ÿ“˜arr.reduce()
              • early break reduce()
            • ๐Ÿ“˜arr.slice()
            • ๐Ÿ“˜arr.splice()
          • ๐Ÿ‘”Array extension
            • ๐Ÿ’พarr.containsSubarray()
            • ๐Ÿ’พarr.copy()
            • ๐Ÿ’พarr.isEmpty
            • ๐Ÿ’พarr.last
            • ๐Ÿ’พarr.none()
            • ๐Ÿ’พarr.reversed()
            • ๐Ÿ’พarr.shuffle()
            • ๐Ÿ’พarr.randomElement
            • ๐Ÿ’พarr.removeDuplicates()
            • ๐Ÿ’พarr.uniqueMerge()
            • ๐Ÿ’พarr.removeUndefined()
            • ๐Ÿ’พarr.removeValue()
            • ๐Ÿ’พarr.sum(), .average()
            • ๐Ÿ’พarr.topN()
            • ๐Ÿ’พarr.rank()
            • ๐Ÿ’พarr.padEndSpaces()
            • ๐Ÿ’พarr.max()
            • ๐Ÿ’พarr.isMatrix
            • ๐Ÿ’พarr.indexDictionaryForValues()
            • Array extensions (archive)
          • โœจarray examples
            • ๐Ÿ’พobjects to HTML table
          • array & matrix methods
          • static methods
            • ๐Ÿ“Array(n) vs. Array(n).fill()
            • Array.from()
            • ๐ŸšงArray.list(n)
          • matrix methods
            • mat.matrixMap()
            • mat.transpose()
            • mat.maxElementInEachColumn()
          • Matrix methods
            • ๐ŸŒ€ Array.matrixFill()
        • ๐Ÿ“˜Set
          • ๐Ÿ‘”Set extension
            • ๐Ÿ’พset.isEqualTo()
        • ๐Ÿ“˜Map
          • Don't use object properties
        • ๐Ÿ“˜RegExp
          • ๐Ÿšฉregex flag
            • ๐Ÿšฉflag /u
            • ๐Ÿšฉflag /d
          • ๐Ÿ”ธlastIndex
          • ๐Ÿ”ฐcreating regex
          • ๐Ÿ”ฐusing regex
          • ๐Ÿ”ฐpattern
            • ๐Ÿ”ฐspecial characters
            • ๐Ÿ”ฐanchor
            • ๐Ÿ”ฐrepeat
              • ๐Ÿ”ฐgreedy vs. lazy
            • ๐Ÿ”ฐcharacter set
            • ๐Ÿ”ฐalternation (or)
            • ๐Ÿ”ฐgroup
              • ๐Ÿ”ฐcapturing group
                • ๐Ÿ”ฐnamed group
            • ๐Ÿ”ฐlookaround
            • ๐Ÿ”ฐinline modifier
            • ๐Ÿ”ฐreplace pattern
            • ๐Ÿ˜€emoji
          • โœจregex examples
            • โœจparse .ini file
            • โœจquick brown fox
            • โœจJS-style numbers
        • ๐Ÿ“˜Proxy
          • ๐Ÿ”นhandler method
          • ๐Ÿ“˜Reflect
          • โœจProxy examples
            • โœจidentity (proxy)
            • โœจread-only proxy
            • โœจobserve()
        • ๐Ÿ“˜Date
    • ๐Ÿ”ฐvariable
      • ๐Ÿˆฏvariable declaration
        • ๐Ÿ“œvar
          • โœ…stop using varโ—๏ธ
          • โ—var is a statementโ—๏ธ
          • โ—var has no block scopeโ—๏ธ
          • โ—accessing var before declaration gets undefinedโ—๏ธ
          • โ—global var / function is global object propertyโ—๏ธ
          • โ—var redeclaration applied even in strict modeโ—๏ธ
          • โ—var in block can't shadow outer letโ—๏ธ
          • โ—var can shadow parameter even in strict modeโ—๏ธ
        • ๐Ÿˆฏconst
          • โ›”const requires initialization
          • โ›”const can't reassign
          • โ›”no const for classic "for"
        • ๐Ÿˆฏlet
          • โœ…let redeclaration not allowed even in sloppy modeโ—๏ธ
          • โœ…let can't shadow parameter even in sloppy modeโ—๏ธ
        • ๐Ÿ”ฐinitial value
      • โ—variable redeclaration
        • โ—var redeclaration
        • โ—let redeclaration
      • ๐Ÿ”ดaccessing variables
        • โ›”temporal dead zone
          • โ›”TDZ
          • โ›”typeof let/const/class in TDZ gets an errorโ—๏ธ
        • โ›”uninitialized variable
        • ๐Ÿ”ฐLHS reference
        • ๐Ÿ”ฐRHS reference
        • โš–๏ธLHS vs. RHS reference
      • โ—variable shadowing
      • โ—can't delete variable/functionโ—๏ธ
    • ๐Ÿ”ฐmodule
      • โญES module
        • ๐Ÿˆฏimport
          • โœจimport ES module
          • dynamic import()
        • ๐Ÿˆฏexport
          • ๐Ÿ“˜default export
          • ๐Ÿ“˜named export
      • ๐Ÿ”ฐCommonJS
        • ๐Ÿ“œpackage.json
      • โš–๏ธES vs CommonJS
      • ๐Ÿ”ฐimport.meta
      • ๐Ÿ”ฐpackage
      • ๐Ÿ”ฐbundler
      • ๐Ÿ”ฐminifier
      • ๐Ÿ”ฐbrowser-specific features
      • ๐Ÿ”ฐmodule pattern
    • ๐Ÿ”ฐiteration
      • ๐Ÿ‘”Iterable+ext
        • ๐Ÿ’พrange()
        • ๐Ÿ’พobj.isIterable
      • ๐Ÿ”ฐiterable
        • ๐Ÿ”ธmake-iterator method
        • โ—only-iterate-once iterable
        • ๐Ÿ”ฐmake iterables
        • โœจiterable examples
          • โœจClosedRange
          • โœจSequence
      • ๐Ÿ”ฐiterator
        • ๐Ÿ”ธnext()
        • ๐Ÿ”ธreturn()
        • โ—iterators only iterate onceโ—๏ธ
        • ๐Ÿ”ฐiterable iterator
        • ๐Ÿ”ฐinfinite iterator
        • ๐Ÿ”ฐmake iterator iterable
        • ๐Ÿ’พIteratorPrototype
        • ๐Ÿ’พIterator
      • ๐Ÿ”ฐiteration result
      • ๐Ÿ“˜Generator
        • ๐Ÿ”ฐgenerator function
          • ๐Ÿ“˜function*
          • ๐Ÿ“ฆyield
          • ๐Ÿ“˜yield*
          • ๐Ÿ”ฐcomposition
          • ๐Ÿ”ฐgenerator function as ...
        • โœจgenerator examples
          • ๐Ÿ’พ*list()
          • ๐Ÿ’พ*integers()
          • ๐Ÿ’พ*closedRange()
          • ๐Ÿ’พ*fibonacci()
          • ๐Ÿ’พ*zip()
          • ๐Ÿ’พ*sequence()
          • ๐Ÿ’พ*interleave()
    • ๐Ÿ”ฐasync code
      • ๐Ÿ”ฐthread
      • ๐Ÿ”ฐevent loop
      • ๐Ÿ„Promise
        • ๐Ÿ‘”custom promises
          • ๐Ÿ’พgetJSON()
          • ๐Ÿ’พPromise.wait()
          • ๐Ÿ’พfutureValue()
        • ๐Ÿ”ฐusing Promises
        • ๐Ÿ”ฐerror handling
          • โญfinally()
          • ๐Ÿ”ฐrecoverable errors
        • ๐Ÿ”ฐchaining Promises
          • ๐Ÿ’พPromise.inSeries()
        • ๐Ÿ”ฐPromises in parallel
      • ๐Ÿ†”async
        • ๐Ÿ”ฐasync function
        • ๐Ÿ”ฐasync method
        • ๐Ÿ”ฐasync arrow function
        • ๐Ÿ”ฐasync IIFE
        • ๐Ÿ’พmeasureTime()
      • โž•await
        • ๐Ÿ”ฐawait promises
          • ๐Ÿ”ฐawait sequentially
          • ๐Ÿ”ฐawait in parallel
        • ๐Ÿ”ฐawait "thenable"
        • ๐Ÿ”ฐerror handling
    • ๐Ÿ”ฐdebugging
      • ๐Ÿ”ฐtesting
      • ๐Ÿ’Šerror handling
        • โคด๏ธthrow
        • ๐Ÿ”ฐrethrow
        • โคด๏ธtry-catch-finally
      • ๐Ÿ› ๏ธdevtools
        • ๐Ÿ“œdebugger
        • ๐Ÿ”ฐshow built-in shadow DOM
    • โ›”Error
      • ๐Ÿ”ดcompile-time error
        • โ›”๏ธ early errors
      • ๐Ÿ”ดruntime error
      • โ›”๏ธ SyntaxError
        • โ›”duplicate parameter not allowed in strict modeโ—๏ธ
        • โ›”unexpected token "xxx"โ—๏ธ
        • โ›”Named export 'xxx' not foundโ—๏ธ
        • โ›”unexpected numberโ—๏ธ
        • โ›”... parenthesis must be used to disambiguate operator precedenceโ—๏ธ
        • โ›”identifier 'xxx' has already been declaredโ—๏ธ
        • โ›”missing initializer in const declarationโ—๏ธ
        • โ›”lexical declaration cannot appear in a single-statement contextโ—๏ธ
        • โ›”delete of an unqualified identifier in strict modeโ—๏ธ
        • โ›”octal literals not allowed in strict modeโ—๏ธ
      • โ›”๏ธ ReferenceError
        • โ›”cannot access 'xxx' before initializationโ—๏ธ
        • โ›”'xxx' is not definedโ—๏ธ
      • โ›”๏ธ TypeError
        • โ›”'xxx' is not a functionโ—๏ธ
        • โ›”assignment to constant variableโ—๏ธ
        • โ›”cannot read properties of nullishโ—๏ธ
        • โ›”cannot convert BigInt to Numberโ—๏ธ
        • โ›”cannot convert Symbol to Numberโ—๏ธ
        • โ›”cannot assign to read only property 'prototype' of function 'xxx'โ—๏ธ
    • ๐Ÿ›๏ธLibraries
      • ๐Ÿ›๏ธJSXGraph
      • ๐Ÿ›๏ธgrapheme-splitter
    • ๐Ÿ› ๏ธtools
      • transpilers
    • โœจexamples
      • Code Wars
        • Next Bigger Number
        • Changing Money
        • Game of Life
      • Exercises
        • flattenObject()
        • Pascal's Triangle
        • Permuations
        • Spiral Matrix
    • ๐Ÿ’ผprojects
      • ๐Ÿ’ผDictionary App
      • ๐Ÿ’ผLanguage: Egg
      • Calculator โค๏ธ
      • Synth Keyboard โค๏ธ
      • Form Validation
      • Password Generator
  • ๐Ÿ”ฐweb component
    • ๐Ÿ”ธcustom element
      • lifecycle methods
      • getter/setter for attributes
      • Element Types
      • Element Info
      • Observed Attributes
      • Element Upgrades
      • Unknown Elements vs Undefined Custom Elements
      • Element-defined Content
    • ๐Ÿ”ธshadow DOM
      • light, shadow, flattened DOM
      • shadow root vs. host
      • shadow DOM styles
        • Use CSS Variables
        • CSS reset in Shadow DOM
      • shadow DOM events
        • retargeting
        • Active Element
        • Events that Cross Shadow DOM Boundary
        • Bubbling in Shadow DOM
      • shadow DOM slots
    • ๐Ÿ”ธ<template>
      • ๐Ÿ”ธ<slot>
        • ๐Ÿ”ธnamed slot
        • ๐Ÿ”ธfallback content
        • ๐Ÿ”ฐslotted node styles
        • ๐Ÿ”ธslotted nodes
        • ๐Ÿ”น`slotchange` event
        • ๐Ÿ”ฐSlot API
    • ๐Ÿ”ธlight DOM
    • ๐Ÿ”ฐimplementing components
    • ๐Ÿ”ฐusing components
      • ๐Ÿ’กhide components until defined
    • Built-in Components
      • <details>
    • โœจweb component examples
      • โœจ<search-box>
      • <my-log> โค๏ธ
      • <element-details>
      • <custom-dialog>
      • <user-card>
      • <expanding-list>
      • <dom-hierarchy> โญ๏ธ
      • <time-formatted>
      • <live-timer>
      • <error-message>
      • <popup-info>
      • <custom-menu>
  • ๐ŸŒbrowser
    • ๐Ÿ“˜web API
      • ๐Ÿ“˜clearTimeout()
      • ๐Ÿ“˜setTimeout()
      • ๐Ÿ„URL
      • ๐Ÿ„navigator
      • ๐Ÿ”ฐweb worker
        • ๐Ÿ„self
    • ๐Ÿ”ฐconcepts
      • ๐Ÿ”ฐcoordinates
    • ๐Ÿ”ฐEvent
      • ๐Ÿ”ธevent.type
      • ๐Ÿ”ธevent.currentTarget
      • ๐Ÿ”ธevent.target
        • โœจbuttons A, B, C
      • ๐Ÿ”ฐevent dispatching
      • ๐Ÿ”ฐevent propagation
        • ๐Ÿ”ฐbubbling phase
        • ๐Ÿ”ฐcapturing phase
        • ๐Ÿ”ฐstop propagation
          • โœจbutton in clickable paragraph
      • ๐Ÿ”ฐevent handler
        • invocation context
        • โŒreturn value
        • ๐Ÿ”ฐ"this" in event handler
        • ๐Ÿ”ฐregister handler
          • ๐Ÿ”ฐhandler options
          • capturing handler
          • ๐Ÿ„object handler
        • ๐Ÿ”ฐremove handler
        • โ—window-reflecting body element event handlers
      • ๐Ÿ”ฐdefault action
        • โœจhide or not to hide?
        • โœจlink going nowhere
      • ๐ŸŒฟevent types
        • ๐Ÿ”ฐkey event
          • โœจpress shift + space
        • ๐Ÿ”ฐinput event
        • ๐Ÿ”ฐmouse event
          • ๐Ÿ”ธ.buttons
          • ๐Ÿ”ธ.button
          • ๐Ÿ”ฐ"click"
            • โœจdraw dots
            • โœจsliding menu
            • โœจclosing button [x]
            • โœจclick to slide (carousel)
            • โœจclick to move ball
          • ๐Ÿ”ฐ"dblclick"
          • ๐Ÿ”ฐ"mousemove"
            • โœจdrag the bar
          • ๐Ÿ”ฐdrag event
          • ๐Ÿ‘”MouseEvent+ext
          • โœจmouse event examples
            • โœจmouse event coords
        • ๐Ÿ”ฐtouch event
          • ๐Ÿ”ธ.touches
          • ๐Ÿ”ธ.targetTouches
          • ๐Ÿ‘”TouchList+ext
        • ๐Ÿ”ฐscroll event
          • โœจscroll me
          • โœจscroll progress
          • โœจscroll progress on body
        • state-change
        • CSS events
      • client-side JavaScript timeline
      • custom events
        • event.isTrusted
      • "change" event
    • ๐Ÿ”ฐDOM
      • ๐Ÿ”ฐDOM hierarchy
      • ๐Ÿ”ฐquerying elements
        • ๐Ÿ’พ$(), $all()
      • ๐Ÿ”ฐtraversing DOM
      • ๐Ÿ”ฐcreate/insert/delete nodes
        • โœจtable of contents
      • ๐ŸŒฟDOM types
        • ๐Ÿ“˜Node
          • ๐Ÿ”ฐ.tagName vs .nodeName
          • ๐Ÿ‘”Node+ext
            • ๐Ÿ’พnode.isInPage
            • ๐Ÿšงnode.traverse()
            • ๐Ÿ’พnode.$(), .$all()
            • ๐Ÿšงnode.appendTag()
            • ๐Ÿ’พnewElement()
        • ๐Ÿ“˜Element
          • ๐Ÿ”ธelement content
          • ๐Ÿ”น.insertAdjacentHTML()
          • ๐Ÿ”ธattribute
            • ๐Ÿ”ธid
            • ๐Ÿ”ฐdata attributes
            • โš–๏ธattributes vs. properties
          • ๐Ÿ”ฐbox models
          • ๐Ÿ‘”Element+boxes
            • ๐Ÿ”ธ.scrollBox
              • ๐Ÿ”ฐscrollbar width
            • ๐Ÿ”ธ.paddingBox
            • ๐Ÿ”ธ.borderBox
              • ๐Ÿ”ธ.offsetParent
            • ๐Ÿ”ธ.boundingBox
              • โœจelem.showNote()
          • ๐Ÿ‘”Element+ext
            • ๐Ÿ’พelem.isInside()
            • ๐Ÿ’พelem.isHeading
            • ๐Ÿ’พelem.wrappedWith()
            • ๐Ÿ’พelem.wrappedWithHTML()
            • ๐Ÿšงelem.attr()
            • ๐Ÿšงelem.styleProp()
            • ๐Ÿšงelem.showDataAttr()
            • ๐Ÿ’พelem.position()
        • ๐Ÿ„HTMLElement
          • ๐Ÿ’พhtmlElem.isHidden
        • ๐Ÿ“˜Document
          • ๐Ÿ”ธdocument size
          • ๐Ÿ”ธmethods
            • ๐Ÿ“˜doc.elementFromPoint()
        • ๐Ÿ“˜Window
          • ๐Ÿ”น.requestAnimationFrame()
          • ๐Ÿ”ฐviewport
          • ๐Ÿ”ฐwindow scrolling
            • ๐Ÿ”ฐscroll smoothly
            • ๐Ÿ”ฐscroll lock
        • ๐Ÿ„DocumentFragment
        • ๐Ÿ„NodeList
          • NodeList vs. Array
        • CSSStyleDeclaration
      • โœจDOM examples
      • ๐Ÿ‘”custom methods
        • ๐Ÿšงprop()
        • ๐Ÿšงtag()
    • ๐Ÿ”ฐSVG
      • ๐Ÿ’พSVGElement()
      • Attributes
        • fill
        • stroke-dasharray
        • transform
      • ๐Ÿ”ฐgradients
        • ๐Ÿ“˜<linearGradient>
        • ๐Ÿ“˜<radialGradient>
      • Patterns
      • ๐Ÿ”ฐSVG shapes
        • <rect>
        • <line>
        • <polygon>
        • <polyline>
        • <ellipse>
        • <path>
      • โœจSVG examples
        • SVG as background image
        • 3 circles
        • โœจSVG Clock
        • โœจpie chart
      • namespace
      • tools
    • ๐Ÿ”ณ<canvas>
      • ๐Ÿ‘”Canvas+ext
        • ๐Ÿ’พdrawOnCanvas2D()
        • ๐Ÿ’พctx.point()
        • ๐Ÿ’พctx.polyline()
        • ๐Ÿ’พctx.roundedRect()
      • ๐Ÿ”ฐrectangle
      • ๐Ÿ”ฐpath
        • ๐Ÿ”ฐnonzero winding rule
        • ๐Ÿ“˜arcTo()
        • โœจcurves
      • ๐Ÿ”ฐtext
      • ๐Ÿ”ฐimage
        • โœจcanvas snapshot
      • ๐Ÿ”ฐgraphics state
        • ๐Ÿ”ฐfill / stroke styles
          • ๐Ÿ”ฐcolors
            • โœจcolor wheel
          • ๐Ÿ”ฐpatterns
          • ๐Ÿ”ฐgradients
            • ๐Ÿ’พctx.gradient()
        • ๐Ÿ”ฐshadows
        • ๐Ÿ”ฐcompositing
        • ๐Ÿ”ฐtransformation
          • โœจKoch snowflake
        • ๐Ÿ”ฐclipping
      • โœจcanvas examples
        • โœจsquare & circle
        • โœจopen/closed subpaths
        • โœจfractal
        • โœจregular polygons
    • ๐Ÿ”ฐstorage
    • ๐Ÿ”ฐanimation
      • โœจanimation examples
        • โœจmoving cat
        • โœจcat in hat
        • โœจcat behind hat
  • ๐Ÿ”ฐReact
    • ๅ•Ÿๅ‹•
    • Hello Reactโ—๏ธ
    • React Projects
      • FullStackOpen
        • Part 1
  • Server
    • HTTP status code
  • ๐Ÿ”–้™„้Œ„
    • ๐Ÿ‘”custom
      • ๐Ÿ‘”element
        • ๐Ÿ‘”tabs control
        • ๐Ÿ‘”left tabs
      • ๐Ÿ‘”custom css
        • ๐Ÿ‘”Every Layout
      • ๐Ÿ‘”custom classes
        • ๐Ÿ‘”Vector
        • ๐Ÿ‘”Rect
        • ๐Ÿ‘”Size
        • ๐Ÿ’พTableMaker
        • List
        • Point
        • Turtle
        • Matrix
      • ๐Ÿ‘”custom functions
        • randomElement()
        • randomColor()
        • randomPassword()
        • clone(obj)
        • functionName()
      • helper functions
    • ๐Ÿงฉthree.js
      • ๐Ÿ‘”Director
      • ๐Ÿ”ฐrenderer
        • ๐Ÿ”นset canvas size
      • โœจexamples
        • โœจstartup
      • ๐Ÿ”ฐprimitives
      • ๐Ÿ”ฐscene graph
    • ๐Ÿ…ฐ๏ธGoogle Apps Script
      • ๐Ÿ„app
        • ๐Ÿ”นhelpers
        • ๐Ÿ”ธapp.init()
        • ๐Ÿ”ธmembers
          • ๐Ÿ”ธapp.color
          • ๐Ÿ’พapp.dataRangeValuesFromSheet()
          • ๐Ÿ’พapp.sheetByName()
          • ๐Ÿ’พapp.valueOfNamedRange()
          • ๐Ÿ’พapp.deleteSheetByName()
          • ๐Ÿšงapp.cellValueAt()
          • โญapp.makeTable()
          • ๐Ÿšงapp.mergedCellValue()
          • ๐Ÿšงapp.parseFields()
          • ๐Ÿšงapp.fetch()
          • ๐Ÿšงapp.resizeColumns()
          • ๐Ÿšงapp.setBorder()
          • ๐Ÿšงapp.writeAwardList()
        • ๐Ÿ”ณprototypes
          • ๐Ÿ”ณapp.sheet.prototype
            • ๐Ÿ’พ sheet.delete()
            • ๐Ÿ’พ sheet.rangeByRect()
            • ๐Ÿ’พ sheet.setValues()
            • ๐Ÿ’พsheet.appendConditionalFormatRule()
            • ๐ŸšงSheetMethods
              • sheet.values()
          • ๐Ÿ”ณapp.range.prototype
            • range.alignCenter()
            • range.cellValue()
            • range.contains()
            • ๐Ÿšงrange.isEqualTo()
        • ๐ŸŸฅapp menu
      • ๐Ÿ„RawData
      • ๐ŸŒฟClasses
        • ๐Ÿ„Sheet
        • ๐Ÿ„Range
          • ๐Ÿ”ฐA1 notation
            • ๐Ÿ’พcolumnName()
            • ๐Ÿ’พA1Notation()
            • ๐Ÿ’พA1NotationToRowColumn()
          • ๐Ÿ”ฐborder
          • ๐Ÿ“˜range.setNumberFormat()
          • range.setRichTextValue()
        • ๐Ÿ„ConditionalFormatRule
        • ๐Ÿ„RichTextValueBuilder
        • ๐Ÿ„Protection
        • ๐Ÿ„Ui
      • ๐Ÿ‘”custom objects
        • ๐Ÿ‘”RangeRect
          • ๐Ÿ’พrect.cell(i, j)
          • ๐Ÿ’พRangeRect.byData()
        • ๐ŸšงBorderStyle
        • ๐ŸšงSheetFields, SheetField
      • ๐Ÿ’ผprojects
        • ๐Ÿ’ผไธ่ƒฝ่ฃœ่€ƒๅๅ–ฎ
        • ๐Ÿ’ผๅ„็ญๅนณๅ‡ๅŠๅ‰ไธ‰ๅ
        • ๐Ÿ’ผๅœ‹ไธญๆˆ็ธพไธ€่ฆฝ่กจ
        • ๐Ÿ’ผ้ซ˜ไธญ็Žๅญธ้‡‘ๅๅ†Š
      • ๐Ÿ’กtips
        • ๐Ÿ’ก custom prototypes
        • ๐Ÿ’ก refresh cells
        • ๐Ÿ’ก ๆขไปถๆ ผๅผ๏ผš่‡ช่จ‚ๅ…ฌๅผ
        • ่™•็†ๅญ—ไธฒ
        • ้กฏ็คบไธญๆ–‡ๆ˜ŸๆœŸๅนพ
        • ๅœจๅ„ฒๅญ˜ๆ ผไฝฟ็”จ้™ฃๅˆ—
        • Count non-blank cells
        • ๐Ÿ’ก ๅฟซ้€Ÿ่ชฟๆ•ดๆฌ„ไฝๅฏฌๅบฆ
      • โ“questions
      • ๐Ÿ“ŠGoogle Sheet
      • ๐Ÿ”ธGAS โŸฉ commands
      • โœจGAS โŸฉ examples
        • examples
        • โœจsplit data into tabs
          • migrate sheets into files
        • โœจevent: onEdit
      • ๐Ÿ”ฐGAS โŸฉ Events
        • onEdit
      • Dialogs & Sidebars
    • ๐Ÿ“–JSDoc
      • return value
      • destructured parameter
    • ๐Ÿ“ฆdata structure
      • ๐Ÿ“ฆQueue
      • ๐Ÿ“ฆStack
      • ๐Ÿ“ฆWaitingList
      • ๐Ÿ“ฆGraph
        • ๐Ÿ”น.findPath()
        • ๐Ÿ”น.findShortestPath()
        • ๐Ÿค–breadth-first search
        • ๐Ÿค–depth-first search
        • โœจGraph examples
          • โœจMail Robot
    • ๐Ÿ”ฐalgorithm
      • ๐Ÿ”ฐrecursion
        • โœจrecursion count
      • ๐Ÿ”ฐdynamic programming
      • Sort
        • sort strings
        • sort by multiple keys
        • bubble sort
      • โœจproblems
        • โœจfind couple
        • โœจknapsack problem
        • โœจlongest path
    • ๐Ÿ”ฐparadigm
      • ๐Ÿ”ฐTest Driven Development (TDD)
      • ๐Ÿ”ฐFunctional Programming (FP)
    • ๐Ÿ”ฐTypeScript
      • Setup
      • โญ๏ธ Cheat sheet
      • Type
        • type annotation
        • type predicate
        • Primitives
        • Narrowing
        • Tuples
        • Generics
          • Array<T>
          • Generic Functions
        • Object
          • Object Types
          • Object Properties
        • Function
          • optional/default parameters
          • return type
          • function type expression
          • callable objects with properties
          • function overloads
        • Union
          • discriminated union
      • TS Operators
    • ๐Ÿ’Žresource
      • โœ๏ธeditor
        • โœ๏ธVSCode
          • emmet
          • shortcuts
        • โœ๏ธreplit.com
          • ๐Ÿ”ฐimport .js file
      • ๐Ÿ”งtools
        • Vectornator
          • Tutorials
      • ๐Ÿ“šbooks
Powered by GitBook
On this page

Was this helpful?

  1. ้™„้Œ„
  2. custom
  3. custom classes

Vector

Previouscustom classesNextRect

Last updated 2 years ago

Was this helpful?

โŸฉ โŸฉ Vector

support vector operations๏ผšu + v, u - v, k * v ...

u + v: u.plus(v)
u - v: u.minus(v)
k * v: v.times(k)
au + bv + cw: linearCombination([a,b,c], [u,v,w])

custom

  • replit โŸฉ , require -> Number+ext

// 2023.01.22 - 21:04 (/) refactor vec(x,y) -> vec(...args)
// 2023.01.21 - 13:18 (+) .clampInRect()
// 2023.01.15 - 19:56 (+) linearCombination()
// 2023.01.15 - 08:50 (?) refactor, first recorded.
// ------------------------------------------------------

const {sin, cos, sqrt} = Math;

// โญ๏ธ import 
// ------------------------------------------------------
import {  } from './Number+ext.js';    // ๐Ÿ‘” Number + ext


// โญ๏ธ Vector
// ------------------------------------------------------
// - vec(x, y), vec(v)
// - polar(r, theta)
// - linearCombination(scalars, vectors)
// ------------------------------------------------------
// ๐Ÿ”ธ .x
// ๐Ÿ”ธ .y
// ๐Ÿ”ธ .coords         : [x, y]
// ๐Ÿ”ธ .inverse        : -v            (additive inverse)
// ๐Ÿ”น .plus(...args)  : (v), (x, y)
// ๐Ÿ”น .minus(...args) : (v), (x, y)
// ๐Ÿ”น .times(k)       : u * k         (scalar product)
// ------------------------------------------------------
// ๐Ÿ”ธ .length
// ๐Ÿ”น .distanceTo(...args)    : (v), (x, y)
// ------------------------------------------------------
// ๐Ÿ”น .toString()
// ------------------------------------------------------
// 
class Vector {

    // ๐ŸŸง Vector.zero
    static get zero() { return new Vector(0, 0) }

    // init
    constructor(x, y) {
        this.x = x;
        this.y = y;
    }

    // ๐Ÿ”ธ .coords
    get coords() { return [this.x, this.y] }

    // -----------
    //     -v
    // -----------

    // ๐Ÿ”ธ .inverse
    get inverse() { return new Vector(-this.x, -this.y) }
    
    // -------------
    //     u + v
    // -------------

    // ๐Ÿ”น u.plus(v) or u.plus(x, y)
    plus(...args) {

        // treat as u + v
        if (args.length === 1) {
            const v = args[0];
            return new Vector(this.x + v.x, this.y + v.y)
        }

        // treat as u + (x, y)
        if (args.length === 2) return this.plus(vec(...args));

        // throw error otherwise
        throw new Error(`Vector.plus() is expecting 1 or 2 arguments, but got ${args.length}.`);
    }

    // -------------
    //     u - v
    // -------------

    // ๐Ÿ”น u.minus(v) or u.minus(x, y)
    minus(...args) { 
        // treat as u - v
        if (args.length === 1) {
            const v = args[0];
            return new Vector(this.x - v.x, this.y - v.y);
        }

        // treat as u - (x, y)
        if (args.length === 2) return this.minus(vec(...args));

        // throw error otherwise
        throw new Error(`Vector.minus() is expecting 1 or 2 arguments, but got ${args.length}.`);
    }

    // -------------
    //     k * v
    // -------------

    // ๐Ÿ”น .times(k)
    times(k) { return new Vector(this.x * k, this.y * k) }

    // ------------------------
    //     distance related
    // ------------------------

    // ๐Ÿ”ธ .length
    get length() { 
        const {x, y} = this;
        return sqrt(x*x + y*y); 
    }

    // ๐Ÿ”น .distanceTo(v) or .distanceTo(x, y)
    distanceTo(...args) {

        // u.distanceTo(v)
        if (args.length === 1) {
            const v = args[0];
            return this.minus(v).length;
        }

        // u.distanceTo(x, y)
        if (args.length === 2) {
            return this.distanceTo(vec(...args));
        }

        // throw error otherwise
        throw new Error(`Vector.distanceTo() is expecting 1 or 2 arguments, but got ${args.length}.`);
    }

    // ๐Ÿ”น .isEqualTo(v)
    isEqualTo(v, {threshold = 100 * Number.EPSILON}={}) {
        return areEqualNumbers(0, this.distanceTo(v), {threshold});
    }

    // ---------------
    //     rect
    // ---------------

    clampInRect(rect) {
        const {x: x1, y: y1} = rect.origin;
        const {x: x2, y: y2} = rect.bottomRight;
        return vec(this.x.clamp(x1, x2), this.y.clamp(y1, y2)); // ๐Ÿ‘” Number + ext
    }

    // ---------------
    //     debug
    // ---------------

    // ๐Ÿ”น .toString()
    toString() { return `(${this.x}, ${this.y})` }

    // โญ๏ธ custom type name
    // โ—๏ธ note: typeof vec(1,2) === 'object' 
    get [Symbol.toStringTag]() { return 'Vector' }
}

// ----------------------------------------
// โญ๏ธ convenience factory functions
// ----------------------------------------

// vec(x, y), vec(v)        // ๐Ÿ‘” Vector (v1.1)
function vec(...args) { 
    const len = args.length;
    // treat as vec(x, y)
    if (len === 2) return new Vector(...args);
    // treat as vec(v)
    if (len === 1) {
        const {x, y} = args[0];
        return new Vector(x, y)
    };
    // throw error otherwise
    throw new Error(`vec(): expecting 1 or 2 arguments, but got ${len}!`);
}

// polar(r, theta)
function polar(r, theta) { 
    return vec(r * cos(theta), r * sin(theta)) 
}

// linear combination: a1*v1 + a2*v2 + ... + an*vn
function linearCombination(scalars, vectors) {
    return vectors
        .map((v, i) => v.times(scalars[i] || 0))
        .reduce((sum, vec) => sum.plus(vec), Vector.zero);
}

// --------------
// โญ๏ธ helpers
// --------------

// โญ๏ธ areEqualNumbers(x, y {threshold})
// - Number.EPSILON = 2^(-52) โ‰ˆ 2.2 * 10^(-16)
function areEqualNumbers(x, y, {threshold = Number.EPSILON}={}) { 
    return Math.abs(x - y) < threshold; 
}

// ๐Ÿ“ค export
// -----------------------------
export { vec, polar, Vector, linearCombination };            // export ES module
// module.exports = { vec, polar, Vector, linearCombination };
  • Size

  • Rect - origin, size, width, height ...

  • Element+boxes

  • Canvas+ext - use vec().

  • MouseEvent+ext

  • coordinates

  • elem.position() - (.borderBox) position relative to some coordinates system.

  • curves

  • arcTo()

  • <canvas>

  • Koch snowflake

  • square & circle

History

0: (?) first recorded, refactor.
1: (+) linearCombination()
2: (+) .clampInRect()
// 2023.01.15 - 08:50 (?) first recorded
// ------------------------------------------------------

const {sin, cos} = Math;

// โญ๏ธ Vector
// ------------------------------------------------------
// ๐Ÿ”ธ .x
// ๐Ÿ”ธ .y
// ๐Ÿ”ธ .coords         : [x, y]
// ๐Ÿ”ธ .inverse        : -v            (additive inverse)
// ๐Ÿ”น .add(v)         : u + v
// ๐Ÿ”น .plus(x, y)     : u + (x, y)
// ๐Ÿ”น .minus(v)       : u - v
// ๐Ÿ”น .subtract(x, y) : u - (x, y)
// ๐Ÿ”น .times(k)       : u * k         (scalar product)
// ------------------------------------------------------
// ๐Ÿ”น .toString()
//
class Vector {

    // init
    constructor(x, y) {
        this.x = x;
        this.y = y;
    }

    // ๐Ÿ”ธ .coords
    get coords() { return [this.x, this.y] }
    
    // -------------
    //     u + v
    // -------------

    // ๐Ÿ”น u.add(v)
    add(v) { return new Vector(this.x + v.x, this.y + v.y) }

    // ๐Ÿ”น u.plus(x, y)
    plus(x, y) { return this.add(new Vector(x, y)) }

    // -----------
    //     -v
    // -----------

    // ๐Ÿ”ธ .inverse
    get inverse() { return new Vector(-this.x, -this.y) }

    // -------------
    //     u - v
    // -------------

    // ๐Ÿ”น u.minus(v)
    subtract(v) { return new Vector(this.x - v.x, this.y - v.y) }

    // ๐Ÿ”น u.subtract(x, y)
    minus(x, y) { return this.subtract(new Vector(x, y)) }

    // -------------
    //     k * v
    // -------------

    // ๐Ÿ”น .times(k)
    times(k) { return new Vector(this.x * k, this.y * k) }

    // ---------------
    //     helpers
    // ---------------

    // ๐Ÿ”น .toString()
    toString() { return `(${this.x}, ${this.y})` }
}

// ----------------------------------------
// โญ๏ธ convenience factory functions
// ----------------------------------------

function vec(x, y) { return new Vector(x, y) }

function polar(r, theta) { 
    return vec(r * cos(theta), r * sin(theta)) 
}

// export
export {
    vec, polar, Vector,
};
// 2023.01.15 - 19:56 (+) linearCombination()
// 2023.01.15 - 08:50 (?) refactor, first recorded.
// ------------------------------------------------------

const {sin, cos, sqrt} = Math;

// โญ๏ธ Vector
// ------------------------------------------------------
// - vec(x, y)
// - polar(r, theta)
// - linearCombination(scalars, vectors)
// ------------------------------------------------------
// ๐Ÿ”ธ .x
// ๐Ÿ”ธ .y
// ๐Ÿ”ธ .coords         : [x, y]
// ๐Ÿ”ธ .inverse        : -v            (additive inverse)
// ๐Ÿ”น .plus(...args)  : (v), (x, y)
// ๐Ÿ”น .minus(...args) : (v), (x, y)
// ๐Ÿ”น .times(k)       : u * k         (scalar product)
// ------------------------------------------------------
// ๐Ÿ”ธ .length
// ๐Ÿ”น .distanceTo(...args)    : (v), (x, y)
// ------------------------------------------------------
// ๐Ÿ”น .toString()
// ------------------------------------------------------
// 
class Vector {

    // ๐ŸŸง Vector.zero
    static get zero() { return new Vector(0, 0) }

    // init
    constructor(x, y) {
        this.x = x;
        this.y = y;
    }

    // ๐Ÿ”ธ .coords
    get coords() { return [this.x, this.y] }

    // -----------
    //     -v
    // -----------

    // ๐Ÿ”ธ .inverse
    get inverse() { return new Vector(-this.x, -this.y) }
    
    // -------------
    //     u + v
    // -------------

    // ๐Ÿ”น u.plus(v) or u.plus(x, y)
    plus(...args) {

        // treat as u + v
        if (args.length === 1) {
            const v = args[0];
            return new Vector(this.x + v.x, this.y + v.y)
        }

        // treat as u + (x, y)
        if (args.length === 2) return this.plus(vec(...args));

        // throw error otherwise
        throw new Error(`Vector.plus() is expecting 1 or 2 arguments, but got ${args.length}.`);
    }

    // -------------
    //     u - v
    // -------------

    // ๐Ÿ”น u.minus(v) or u.minus(x, y)
    minus(...args) { 
        // treat as u - v
        if (args.length === 1) {
            const v = args[0];
            return new Vector(this.x - v.x, this.y - v.y);
        }

        // treat as u - (x, y)
        if (args.length === 2) return this.minus(vec(...args));

        // throw error otherwise
        throw new Error(`Vector.minus() is expecting 1 or 2 arguments, but got ${args.length}.`);
    }

    // -------------
    //     k * v
    // -------------

    // ๐Ÿ”น .times(k)
    times(k) { return new Vector(this.x * k, this.y * k) }

    // ------------------------
    //     distance related
    // ------------------------

    // ๐Ÿ”ธ .length
    get length() { 
        const {x, y} = this;
        return sqrt(x*x + y*y); 
    }

    // ๐Ÿ”น .distanceTo(v) or .distanceTo(x, y)
    distanceTo(...args) {

        // u.distanceTo(v)
        if (args.length === 1) {
            const v = args[0];
            return this.minus(v).length;
        }

        // u.distanceTo(x, y)
        if (args.length === 2) {
            return this.distanceTo(vec(...args));
        }

        // throw error otherwise
        throw new Error(`Vector.distanceTo() is expecting 1 or 2 arguments, but got ${args.length}.`);
    }

    // ๐Ÿ”น .isEqualTo(v)
    isEqualTo(v, {threshold = 100 * Number.EPSILON}={}) {
        return areEqualNumbers(0, this.distanceTo(v), {threshold});
    }

    // ---------------
    //     debug
    // ---------------

    // ๐Ÿ”น .toString()
    toString() { return `(${this.x}, ${this.y})` }

    // โญ๏ธ custom type name
    // โ—๏ธ note: typeof vec(1,2) === 'object' 
    get [Symbol.toStringTag]() { return 'Vector' }
}

// ----------------------------------------
// โญ๏ธ convenience factory functions
// ----------------------------------------

// vec(x, y)
function vec(x, y) { return new Vector(x, y) }

// polar(r, theta)
function polar(r, theta) { 
    return vec(r * cos(theta), r * sin(theta)) 
}

// linear combination: a1*v1 + a2*v2 + ... + an*vn
function linearCombination(scalars, vectors) {
    return vectors
        .map((v, i) => v.times(scalars[i] || 0))
        .reduce((sum, vec) => sum.plus(vec), Vector.zero);
}

// --------------
// โญ๏ธ helpers
// --------------

// โญ๏ธ areEqualNumbers(x, y {threshold})
// - Number.EPSILON = 2^(-52) โ‰ˆ 2.2 * 10^(-16)
function areEqualNumbers(x, y, {threshold = Number.EPSILON}={}) { 
    return Math.abs(x - y) < threshold; 
}

// ๐Ÿ“ค export
// -----------------------------
// export { vec, polar, Vector, linearCombination };            // export ES module
module.exports = { vec, polar, Vector, linearCombination };
// 2023.01.21 - 13:18 (+) .clampInRect()
// 2023.01.15 - 19:56 (+) linearCombination()
// 2023.01.15 - 08:50 (?) refactor, first recorded.
// ------------------------------------------------------

const {sin, cos, sqrt} = Math;

// โญ๏ธ import 
// ------------------------------------------------------
import {  } from './Number+ext.js';    // ๐Ÿ‘” Number + ext


// โญ๏ธ Vector
// ------------------------------------------------------
// - vec(x, y)
// - polar(r, theta)
// - linearCombination(scalars, vectors)
// ------------------------------------------------------
// ๐Ÿ”ธ .x
// ๐Ÿ”ธ .y
// ๐Ÿ”ธ .coords         : [x, y]
// ๐Ÿ”ธ .inverse        : -v            (additive inverse)
// ๐Ÿ”น .plus(...args)  : (v), (x, y)
// ๐Ÿ”น .minus(...args) : (v), (x, y)
// ๐Ÿ”น .times(k)       : u * k         (scalar product)
// ------------------------------------------------------
// ๐Ÿ”ธ .length
// ๐Ÿ”น .distanceTo(...args)    : (v), (x, y)
// ------------------------------------------------------
// ๐Ÿ”น .toString()
// ------------------------------------------------------
// 
class Vector {

    // ๐ŸŸง Vector.zero
    static get zero() { return new Vector(0, 0) }

    // init
    constructor(x, y) {
        this.x = x;
        this.y = y;
    }

    // ๐Ÿ”ธ .coords
    get coords() { return [this.x, this.y] }

    // -----------
    //     -v
    // -----------

    // ๐Ÿ”ธ .inverse
    get inverse() { return new Vector(-this.x, -this.y) }
    
    // -------------
    //     u + v
    // -------------

    // ๐Ÿ”น u.plus(v) or u.plus(x, y)
    plus(...args) {

        // treat as u + v
        if (args.length === 1) {
            const v = args[0];
            return new Vector(this.x + v.x, this.y + v.y)
        }

        // treat as u + (x, y)
        if (args.length === 2) return this.plus(vec(...args));

        // throw error otherwise
        throw new Error(`Vector.plus() is expecting 1 or 2 arguments, but got ${args.length}.`);
    }

    // -------------
    //     u - v
    // -------------

    // ๐Ÿ”น u.minus(v) or u.minus(x, y)
    minus(...args) { 
        // treat as u - v
        if (args.length === 1) {
            const v = args[0];
            return new Vector(this.x - v.x, this.y - v.y);
        }

        // treat as u - (x, y)
        if (args.length === 2) return this.minus(vec(...args));

        // throw error otherwise
        throw new Error(`Vector.minus() is expecting 1 or 2 arguments, but got ${args.length}.`);
    }

    // -------------
    //     k * v
    // -------------

    // ๐Ÿ”น .times(k)
    times(k) { return new Vector(this.x * k, this.y * k) }

    // ------------------------
    //     distance related
    // ------------------------

    // ๐Ÿ”ธ .length
    get length() { 
        const {x, y} = this;
        return sqrt(x*x + y*y); 
    }

    // ๐Ÿ”น .distanceTo(v) or .distanceTo(x, y)
    distanceTo(...args) {

        // u.distanceTo(v)
        if (args.length === 1) {
            const v = args[0];
            return this.minus(v).length;
        }

        // u.distanceTo(x, y)
        if (args.length === 2) {
            return this.distanceTo(vec(...args));
        }

        // throw error otherwise
        throw new Error(`Vector.distanceTo() is expecting 1 or 2 arguments, but got ${args.length}.`);
    }

    // ๐Ÿ”น .isEqualTo(v)
    isEqualTo(v, {threshold = 100 * Number.EPSILON}={}) {
        return areEqualNumbers(0, this.distanceTo(v), {threshold});
    }

    // ---------------
    //     rect
    // ---------------

    clampInRect(rect) {
        const {x: x1, y: y1} = rect.origin;
        const {x: x2, y: y2} = rect.bottomRight;
        return vec(this.x.clamp(x1, x2), this.y.clamp(y1, y2)); // ๐Ÿ‘” Number + ext
    }

    // ---------------
    //     debug
    // ---------------

    // ๐Ÿ”น .toString()
    toString() { return `(${this.x}, ${this.y})` }

    // โญ๏ธ custom type name
    // โ—๏ธ note: typeof vec(1,2) === 'object' 
    get [Symbol.toStringTag]() { return 'Vector' }
}

// ----------------------------------------
// โญ๏ธ convenience factory functions
// ----------------------------------------

// vec(x, y)
function vec(x, y) { return new Vector(x, y) }

// polar(r, theta)
function polar(r, theta) { 
    return vec(r * cos(theta), r * sin(theta)) 
}

// linear combination: a1*v1 + a2*v2 + ... + an*vn
function linearCombination(scalars, vectors) {
    return vectors
        .map((v, i) => v.times(scalars[i] || 0))
        .reduce((sum, vec) => sum.plus(vec), Vector.zero);
}

// --------------
// โญ๏ธ helpers
// --------------

// โญ๏ธ areEqualNumbers(x, y {threshold})
// - Number.EPSILON = 2^(-52) โ‰ˆ 2.2 * 10^(-16)
function areEqualNumbers(x, y, {threshold = Number.EPSILON}={}) { 
    return Math.abs(x - y) < threshold; 
}

// ๐Ÿ“ค export
// -----------------------------
export { vec, polar, Vector, linearCombination };            // export ES module
// module.exports = { vec, polar, Vector, linearCombination };

replit โŸฉ (with canvas example)

replit โŸฉ , require -> Number+ext

๐Ÿ”–
๐Ÿ‘”
๐Ÿ‘”
๐Ÿ‘”
๐Ÿ‘‰
custom
class
Vector (v1.1)
vector
๐Ÿ’พ
Vector.js