sudhakarinfotech
(current)
Run Code
Live Code Editor- Javascript Object Access Alternative Example
Source Code
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Javascript Object Access</title> </head> <body> <h1>Javascript Object Access</h1> <p id="result"></p> <script> var users = '{"name":"Smith", "salary":45000}'; var obj = JSON.parse(users); document.getElementById("result").innerHTML = obj["name"]; </script> </body> </html>
Source Code Output :
Running