DEV Community

front_end_shifu_2022
front_end_shifu_2022

Posted on

3 1

String obj:

string Objects

in js strings are objects.
The String object lets you work with a series of characters; it wraps Javascript's string primitive data type with a number of helper methods.
Use the following syntax to create a String object :
let value = new String(string);

string property

length Returns the length of the string.
e.g.
let human = " john pepper";
human.length;
let length = human.lenght;
console.log(human.length);

String Methods

CharAt():

return the character at specified index.
let human = " john pepper";
console.log(human.charAt(1)) // o

indexOf():

Returns the index within the calling String object of the first occurrence of the specified value, or -1 if not found.
let human = " john pepper";
console.log(human.indexOf(e)); // 6

toLowerCase():

Returns the calling string value converted to lower case.
*let human = " John Pepper";
console.log(human.toLowerCase()); //john pepper

toUpperCase():

Returns the calling string value converted to upperCase.
let human = " John Pepper";
console.log(human.toUpperCase()); //JOHN PEPPER

slice()

Extracts a section of a string and returns a new string.
let human = " John Pepper";
console.log(human.slice(1,4)); //OHN

This is all for now I'll share more in my upcoming posts.

SurveyJS custom survey software

Simplify data collection in your JS app with a fully integrated form management platform. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more. Integrates with any backend system, giving you full control over your data and no user limits.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay