I saw this piece of code in React, like
connect(mapStateToProps, {
test: () => {return { type: 'TEST_ACTION' }}
})(Index);
but I failed to google any explanation. Probably the question is dumb, but I appreciate any help, maybe links to some existing explanations or examples.
It stands for "implies that". For example, x=2⟹x2=4 - if x is 2, then it is obvious that x squared is 4; the symbol essentially shows a function here.
It means assign the key to $user and the variable to $pass. When you assign an array, you do it like this. $array = array("key" => "value"); It uses the same symbol for processing arrays in foreach statements. The '=>' links the key and the value.
=> is syntactic sugar for creating instances of functions. Recall that every function in scala is an instance of a class. For example, the type Int => String , is equivalent to the type Function1[Int,String] i.e. a function that takes an argument of type Int and returns a String .
The object operator, -> , is used in object scope to access methods and properties of an object. It's meaning is to say that what is on the right of the operator is a member of the object instantiated into the variable on the left side of the operator. Instantiated is the key term here.
That's an ES2015 (aka ES6) arrow function. It's a function expression that inherits this
(and arguments
, and a few other things) from the context where it's created. So basically:
test: function() { return { type: 'TEST_ACTION' }; }
...but using the newer syntax that would handle this
differently, if it used this
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With