- corporate - cobol, fortran
- personal - c++ family
- ambient - javascript
--
why js?
coz worse is better
- already there
- widest reach
- lowest risk
- write libs and apps once
- single knowledge and skillset
--
is it even possible to replace it?
how does js evolved?
invented in 10 days in may 1995
mocha- livescript- js
javascript cloned in microsoft ie3.0 jscript
standarization ecma scrjpt
called ecma becuse java is sun., js is microsoft
so use ecma for none owner naming
-- ecmascript?
ecmascript is the standard that define javascript
not part of w3c
--
js implementation
- google v8
- mozila spidermonkey
- microsoft chakra
- webkit jscore
--
2009 ecmascript 5 :
use strict - json, object.create, etc
--
2008 javascript performance problem.
2013 performance improved
--
2014 es6 almost done,
--
es6 improvement
- more concise syntax
modules and sandkng boxing
class declaration
control abstraction
array comprehensions
promises
string interpolations
subclasses
--
tc39 its not like this..
and not like this..
google, ms, fb, netflix, safarj, jquery, ebay, yahoo, ie, intels
--
ecma design challenges
the closure in loop problem
foreach() objcallback(x)
obj.callback(x)
x will take the last.
--
local scoping WTF
function(x,x)
var x
function x()
x()
so what x will be?
--
why u need to worry about the edgecases?
because it will work on the browser but not on other browser
--
how we fix?
closire in loop?
instead var using let
let p in x
let v = doSomethjbg (x,p)
let will binding on scope variable
--
but want to avoid new let WTF
let x = 1
let x = 2
or
let x =
var x =
the solution, there will static error.
anybody shouldn't code this things.
--
avoid inconsistent scoping WTF?
let x = 1
functionf ()
console log (x)
let x = 2
what will u get 1/ undefined / 2?
- never leaking scope.
avoid bogus const
using const x = 3
will be an error
-- but u need it in forward declaration
e.g mutual function
r1 = f(r2)
r2 = f(r1)
error vased upon time of actual access
nor upon position in source code
must be intialize before
--
what abt block scope function?
function g()
g()
browser agree it will applied after it declared
but also disageee how to handle if g is not declare and call on the top or in the block or outside the block
--
unfortunately browser agree violate block scoping
--
summary
its real
will be the future soon
No comments:
Post a Comment