Why can't I, in javascript

I have a problem, I can’t change the text of a text object and I don’t understand why, Is there any way to tell the engine if an object is a sprite, text or video and etc or does the engine do it automatically?, this is in javascriptI await your response and thank you

You can, the auto complete just doesn’t know what type of object that is, so it only shows functions shared between all object types. You can find the methods available on text objects and use them nonetheless on https://docs.gdevelop.io/.
If you really care about auto completion, you can give the editor a TSDoc type hint to tell it what type of object it actually is:

/** @type {gdjs.TextRuntimeObject} */
const object = objects[0];
// object.  <-- will now show the correct auto completions 

Thanks, yesterday I was reviewing the platform example with javascript and I noticed this, thanks for the help