this question has answer here:
in react native website, there following line of code:
var react = require('react-native'); var { tabbarios, navigatorios } = react; in second line of example, meaning of brackets around tabbarios , navigatorios variables?
this called destructuring assignment. it's newer feature being brought in ecmascript 6 spec.
here example object:
var test = { "hello": 1, "world": 2 } if deconstruct this:
var {hello, world} = test; this equivalent doing:
var hello = test.hello, world = test.world; but, there more fun stuff can destructuring assignments...
lets have object:
var bucket = { exampleobject: function(input){ this.input = input.trim(); return this.input; }, testingobject: function(example){ this.example = example || {}; console.log(this.example.input); } } just record, i've given members annoying names... when destructuring, can rename them this:
var {exampleobject: example, testingobject: test} = bucket; the binding pattern follows syntax so:
{objectmembername} // or {objectmembername: variablename} for more information, can @ ecmascript 6 specification draft or mdn documentation
Comments
Post a Comment