Tuesday, 15 August 2017

Dynamically Call JSON Values With Output | Simple - W3tricks

Dynamically Call JSON Values


JSON is easy to call dynamic value like JavaScript Object

Syntax

  • var student = { "name" : "Bob", "msg1" : "Hi" , "msg2" : "Hi Bob", "msg3" : "Hello Bob" };
  • var num = 1;
  • console.log(student["msg"+num]);
  • num++;
  • console.log(student["msg"+num]);
  • num++;
  • console.log(student["msg"+num]);

Output


0 comments:

Post a Comment