Vinhtrinh - Tin Tức Hay, Siêu Hot Cập Nhật Hàng Ngày
  • Home
  • Bất Động Sản
  • Công Nghệ
  • Luật
  • Tài Chính
No Result
View All Result
  • Home
  • Bất Động Sản
  • Công Nghệ
  • Luật
  • Tài Chính
No Result
View All Result
Vinhtrinh - Tin Tức Hay, Siêu Hot Cập Nhật Hàng Ngày
No Result
View All Result

JavaScript tutorial 104 – JavaScript String Methods | String Functions

admin by admin
April 25, 2020
in Công Nghệ
0
JavaScript tutorial 104 – JavaScript String Methods | String  Functions



String object properties and methods:

var name = “I am javascript language”;
document.write(name);

Note: when we use member access operator (dot) on a primitive string variable it is implicitly converted to a string object.

Properties:
length:
– returns the total number of characters present in a given string
Ex:
document.write(name.length); // 24

Methods:

charAt(index:Number):String
– returns a new string containing a character at the specified index
Ex:
document.write(name.charAt(2)); // a

charCodeAt(index:Number):Number
– returns the numeric ASCII value of the character at the specified index
Ex:
document.write(name.charCodeAt(2)); //97

indexOf(value:String):Number
– searches the string from left to right and returns the index of the first occurrence of the given value
Ex:
document.write(name.indexOf(“a”)); // 2

lastIndexOf(value:String):Number
– searches the string from left to right and returns the index of the last occurrence of the given value
Ex:
document.write(name.lastIndexOf(“a”)); // 21

toLowerCase():String
– returns a new string, with all uppercase characters converted to lowercase
Ex:
document.write(name.toLowerCase()); // i am javascript language

toUpperCase():String
– returns a new string, with all lowercase characters converted to uppercase
Ex:
document.write(name.toUpperCase()); // I AM JAVASCRIPT LANGUAGE

substr(startIndex:Number, len:Number):String
– returns a substring consisting of the characters that start at the specified startIndex and with a length specified by len
Ex:
document.write(name.substr(2,2)); // am

substring(startIndex:Number, endIndex:Number):String
– returns a string consisting of the characters specified by startIndex and all characters up to endIndex -1
Ex:
document.write(name.substring(2,4)); // am

slice(startIndex:Number, endIndex:Number):String
– returns a string that includes the startIndex character and all characters up to endIndex -1
Ex:
document.write(name.slice(2,4)); // am

startsWith(value:String):Boolean
– returns true if this string begins with the given string value else returns false
Ex:
document.write(name.startsWith(“I”)); // true

endsWith(value:String):Boolean
– returns true if this string ends with the given string value else returns false
Ex:
document.write(name.endsWith(“language”)); // true

concat(str1:String, str2:String,… ):String
– returns a new string by combining the given strings
Ex:
document.write( “I”.concat(” am”,” JavaScript”) );
document.write(“I” + ” am” + ” JavaScipt”);

split(seperator:String):Array
– splits a String object into an array of substrings by dividing it wherever the specified seperator occurs
Ex:
var words = name.split(” “);
document.write(words[0]); // I
document.write(words[1]); // am
document.write(words[2]); // javascript
document.write(words[3]); // language

valueOf():String
– returns the primitive value of a String object
Ex:
var number = new String(“244”);
document.write(typeof number); // object
document.write(number.valueOf());
document.write(typeof number.valueOf()); // string

=========================================

Follow the link for previous video:
JavaScript tutorial 103 – Creating Strings in Javascript

=========================================

Nguồn: https://vinhtrinh.com.vn

Xem thêm bài viết khác: https://vinhtrinh.com.vn/cong-nghe/

Xem thêm Bài Viết:

  • Phần mềm quản lý bất động sản là gì?
  • Dash là gì? Tìm hiểu chi tiết về đồng tiền ảo Dashcoin
  • Top 3 ứng dụng xem phim online chất lượng cao trên di động
  • Giải pháp thiết kế website in ấn chuyên nghiệp, giá rẻ và chuẩn SEO
  • Khách hàng mục tiêu là gì và cách để xác định khách hàng mục tiêu hiệu quả
Previous Post

ViettinBank cách xem số dư tài khoản ViettinBank chỉ cần 1 tin nhắn

Next Post

Cho thuê biệt thự Vincom Sài Đồng

Next Post
Cho thuê biệt thự Vincom Sài Đồng

Cho thuê biệt thự Vincom Sài Đồng

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Xem Thêm

Bạn nên khảo sát, tìm hiểu thật kỹ, so sánh để tìm được sự lựa chọn phù hợp

Hướng dẫn mua bán nhà Quận 7 dưới 3 tỷ đảm bảo chất lượng sống 

November 30, 2022
Bạn không nên mua bán đất nền Lai Châu chung sổ

5 lưu ý quan trọng khi mua đất nền Lai Châu mà bạn cần biết

October 27, 2022
Hình ảnh mua bán biệt thự quận Đống Đa 2

6 điểm cần lưu ý trước khi mua bán biệt thự quận Đống Đa

October 21, 2022
Hình ảnh chung cư Nam Từ Liêm 3

5 kinh nghiệm mua chung cư Nam Từ Liêm an toàn hữu ích

October 11, 2022
Hình ảnh bán nhà mặt phố quận Hai Bà Trưng 2

Kinh nghiệm bán nhà mặt phố quận Hai Bà Trưng

October 4, 2022
Hình ảnh mua bán nhà riêng quận đống đa 1

9 điều cần lưu ý khi mua bán nhà riêng quận Đống Đa lần đầu

September 27, 2022
  • Liên Hệ
  • Chính Sách Bảo Mật

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Bất Động Sản
  • Công Nghệ
  • Luật
  • Tài Chính

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.