Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

To split a full name into first and last names in JavaScript

//  Supported in IE 6-11
const fullName = 'Adam Jones';

//  ['Adam', 'Jones']
const splitOnSpace = fullName.split(' ');
console.log(splitOnSpace);

const first = splitOnSpace[0];
const last = splitOnSpace[1];

console.log(first); //  Adam
console.log(last); //  Jones
Source by bobbyhadz.com #
 
PREVIOUS NEXT
Tagged: #To #split #full #names #JavaScript
ADD COMMENT
Topic
Name
5+1 =