<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Javascript :: 태그 :: 모두의프린터</title><link>https://modu-print.com/tags/javascript/</link><description/><generator>Hugo</generator><language>ko-KR</language><lastBuildDate>Sat, 05 Aug 2023 08:45:30 +0900</lastBuildDate><atom:link href="https://modu-print.com/tags/javascript/index.xml" rel="self" type="application/rss+xml"/><item><title>JSON 오브젝트 사이즈 얻기</title><link>https://modu-print.com/posts/3893/</link><pubDate>Wed, 23 Jun 2021 15:58:00 +0900</pubDate><guid>https://modu-print.com/posts/3893/</guid><description>일반적으로 자바스크립트에서 배열등의 크기를 얻을떄는 .length 를 통해 얻습니다만 .. 이게 JSON 파싱등을 통해서 얻은 오브젝트에 포함된 경우에는 length 변수의 값으로는 얻어지지 않습니다. 그런경우 참고하세요.&#10;JavaScript function jsonLength(objVal){ if( !objVal ){ return 0; } return Object.keys(objVal).length; }</description></item><item><title>mysql/mariadb DATETIME -&gt; 년/월/일 시:분:초 변환</title><link>https://modu-print.com/posts/3859/</link><pubDate>Wed, 23 Jun 2021 13:12:00 +0900</pubDate><guid>https://modu-print.com/posts/3859/</guid><description>JavaScript function convDateFormat(dbDate){ var date = new Date(dbDate) var year = date.getFullYear(); var month = (1 + date.getMonth()); month = month &gt;= 10 ? month : '0' + month; var day = date.getDate(); day = day &gt;= 10 ? day : '0' + day; var hour = date.getHours() hour = hour &gt;= 10 ? hour : "0" + hour; var minute = date.getMinutes() minute = minute &gt;= 10 ? minute : "0" + minute; var sec = date.getSeconds() sec = sec &gt;= 10 ? sec : "0" + sec; return year + '/' + month + '/' + day + " " + hour + ":" + minute + ":" + sec; }</description></item><item><title>바이트를 KB, MB, GB 등의 Human Readable로 변환</title><link>https://modu-print.com/posts/3855/</link><pubDate>Wed, 23 Jun 2021 13:05:00 +0900</pubDate><guid>https://modu-print.com/posts/3855/</guid><description>JS작업을 하다보면 .. 바이트 단위의 파일 사이즈등을 MB 등의 단위로 표시해야 할 경우가 있습니다.&#10;그런경우에 사용가능한 .. 변환 함수입니다..&#10;JavaScript function bytesToHumanSize(bytes) { var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; if (bytes == 0){ return '0 Byte'; } var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); if (i &gt; 4) { return Math.round(bytes / Math.pow(1024, i), 2); } return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i]; };</description></item></channel></rss>