Saturday 21 December 2019

Parse an array (type string) to object

This seems to be a very silly question, but I have spent quite a lot of time on thisvar listOfNames = "['google', 'facebook', 'twitter']" // this is of type string How do I parse this as an Object ??Like thislistOfNames[0] to get the value 'google'JSON.parse would throw an error : Unexpected token ' in JSON at position 1

Submitted December 21, 2019 at 02:05PM by mahesh_kumaran

No comments:

Post a Comment