function

    js - this 바인딩 관련

    Call & Apply 바인딩 예시 코드 class Point { constructor(x) { this.x = x; } info(y, z) { console.log(`x: ${this.x}, y: ${y}, z: ${z}`); } } var point = new Point(1); point.info(2, 3); // 결과 - x: 1, y: 2, z: 3 var point2 = {x: 100}; point.info.call(point2, 200, 300); // 결과 - x: 100, y: 200, z: 300 point.info.apply(point2, [200, 300]); // 결과 - x: 100, y: 200, z: 300 설명 함수를 바인딩하여 사용 시 this가 지정해준 object로 고정..

    js - 변수 값으로 함수 사용

    코드 // 변수 값이 함수명인 함수 사용 eval(`${변수}()`); 예시 코드 // 예) function 함수() { console.log('성공!'); } var 변수 = '함수'; eval(`${변수}()`); // 결과 (성공)

    js - js 로드 후 생성된 html이라 on 이벤트가 감지되지 않을 때

    코드 // js 로드 후 생성된 html이라 on 이벤트가 감지되지 않을 때 사용 $(document).on('click', '.태그', function () { console.log('click event'); });

    Jquery - ajax 기본 함수

    // 기본 ajax 함수 function 함수이름() { var Params = {}; $.ajax({ url: "/url", type: 'POST', data: Params, datatype: 'json', // ajax 통신 성공 시 success: function(result) { switch (result.status) { case 'complete': console.log('성공 시'); break; case 'fail': console.log('실패 시'); break; default: console.log('예외 발생 시'); break; } }, // ajax 통신 중 에러 발생 시 error: function(request, status, error) { // 에러 출력 console.e..