String in javascript
JavaScript strings are used for storing and manipulating text. It can contain zero or more characters within quotes.
Creating Strings: There are two ways to create a string in Javascript:
- By string literal
- By string object
String operations:
- Substrings: A substring is a contiguous sequence of characters within a string
- Concatenation: This operation is used for appending one string to the end of another string.
- Length: It defines the number of characters in the given string.
- Text Processing Operations: Text processing is the process of creating and editing strings.
- Insertion: This operation is used to insert characters in the string at the specified position.
- Deletion: This operation is used to delete characters in the string at the specified position.
- Update: This operation is used to update characters in the string at the specified position.
Below is the implementation of the String in javascript:
// String written inside quotes
var x = "Welcome to w3wiki!";
console.log(x);
// Declare an object
var y = new String("Great Geek");
console.log(y);
let a = "abcdefgh";
// Finding the first index of the character 'b'
console.log(a.indexOf('b'));
let a2 = "Hello World";
let arrString = ["Geeks", "for", "Geeks"]
// Replacing the word 'World' with 'Geeks'
console.log(a2.replace("World", arrString[0]));
Output
Welcome to w3wiki! [String: 'Great Geek'] 1 Hello Geeks
Learn Data Structures with Javascript | DSA using JavaScript Tutorial
JavaScript (JS) is the most popular lightweight, interpreted compiled programming language, and might be your first preference for Client-side as well as Server-side developments. But have you thought about using Javascript for DSA? Learning Data Structures and Algorithms can be difficult when combined with Javascript. For this reason, we have brought to you this detailed DSA tutorial on how to get started with Data Structures with Javascript from scratch.
Table of Content
- What is Data Structure?
- How to start learning Data Structures with Javascript?
- Learn about Complexities
- Learn Data Structures with JavaScript
- Array in javascript
- String in javascript
- Linked List in Javascript
- Stack in Javascript
- Queue in Javascript
- Tree in Javascript
- Priority Queue in Javascript
- Map in Javascript
- Set in Javascript
- Graph in Javascript
Contact Us