Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用ionic 3拆分名称_Javascript_Ionic Framework_Ionic3 - Fatal编程技术网

Javascript 如何使用ionic 3拆分名称

Javascript 如何使用ionic 3拆分名称,javascript,ionic-framework,ionic3,Javascript,Ionic Framework,Ionic3,我有一个变量,我存储我的全名,我想打破我的名字 let fullname ="Praveen Tripathi"; 我想选择这种类型:- let firstname ="Praveen"; let lastname = "Tripathi"; 您可以使用拆分功能:- let fullname ="Praveen Tripathi"; let names = fullname.split(" "); let firstName = names[0]; let lastName = names[

我有一个变量,我存储我的全名,我想打破我的名字

let fullname ="Praveen Tripathi";
我想选择这种类型:-

let firstname ="Praveen";
let lastname = "Tripathi";

您可以使用拆分功能:-

let fullname ="Praveen Tripathi";
let names = fullname.split(" ");
let firstName = names[0];
let lastName = names[1];
如果您的姓名超过2个,则可以使用以下代码:-

let fullname ="Praveen Tripathi James";
let names = fullname.split(" ");
let firstName = names[0];
let lastName = names[(names.length -1)];

再见,谢谢。这是我的工作。