배열을 반복하여 속성이 일부 조건과 일치하는지 확인하고 조건이 적용되는 인덱스를 검색하고 jquerys map 메서드를 사용하려고 생각했습니다. 내 문제 here에 대한 정확한 해결책을 찾은 후 동일한 문제가 발생하면 물건을 만들기 위해 내 coffeescript를 굴렸다.TypeError : obj is undefined Coffeescript
buildNewWaypointsFromDraggable:()->
[email protected][0]
indexes = $.map(@newDraggableWaypoints, (obj, index) =>
index if obj.legStart is item
)
window.alert indexes.toString()
왜 이것이다 : @newDraggableWaypoints.push newWaypoint
이 코드는 나에게 headeache을 제공 이잖아입니다 :
newWaypoint = {waypoint:latlon.toString(), legStart:leg.start_location.toString() ,legNumber:legNo.toString()}
와 같은 객체가 간단한 배열에 밀려 :
내 목적은 이것이다 메시지가 표시 되었습니까? 조건이 충족되는 경우 index
및 다른 undefined
: 당신의 map
는 배열의 모든 요소에 대한 뭔가를 검색하지, 당신