gpt4 book ai didi

javascript - 将对象转换为字符串 Javascript 时出错

转载 作者:行者123 更新时间:2023-11-28 11:13:42 24 4
gpt4 key购买 nike

我正在尝试在 JavaScript 中将对象转换为字符串以进行一些字符串操作。这是我的代码:

   var userName=String(userInfo.email);//regular email like user@email.com
var atIndex=userName.indexof("@");

我收到以下错误:

TypeError: Object feraeww23d4@wo3ewwito.co2mb has no method 'indexof'

我做错了什么?

谢谢

最佳答案

indexOf

大写O很重要。

关于javascript - 将对象转换为字符串 Javascript 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10252687/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com