js问题集合
问题:js参数中有大括号
import CheckPermissions from './CheckPermissions';
const Authorized = ({ children, authority, noMatch = null }) => { //大括号括起来和不用大括号有什么区别?
const childrenRender = typeof children === 'undefined' ? null : children;
return CheckPermissions(authority, childrenRender, noMatch);
};
回答:
带大括号是指传递一个参数,参数类型为对象,里面有三个属性children, authority, noMatch,不带大括号就是传递三个参数,这里的大括号不是块级作用域,就是单纯的表示一个对象
https://segmentfault.com/q/1010000017062649
https://es6.ruanyifeng.com/#docs/function
有趣的问题:学开发到底要实操项目。
学软件主要是为了做出软件,所以尽量使用代码块,这和学英语一样,语言块永远重要,让你有生产力,产出产品。而细节(单个语素,字词)会让你懂得原理。
太探究问题,会太费时间。
所以就像搭积木,你先用,用一段时间后,大脑就会认为,它本来就是那个样子。让后在做探究。所以实用是 最高优先级 而并非理论。
他们整词,所以理解概念 ,是需要实践的。
闭包:
https://www.jianshu.com/p/26c81fde22fb
发表评论