0% found this document useful (0 votes)
14 views2 pages

String JS

String in java script

Uploaded by

devyanibotre2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

String JS

String in java script

Uploaded by

devyanibotre2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

String Manipulation:

Concatenation:
let firstName = "John";
let lastName = "Doe";
let fullName = firstName + " " + lastName; // Concatenation
String Length:
let text = "Hello, World!";
let length = text.length; // Length of the string (number
of characters)
Accessing Characters:
let text = "Hello, World!";
let firstChar = text[0]; // Accessing the first character
let lastChar = text[text.length - 1]; // Accessing the
last character
Substring:
let text = "Hello, World!";
let substring = text.substring(0, 5); // Extracts characters
from index 0 to 4 ("Hello")
String Methods:
JavaScript provides several string methods for manipulation,
including toUpperCase(), toLowerCase(), indexOf(), replace(),
etc.
let text = "Hello, World!";
let upperCaseText = text.toUpperCase(); // Converts to
uppercase
let lowerCaseText = text.toLowerCase(); // Converts to
lowercase
let indexOfComma = text.indexOf(","); // Finds the index of a
substring
let replacedText = text.replace("Hello", "Hi"); // Replaces a
substring
Template Literals:
Template literalsprovide a more convenient way to
concatenate strings and include variables.
let name = "John";
let greeting = `Hello, ${name}!`; // Using template literals

These examples cover some fundamental math operations


using the Math object and various string manipulations in
JavaScript. Understanding these concepts is essential for
working with numerical and string data in your JavaScript
programs.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy