Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to get the first character of a string in javascript

let str = 'John Wick'
let firstChar = str.charAt(0) 
console.log(firstChar); // "J" 
Comment

get first word of string js

let myStr = "Hello World"
let firstWord = myStr.split(" ")[0]
Comment

JavaScript - The first word of a string

const str = "What day of the week is it?";

// 1) the match() method:
str.match(/^w+s/)[0];// => What

// 2) the split() method:
str.split(' ')[0];  // => What

// 3) the slice() method:
str.slice(0, str.indexOf(' ')); // => What
Comment

get the first word of a string javascript

let sentence = "The big brown fox"
let word = sentence.split(" ")[0]

console.log(word) // The
Comment

js get first letter of string

var x = 'some string';
alert(x.charAt(0)); // alerts 's'
Comment

get first word in javascript

let string = "Hello World"

let firstWord = typeof string.split(" ")[0] !== 'undefined' ? string.split(" ")[0] : null; 
Comment

js get words first letter

var str = "Java Script Object Notation";
var matches = str.match(/(w)/g); // ['J','S','O','N']
var acronym = matches.join(''); // JSON

console.log(acronym)
Comment

PREVIOUS NEXT
Code Example
Javascript :: create react app deployment heroku 
Javascript :: what are native node modules 
Javascript :: js add class 
Javascript :: nodejs array buffer to buffer 
Javascript :: convert string in hh:mm am/pm to date js 
Javascript :: how to print numbers from 1 to 100 in javascript 
Javascript :: run jest on single file 
Javascript :: javascript get sum array values 
Javascript :: javascript detect page 
Javascript :: ckeditor check if empty 
Javascript :: set data-id javascript 
Javascript :: how to install formik in react native 
Javascript :: mysql json search array of objects 
Javascript :: redirect if not logged in next js 
Javascript :: An external JavaScript cannot contain the <script tag 
Javascript :: clear interval e.close is not a function 
Javascript :: check checkbox based on value using jquery 
Javascript :: jquery empty 
Javascript :: js window.alert 
Javascript :: authfunctions express 
Javascript :: javascript download xlsx file 
Javascript :: how to remove an object from jsonobject in java 
Javascript :: datatable child rows without ajax 
Javascript :: google maps places autocomplete api 
Javascript :: jquery fadein display new page 
Javascript :: javascript onload complete 
Javascript :: how to make @click in router-link vuejs 
Javascript :: react keydown event listener 
Javascript :: remove double quotes from json array javascript 
Javascript :: convert date to timestamp javascript 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =