Calling a class function in forEach: how Javascript handles “this” keyword
问题 I'm new to Javascript and just want to make sure I'm understanding how it handles the this keyword, since... well, it seems like it's pretty messy. I've checked out similar questions on StackOverflow and want to make sure I'm not moving forward with the wrong idea. So I'm defining a class like so, and want to process every point received in the constructor. function Curve(ptList) { this.pts = []; if(ptList.length > 2) { // I want to call "addPoint" for every item in ptList right here } }