Default Parameters

Default Parameters:

If you are familiar with other programming languages like Ruby, Python then default parameters isn’t new to you.

Default parameters are parameters which are given by default while declaring a function. But it’s value can be changed when calling the function.

Example

let Func = (a, b = 10) => {
 return a + b; 
}
Func(20); // 20 + 10 = 30

In the above example, we are passing only one parameter. The function makes use of the default parameter and executes the function.

Consider another example:

Func(20, 50); // 20 + 50 = 70

In the above example, the function takes two parameters and the second parameter replaces the default parameter.

来源:https://codeburst.io/es6-tutorial-for-beginners-5f3c4e7960be

JavaScript let

if (true) {
 let a = 40;
 console.log(a); //40
}
console.log(a); // undefined

上面的范例,如果改成var的话,最下面一行的console.log(a); 却是可以获取到的(40)

React Tutorial

Build with React JS
http://buildwithreact.com/tutorial

ReactJS Tutorial
https://www.tutorialspoint.com/reactjs/index.htm

React Native
https://facebook.github.io/react-native/docs/tutorial.html

Hello World – React
https://reactjs.org/docs/hello-world.html

文章
Optimizing React: Virtual DOM explained — Martian Chronicles, Evil Martians’ team blog

 

React Tutorial: A Comprehensive Guide to learning React.js in 2018

前端杂货

JavaScript Array map() Method

jQuery Misc index() Method

parents() 和 parent() 的差别,在于 parent() 是上一个元素,而 parents() 是所有祖先元素。除非有加参数,例如parents(“ul”),不然会一直跑到最上面。但是假如是这样选择parents(“ul”),它会传回所有的娘亲ul们。所以建议参数用class还是id之类的。

The parent() method returns the direct parent element of the selected element.
The parents() method returns all ancestor elements of the selected element.