TIL coding
  • Initial page
  • 排版
  • Flexbox
  • Grid
  • jQuery
  • Untitled
  • JavaScript
    • An Introduction to JavaScript
    • Hello, world!
    • Code structure
    • The modern mode, "use strict"
    • Variables
    • Data types
    • Type Conversions
    • Operators
    • Comparisons
    • Interaction: alert, prompt, confirm
    • Conditional operators: if, '?'
    • Logical operators
    • Loops: while and for
    • The "switch" statement
    • Functions
    • Function expressions and arrows
    • JavaScript specials
    • Comments
    • Ninja code
    • Automated testing with mocha
    • Polyfills
    • Objects
    • Garbage collection
    • Symbol type
    • Object methods, "this"
    • Object to primitive conversion
    • Constructor, operator "new"
    • Methods of primitives
    • Numbers
    • Strings
    • Arrays
    • Array methods
    • Iterables
    • Map, Set, WeakMap and WeakSet
    • Object.keys, values, entries
    • Destructuring assignment
    • Date and time
    • JSON methods, toJSON
    • Recursion and stack
    • Rest parameters and spread operator
    • Closure
    • The old "var"
    • Global object
    • Function object, NFE
    • The "new Function" syntax
    • Scheduling: setTimeout and setInterval
    • Decorators and forwarding, call/apply
    • Function binding
    • Currying and partials
    • Arrow functions revisited
    • Property flags and descriptors
    • Property getters and setters
    • Prototypal inheritance
    • F.prototype
    • Native prototypes
    • Prototype methods, objects without __proto__
    • The “class” syntax
    • Class inheritance
    • Static properties and methods
    • Private and protected properties and methods
    • Extending built-in classes
    • Class checking: "instanceof"
    • Mixins
    • Error handling, "try..catch"
    • Custom errors, extending Error
    • Introduction: callbacks
    • Promise
    • Promises chaining
    • Error handling with promises
    • Promise API
  • Bootstrap
    • Navbar
Powered by GitBook
On this page

Was this helpful?

  1. JavaScript

Polyfills

執行瀏覽器不支援的原生 API 。

PreviousAutomated testing with mochaNextObjects

Last updated 5 years ago

Was this helpful?

Babel

當使用語言的新特性,瀏覽器不一樣支援,這時候要使用轉譯器將程式碼轉為較老舊瀏覽器支援的寫法。Babel 包含2 個部分;

  1. 轉譯程式,將重新改寫程式碼轉為老舊支援的寫法,webpack 就提供了這樣自動轉譯的功能,對於工程師來說沒有時間的損失。

  2. polyfill 新的特性包含內建函式跟語法結構,轉譯器可以轉譯成就的語法結構,但新的函式需要額外加上去。

  • 支援很多函式,但吃資源

  • 可以視需求加需要的功能

可以使用所有新特性。

babel polyfill
polyfill.io
Chrome Canary