The charCodeAt() method returns the Unicode of the character at a specified position.
Description: A number representing a position in the string
Note: The first character in the string is at position 0.
Example
In the string "Hello world!", we will return the Unicode of the character at position 1:
101
Final code and demo is here
Demo
stringObject.charCodeAt(index)Parameter: index Required
Description: A number representing a position in the string
Note: The first character in the string is at position 0.
Example
In the string "Hello world!", we will return the Unicode of the character at position 1:
<script type="text/javascript">The output of the code above will be:
var str="Hello world!"
document.write(str.charCodeAt(1))
</script>
101
Final code and demo is here
Demo
No comments:
Post a Comment