草庐IT

javascript - 'Arrow Functions' 和 'Functions' 是否等效/可互换?

ES2015中的箭头函数提供了更简洁的语法。我现在可以用箭头函数替换我所有的函数声明/表达式吗?我需要注意什么?例子:构造函数functionUser(name){this.name=name;}//vsconstUser=name=>{this.name=name;};原型(prototype)方法User.prototype.getName=function(){returnthis.name;};//vsUser.prototype.getName=()=>this.name;对象(文字)方法constobj={getName:function(){//...}};//vscon

javascript - 'Arrow Functions' 和 'Functions' 是否等效/可互换?

ES2015中的箭头函数提供了更简洁的语法。我现在可以用箭头函数替换我所有的函数声明/表达式吗?我需要注意什么?例子:构造函数functionUser(name){this.name=name;}//vsconstUser=name=>{this.name=name;};原型(prototype)方法User.prototype.getName=function(){returnthis.name;};//vsUser.prototype.getName=()=>this.name;对象(文字)方法constobj={getName:function(){//...}};//vscon

leetcode 452. Minimum Number of Arrows to Burst Balloons 用最少数量的箭引爆气球(中等)

一、题目大意标签:贪心https://leetcode.cn/problems/minimum-number-of-arrows-to-burst-balloons有一些球形气球贴在一堵用XY平面表示的墙面上。墙面上的气球记录在整数数组 points ,其中points[i]=[xstart,xend] 表示水平直径在 xstart 和 xend之间的气球。你不知道气球的确切y坐标。一支弓箭可以沿着x轴从不同点完全垂直地射出。在坐标x处射出一支箭,若有一个气球的直径的开始和结束坐标为xstart,xend,且满足 xstart ≤x≤xend,则该气球会被引爆 。可以射出的弓箭的数量没有限制。

leetcode 452. Minimum Number of Arrows to Burst Balloons 用最少数量的箭引爆气球(中等)

一、题目大意标签:贪心https://leetcode.cn/problems/minimum-number-of-arrows-to-burst-balloons有一些球形气球贴在一堵用XY平面表示的墙面上。墙面上的气球记录在整数数组 points ,其中points[i]=[xstart,xend] 表示水平直径在 xstart 和 xend之间的气球。你不知道气球的确切y坐标。一支弓箭可以沿着x轴从不同点完全垂直地射出。在坐标x处射出一支箭,若有一个气球的直径的开始和结束坐标为xstart,xend,且满足 xstart ≤x≤xend,则该气球会被引爆 。可以射出的弓箭的数量没有限制。