🏫 TECH/🖼️ Front [javascript] 간단하게 오버로딩 처리하기! 728x90 javascript는 오버로딩을 지원하지 않습니다.예를 들어서,123456789101112131415161718192021222324252627<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title> New Document </title> <meta name="Generator" content="EditPlus"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> </head> <body> <script> function test(content){ alert(content); } function test(){ alert(1); } test("hello my name is..");</script> </body></html>Colored by Color Scriptercs결과는 아래와 같지요.위에 작성된 function test(content){}는 무시당합니다.해결하는 방법solution : 1파라미터 숫자로 구분하는 방법12345678 function test(){ if(arguments.length === 1){ }else if(arguments.length === 2){ }} Colored by Color Scriptercssolution : 2typeof 키워드를 통해서, 자료형으로 구분하는 방법123456789 function test(){ if(typeof arguments[1] === 'function'){ }else if(typeof arguments[1] === 'boolean'){ }else{ }}Colored by Color Scriptercs위 방법을 잘 활용하면javascript 오버로딩을 적절히 해결할 수 있습니다. 감사합니다. 반응형 공유하기 URL 복사카카오톡 공유페이스북 공유엑스 공유 게시글 관리 구독하기팀드모네 IT Blog 저작자표시 비영리 동일조건 '🏫 TECH > 🖼️ Front' 카테고리의 다른 글 javascript 전화걸기, 문자보내기, 메일보내기 (0) 2017.10.30 [javascript] 간단하게, 부모 객체 선택 방법! (0) 2017.10.25 [javascript] setTimeout 지연함수 사용방법 (0) 2017.10.23 [html/tag] p태그에서 값을 가져오는 방법 (0) 2017.10.22 jquery에 animated가 걸린 modal 팝업! (0) 2017.10.19 Contents 당신이 좋아할만한 콘텐츠 javascript 전화걸기, 문자보내기, 메일보내기 2017.10.30 [javascript] 간단하게, 부모 객체 선택 방법! 2017.10.25 [javascript] setTimeout 지연함수 사용방법 2017.10.23 [html/tag] p태그에서 값을 가져오는 방법 2017.10.22 댓글 0 + 이전 댓글 더보기