在前面的章节中,已陆陆续续介绍了ES6为改良函数而引入的几个新特性,本章将会继续讲解ES6对函数的其余改进,包括默认参数.元属性.块级函数和箭头函数等. 一.默认参数 在ES5时代,只能在函数体中定义参数的默认值,而自从ES6引入了默认参数(Default Parameter)后,就能让参数在声明时带上它的默认值,如下代码所示,func2()函数中的参数默认值在可读性和简洁性方面更为优秀. function func1(name) { name = name || "strick";…
In C++, the only code that guaranteed to be executed after an exception is thrown are the destructors of objects residing in stack and that's why we need RAII. We don't always deal with head based objects, so instead with using auto_ptrs and shared_p…