JavaScript(28)
-
Javascript array 복사하기
const seriesOrigin = [].concat(chart.getSeries()); // Wrap in an array if not already const seriesClone = seriesOrigin.map(series => Ext.clone(series.getInitialConfig()));
2024.12.13 -
Javascript array 및 map 처리
Ext.Array.each(selection, function (node) { if(node.getData().id.startsWith('extModel')) { node.remove(); } if(node.hasChildNodes()) { Ext.Msg.alert('Warning', '하위 record가 있으면 삭제할 수 없습니다!'); return; }});const selecteRecords = selection.map(record => record.getData());
2024.12.05 -
Javascript 윈도우, 리눅스 상관없이 파일 경로 처리 하기
const filePath = "C:\\Users\\Public/Documents/file.txt";// Split the path into componentsconst components = filePath.split(/[\/\\]/);console.log(components);// Output: ['C:', 'Users', 'Public', 'Documents', 'file.txt']
2024.12.05 -
Javascript split 함수에 정규식 적용하기
'콤마, 세미콜론, 파이프'로 나누기const text = "apple,banana;cherry|date";const result = text.split(/[,;|]/); // Split on commas, semicolons, or pipesconsole.log(result);// Output: ['apple', 'banana', 'cherry', 'date']'스페이스바'로 나누기const text = "Hello World How Are You";const result = text.split(/\s+/); // Split on one or more spacesconsole.log(result);// Output: ['Hello', 'World', 'How', 'Are', 'You']2개만 ..
2024.12.05 -
Javascript 시간 더하기
function addMinutesToCurrentTime(minutesToAdd) { const now = new Date(); // Get the current date and time now.setMinutes(now.getMinutes() + minutesToAdd); // Add 15 minutes return now;}// Example usageconst updatedTime = addMinutesToCurrentTime(15);console.log(updatedTime.toLocaleTimeString('en-US', { hour12: false })); // Example output: "15:30:00" (24-hour format)
2024.12.05 -
Javascript 현재 시간을 15단위로 표시하기
function getCurrentTimeRoundedTo15Minutes() { const now = new Date(); // Get the current hour and minute const hours = now.getHours(); const minutes = now.getMinutes(); // Round minutes to the nearest 15-minute increment const roundedMinutes = Math.round(minutes / 15) * 15; // Handle overflow of minutes (e.g., 60 minutes = next hour) const adjustedHours = (roundedMinutes ..
2024.12.05