Javascript strings - getting the char at a certain point

前端 未结 3 1251
梦谈多话
梦谈多话 2021-01-12 00:01

I have a variable:

var text = \"hello\";

I want to get the 0 positioned character, so:

var firstChar = text[0];
         


        
3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-12 00:32

    I'm not sure why that doesn't work, but you could try using substr()

提交回复
热议问题