Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

divide first name and last name 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
Comment

PREVIOUS NEXT
Code Example
Javascript :: joi or null 
Javascript :: get authorization header javascript in my page 
Javascript :: axios post with header 
Javascript :: how to change checkbox state in jquery 
Javascript :: empty input of clone jquery 
Javascript :: mongoose id from string 
Javascript :: js convert special characters to html entities 
Javascript :: view background image in react native 
Javascript :: react native text input select all text on focus 
Javascript :: import fetch from ("node-fetch"); ^^^^^^ SyntaxError: Cannot use import statement outside a module 
Javascript :: ajax load document ready 
Javascript :: javascript string comma seprated price to int 
Javascript :: jquery add multiple attribute to element by class 
Javascript :: jquery select option by text 
Javascript :: javascript replace 
Javascript :: javascrpt formatBytes 
Javascript :: get index of selected option javascript 
Javascript :: object.keys 
Javascript :: typeahead cdn 
Javascript :: spread operator merge objects 
Javascript :: json array to string in postgresql 
Javascript :: js get random word from list 
Javascript :: Find smallest Number from array in javascript 
Javascript :: fetch and edit jsonplaceholder api 
Javascript :: validate phone number javascript 
Javascript :: jquery serialize with file upload 
Javascript :: open modal js 
Javascript :: append HTML elements in JavaScript 
Javascript :: How to write inside a div using javascript 
Javascript :: angular mat datepicker timezone 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =