S
S
sprofxx2018-10-10 10:52:47
JavaScript
sprofxx, 2018-10-10 10:52:47

A Javascript string like “⚡️Text” comes in, how to set the first character in the code to search for it in the string?

A Javascript string like "⚡️Text" comes in, how to set the first character in the code to search for it in the string?
indexOf("⚡")- does not work, tell me what to do?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladislav Lyskov, 2018-10-10
@sprofxx

U+26A1

B
Bhudh, 2018-10-10
@Bhudh

And who's stopping you from inserting the character itself? JavaScript understands Unicode perfectly.

>>> "⚡️Текст".match( "⚡" );
Array ["⚡"]

>>> "⚡️Текст".indexOf( "⚡" );
0

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question