본문 바로가기
Develop/JavaScript

Uncaught TypeError: Cannot read property 'split' of undefined

by Pinocchio 2022. 5. 24.
const address = undefined;

// ✅ Provide fallback empty string if falsy
const str = address || '';

Ref. https://bobbyhadz.com/blog/javascript-cannot-read-property-split-of-undefined

 

Solve - Cannot read Property 'split' of Undefined in JS | bobbyhadz

The "Cannot read property 'split' of undefined" error occurs when trying to call the `split()` method on a variable that stores an `undefined` value. To solve the error, make sure to only call the `split` method on strings.

bobbyhadz.com

Ref. https://okky.kr/article/876611

 

OKKY | Uncaught TypeError: Cannot read property 'split' of undefined 에러가....

분명 잘 되던 건데 마이바티스에 쿼리 좀 수정하니까 에러가 나네요.... 대체 원인이 뭘까요... console.log(data) 결과  2021-01-10 출근.  2021-01-09 출근. 2021-01-01 출근 . 2021-02-11 출근. 2021-01-05 출근. 2021-0

okky.kr

Ref. https://am05307.tistory.com/160

 

Javascript | Uncaught TypeError: Cannot read properties of undefined (reading 'split')

1. 오류 : Uncaught TypeError: Cannot read properties of undefined (reading 'split') 2. 코드 수정한 내용 (수정전) var d = $("#"+id).val().split("."); (수정후) var regex = / /gi; if(e != null..

am05307.tistory.com

 

'Develop > JavaScript' 카테고리의 다른 글

Casting between Numbers and String in JavaScript  (0) 2022.05.23
String split in JavaScript  (0) 2022.05.23
Slicing string in JavaScript  (0) 2022.05.20

댓글