What's wrong with javascript string search? -
why snippet not generate 6? , generates -1?
<!doctype html> <html> <body> <script> res =('{"name_^":"ali","age":34}'.search('_^')); document.body.innerhtml = res ; </script> </body> </html>
you're looking indexof function:
'{"name_^":"ali","age":34}'.indexof('_^')
returns 6 (search uses regex, , ^ has special meaning in regex- -1 means string wasn't found)
Comments
Post a Comment