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
  • What is JavaScript?
  • What can in-browser JavaScript do?
  • What CAN’T in-browser JavaScript do?
  • Languages “over” JavaScript

Was this helpful?

  1. JavaScript

An Introduction to JavaScript

PreviousUntitledNextHello, world!

Last updated 5 years ago

Was this helpful?

What is JavaScript?

JavaScript 讓網頁動起來的語言 不同瀏覽器有不同的 "引擎" 1. Chrome and Opera - 2. Firefox - 3. Safari - 引擎如何運作 ? JavaScript > machine language > run

What can in-browser JavaScript do?

  • 新增、修改網頁內容 ( HTML )、改變外觀 ( CSS )

  • 對使用者動作做出反應 (滑鼠移動、點擊 )

  • 對伺服器發出請求,下載或上傳檔案

  • 存取 cookie ( 紀錄使用者資訊的資料 )

  • 存取用戶端資料 ( local storage )

What CAN’T in-browser JavaScript do?

  • 不能存取使用者硬碟的資料,除非使用者同意 ( 下載 / 上傳檔案 )

  • 不同網站之間無法互相存取資料 ( Same Origin Policy )

  • 不同網站之間可以提取資料,但需要額外設定新的參數 ( HTTP header )

  • 在非瀏覽器的環境下或瀏覽器安裝插件(使用者同意下),JavaScript 沒有以上的限制。

Languages “over” JavaScript

JavaScript 不能滿足所有人,許多相關的新語言誕生,像是 CoffeeScript、TypeScript、Dart 等等, 這些語言在執行前會被轉譯成 JavaScript。

V8
SpiderMonkey
WebKit