# Split function overrides string.split?

**URL:** <https://discourse.processing.org/t/split-function-overrides-string-split/34518>\
**Category:** Beginners\
**Created:** [January 7, 2022, 11:48pm UTC](https://discourse.processing.org/t/split-function-overrides-string-split/34518 "2022-01-07T23:48:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Errorbot1122](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/errorbot1122/32/14718_2.png) [@Errorbot1122](https://discourse.processing.org/u/Errorbot1122)\
**Post date:** [January 7, 2022, 11:48pm UTC](https://discourse.processing.org/t/split-function-overrides-string-split/34518/1 "2022-01-07T23:48:39Z")

</div>

For some reason every time, when I tried to use the `string.split()` function, but it says this error.

```auto
TypeError: Cannot read properties of undefined (reading 'split')
Did you just try to use p5.js's split() function? If so, you may want to move it into your sketch's setup() function.

For more details, see: https://github.com/processing/p5.js/wiki/p5.js-overview#why-cant-i-assign-variables-using-p5-functions-and-variables-before-setup

```

My code specifically uses this:

```auto
const filesToLoad = [{ path: 'Bruh.png', forLib: ['p5'] } ]
...
const ext = lib.path
	.split('.')
	.slice(-1);

```

---

<div class="post-metadata">

**Author:** ![Errorbot1122](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/errorbot1122/32/14718_2.png) [@Errorbot1122](https://discourse.processing.org/u/Errorbot1122)\
**Post date:** [January 8, 2022, 12:05am UTC](https://discourse.processing.org/t/split-function-overrides-string-split/34518/2 "2022-01-08T00:05:31Z")

</div>

> [@Errorbot1122](#):
>
> ```auto
> TypeError: Cannot read properties of undefined (reading 'split')
> 
> ```

Oh, I fixed the problem, my path should have been `fileObj.path` instead of `lib.path`

but this is still a problem with p5 and it thinking that I was using the split function.
