JavaScript(29)
-
Javascript 문자열 연결하기
ASIS{ text: '이미지', dataIndex: 'image', align: 'center', width:100, renderer: function(value) { return ''; },},TOBE{ text: '이미지', dataIndex: 'image', align: 'center', width:100, renderer: function(value) { return ``; },},
2025.01.26 -
Javascript json 데이터의 key 이름 바꾸기
const jsonData = { group_id: selectedCategoryId,};// Transform the keyconst updatedJsonData = Object.fromEntries( Object.entries(jsonData).map(([key, value]) => key === 'group_id' ? ['attach_id', value] : [key, value] ));console.log(updatedJsonData);
2025.01.19 -
Javascript or(||)를 oracle의 in 구현하기
기존 처리 방식if(a === 'test1' || a === 'test2') {}in 처럼 구현if(['test1', 'test2'].includes(a)) {}
2025.01.11 -
Javascript arrya 데이터 삭제시 주의점
for문 등을 이용해서 삭제할 경우, 데이터가 밀리는 문제가 있음뒤에서부터 삭제를 해야 밀리는 문제가 없어짐잘못된 예const drawContainer = Ext.ComponentQuery.query('#drawContainer')[0];const surface = drawContainer.getSurface();const sprites = surface.getItems();console.log(sprites);displayedRects.splice(0, displayedRects.length);sprites.forEach(sprite => { if (sprite.type === 'rect') { console.log(sprite); surface.remove(sprite,..
2024.12.25 -
Javascript loop문에서 빠져나오기(중단하기)
Ext.Array.eachreturn은 작동하지 않음return false로 빠져나와야 함let hasChildNodes = false;Ext.Array.each(checkedRows, function (node) { if (node.hasChildNodes()) { Ext.Msg.alert('Warning', '하위 record가 있으면 삭제할 수 없습니다!'); hasChildNodes = true; // Mark that a child node was found return false; // Stop further iterations }});// Exit the function if child nodes were foundif (hasChildNode..
2024.12.22 -
Javascript Object Literal 에러 방지 및 default값 설정
x, y, width, height가 없어도 에러 나지 않도록 함const data = { rectData: { x: 10, y: 20 }};// Using ?. to safely access propertiesconst x = data.rectData?.x; // 10const y = data.rectData?.y; // 20const width = data.rectData?.width; // undefinedconst height = data.rectData?.height; // undefinedconsole.log(x, y, width, height);x, y, width, hegith의 디폴트값 지정const data = { ..
2024.12.21