puma icon indicating copy to clipboard operation
puma copied to clipboard

ECMA 6 - RESEARCH Meta-programming features

Open emravera opened this issue 7 years ago • 0 comments

These features can be important for our project on ECMA6. It could be really useful to develop a short work on the features, usage and how impact on JS.

  1. Proxying

Info at: http://es6-features.org/#Proxying

let target = {
    foo: "Welcome, foo"
}
let proxy = new Proxy(target, {
    get (receiver, name) {
        return name in receiver ? receiver[name] : `Hello, ${name}`
    }
})
proxy.foo   === "Welcome, foo"
proxy.world === "Hello, world"
  1. Reflection

More info at: http://es6-features.org/#Reflection

let obj = { a: 1 }
Object.defineProperty(obj, "b", { value: 2 })
obj[Symbol("c")] = 3
Reflect.ownKeys(obj) // [ "a", "b", Symbol(c) ]

emravera avatar Apr 16 '18 23:04 emravera