我是JavaScript新手。我正在阅读一个简洁的ES6功能,destructuring assignment。在"设置功能参数的默认值 - ES6版本"它有以下例子:
Scanner fileReader = new Scanner(new FileReader("pets.txt"));
fileReader.useLocale(Locale.US);
double age = 0, weight = 0;
int counter = 0;
// A while loop to read until there are no more lines
while(fileReader.hasNext()) {
fileReader.useDelimiter(",");
System.out.println(fileReader.next());
System.out.println(fileReader.nextInt());
fileReader.useDelimiter(Pattern.compile("[\\r\\n,]+"));
System.out.println(fileReader.nextDouble());
}
fileReader.close();
在解构function drawES6Chart({size = 'big', cords = { x: 0, y: 0 }, radius = 25} = {}) {
//------------------------------------------------------ what is this for? ^
}
drawES6Chart({
cords: { x: 18, y: 30 },
radius: 30
});
的参数时drawES6Chart()
的目的是什么?