Split First name and Last name using javascript

后端 未结 20 3160
悲&欢浪女
悲&欢浪女 2020-12-08 06:39

I have a user with a name Paul Steve Panakkal. It\'s a long name it won\'t fit to the div container. So is there anyway to split first name and lastname fro

20条回答
  •  春和景丽
    2020-12-08 07:04

    If you mean the last name is all the names after the first name, just use:

    var name = "Paul Steve Panakkal";
    var arrName = name.split(" ");
    var firstName = arrName.slice(0, 1).join(' ');
    var lastName = arrName.slice(1, arrName.length).join(' ');
    

提交回复
热议问题