const Message=props=>div>{props.msg}</div>
and
function Message(props){
return(
<div>{props.msg}</div>
)
}
Is the same?
Can I check somewhere?
javascript es6
No, it's not.
Functions defined by a normal function definition can be called in new
, but not an Arrow function.
var Foo=function(){};
var foo=new Foo();//OK
var Foo=()=>{};
var foo=new Foo();// Error
Also, although it does not appear in this example, there is a difference in the treatment of (This kind of problem seems to come out well if you search for 〇 v vs ×× in English.)Also, in the end, it would be better to read the specifications.)this
between the normal function and the Arrow functions.
For more information, see "Arrow function vs function declaration/expression: Are they equivalent/exchangeable?" and in your home Q&A.
© 2024 OneMinuteCode. All rights reserved.