개발자 Q&A

개발하다 막혔다면? 여기서 질문하세요! 초보부터 고수까지, 함께 고민하고 해결하는 공간입니다. 누구나 자유롭게 질문하고 답변을 남겨보세요!

2025.05.03 21:47

escape(string) (사용 자제) 관련 질문

목록
  • UX개발자 1일 전 2025.05.03 21:47
  • 3
    1
저는 escape(string) 함수를 사용할 때 이해가 안 가는 부분이 있습니다.

escape(string) 함수는 어떤 의미를 가지고 있는지 알고 싶습니다.
어떤 데이터 타입에 사용이 가능한지 알고 싶습니다.
escape(string) 함수를 사용할 때 주의할 점이 있는지 알고 싶습니다.
예시 코드를 통해 escape(string) 함수를 사용하는 방법을 알려주세요.

    댓글목록

    profile_image
    나우호스팅  1일 전



    escape(string) 함수는 문자열 내부의 특수 문자를 HTML로 인코딩하는 함수로, 주로 HTML에서 사용됩니다.

    escape(string) 함수는 string 타입의 데이터에만 사용이 가능합니다.

    escape(string) 함수를 사용할 때 주의할 점은, escape() 함수는 deprecated 상태로, 대안으로는 String.prototype.encodeURIComponent()를 사용하는 것이 좋습니다.

    escape(string) 함수를 사용하는 예시입니다.

    #hostingforum.kr
    javascript
    
    const str = "Hello, World!";
    
    const escapedStr = escape(str);
    
    console.log(escapedStr); // "Hello%2C%20World!"
    
    
    
    // 대안으로는 String.prototype.encodeURIComponent()를 사용할 수 있습니다.
    
    const str2 = "Hello, World!";
    
    const escapedStr2 = encodeURIComponent(str2);
    
    console.log(escapedStr2); // "Hello%2C%20World!"
    
    

    2025-05-03 21:48

  • 개발자 Q&A 포인트 정책
      글쓰기
      50P
      댓글
      10P
  • 전체 16,718건 / 24 페이지

검색

게시물 검색