Translate

Total Pageviews

charCodeAt()

 

JavaScript String charCodeAt()

The charCodeAt() the method returns the Unicode of the character at a specified index in a string:

The method returns a UTF-16 code (an integer between 0 and 65535).

---------

<!DOCTYPE html>

<html>

<body>


<h2>JavaScript String Methods</h2>


<p>The charCodeAt() method returns the unicode of the character at a given position in a string:</p>


<p id="demo"></p>

<script>

let text = "HELLO WORLD";

document.getElementById("demo").innerHTML = text.charCodeAt(0);

</script>


</body>

</html>

------------------------------------------

Result:

JavaScript String Methods

The charCodeAt() method returns the Unicode of the character at a given position in a string:

72

Substring

 JavaScript String substring()

substring() is similar to slice().

The difference is that start and end values less than 0 are treated as 0 in substring().

<!DOCTYPE html>

<html>

<body>


<h2>JavaScript String Methods</h2>

<p>The substring() method extract a part of a string and returns the extracted parts in a new string:</p>


<p id="demo"></p>

<script>

let str = "Apple, Banana, Kiwi";

document.getElementById("demo").innerHTML = str.substring(7,13);

</script>


</body>

</html>

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

Result:

JavaScript String Methods

The substring() method extracts a part of a string and returns the extracted parts in a new string:

Banana