string

Estimated reading time: 6 minutes

string

  • string is stored text type data
  • string represent by one quote ' ' or double qoute " " and es6 back tick ``
let user = 'kamal';
console.log(user);
// kamal
  • string concat by +
let user = 'kamal';
let position = 'code artist';

console.log(users + ' ' + 'is a ' + position)
// kamal is a code artist
  • string interpolation by es6
let user = 'kamal';
let position = 'code artist';

console.log(`${user} is a ${position}`);
// kamal is a code artist
name name name name
fromCharCode fromCodePoint anchor big
blink bold charAt charCodeAt
charPointAt concat endsWith fixed
fontColor fontSize includes indexof
italics lastIndexOf link localCompare
match normalize padEnd padStart
repeat replace search slice
small split startsWith strike
sub substr substring sup
toLocaleLowerCase toLocaleUpperCase toUpperCase toUppercase
toSource toString trim(L,R) valueOF

length

let users = 'kamal is a code artist';
let len = users.length;
console.log(len);
// 23

charAt

let users = 'kamal is a code artist';
let result = users.charAt(1);
console.log(result);
// a

charCodeAt

let users = 'kamal is a code artist';
let result = users.charPointAt(1);
console.log(result);
// 97

charPointAt

  • same as charCodeAt
  • non negative integer

concat

let users = 'kamal is a code artist';
let result = users.concat(' and web developer.');
console.log(result);
// kamal is a code artist and web developer

includes

let users = 'kamal is a code artist';
let result = users.includes('kamal',0);
console.log(result);
// true

endsWith

let users = 'kamal is a code artist';
let result = users.endsWith('artist',22);
console.log(result);
// true

padEnd

let name = 'kamal';
let result = name.padEnd(10,'a');
console.log(result);
// kamalaaaaa

padStart

let name = '