Standard built-in objects in Java Script

The string in java script are used to represent and manipulate a sequence of characters. Discussing about different standard built-in objects :- Instance Method String.prototype.charAt() - It returns a new string that consists of unit at the given index. JavaScript Demo: String.prototype.charAt() - const name = 'Dakshata' console.log(name.charAt(4)) //output : 'h' String.prototype.includes() - performs a case-sensitive search to determine whether a given string may be found within this string, returning true or false. JavaScript Demo: String.prototype.includes() const sentence = 'I love tea' console.log(sentence.includes('love')) // output : true String.prototype.indexOf() - It searches this string and returns the index of the first occurrence of the specified substring. JavaScript Demo: String.prototype.indexOf() const search = ' My favorite language is JavaScript' console.log(search.indexOf('y')) // output : 2 String.prototype.replace() - It returns a new string with one, some, or all matches of a pattern replaced by a replacement. JavaScript Demo: String.prototype.replace() const para = 'I live in India' console.log(para.replace('India' , 'Delhi')) //output : 'I live in Delhi' String.prototype.slice() - It extracts a section of this string and returns it as a new string, without changing the original. JavaScript Demo: String.prototype.slice() const str = 'I love cats and dogs' console.log(str.slice(2, -5)) // output : "love cats and" String.prototype.split() - It takes a pattern and divides this string into an ordered list of substrings by searching for the pattern. const str = ' I-am-learning-Reactjs ' const wordgap = str.split('-') console.log(wordgap[2]) // output: 'learning' String.prototype.trim() - It removes whitespace from both ends of this string. JavaScript Demo: String.prototype.trim() - const alpha = 'Fun and learn' console.log(alpha.trim()) //output: 'Fun and learn' String.prototype.toLowerCase()/toUpperCase() - returns this string converted to lowercase/ uppercase respectively. const sentence = 'I am happy' console.log(sentence.toUpperCase()) //output 'I AM HAPPY' Still the list is not over many left to be discussed. Want to checkout more? Read this ECMAScript. (っ◔◡◔)っ ♥ Show love and support ♥

Apr 6, 2025 - 11:58
 0
Standard built-in objects in Java Script

The string in java script are used to represent and manipulate a sequence of characters.

Discussing about different standard built-in objects :-

Instance Method

  • String.prototype.charAt() - It returns a new string that consists of unit at the given index. JavaScript Demo: String.prototype.charAt() -
const name = 'Dakshata'
console.log(name.charAt(4)) 
//output : 'h'
  • String.prototype.includes() - performs a case-sensitive search to determine whether a given string may be found within this string, returning true or false. JavaScript Demo: String.prototype.includes()
const sentence = 'I love tea' 
console.log(sentence.includes('love'))
// output : true
  • String.prototype.indexOf() - It searches this string and returns the index of the first occurrence of the specified substring. JavaScript Demo: String.prototype.indexOf()
const search = ' My favorite language is JavaScript'
console.log(search.indexOf('y'))
// output : 2
  • String.prototype.replace() - It returns a new string with one, some, or all matches of a pattern replaced by a replacement. JavaScript Demo: String.prototype.replace()
const para = 'I live in India'
console.log(para.replace('India' , 'Delhi'))
//output :  'I live in Delhi'

  • String.prototype.slice() - It extracts a section of this string and returns it as a new string, without changing the original. JavaScript Demo: String.prototype.slice()
const str = 'I love cats and dogs'
console.log(str.slice(2, -5))
// output : "love cats and"
  • String.prototype.split() - It takes a pattern and divides this string into an ordered list of substrings by searching for the pattern.
const str = ' I-am-learning-Reactjs '
const wordgap = str.split('-') 
console.log(wordgap[2])
// output: 'learning'
  • String.prototype.trim() - It removes whitespace from both ends of this string. JavaScript Demo: String.prototype.trim() -
const alpha = 'Fun   and learn'
console.log(alpha.trim())
//output: 'Fun and learn'
  • String.prototype.toLowerCase()/toUpperCase() - returns this string converted to lowercase/ uppercase respectively.
const sentence = 'I am happy'
console.log(sentence.toUpperCase())
//output 'I AM HAPPY'

Still the list is not over many left to be discussed. Want to checkout more? Read this ECMAScript.

(っ◔◡◔)っ ♥ Show love and support ♥