I'm new to javascript and I have this issue. I have an array which I need to append inside my script tag, which means:
Example:-
array(abc=>'abc', def=>'def')
var markers = [
// putting the array here
]
In PHP I can just echo, but how can I achieve it in javascript? Furthermore, each time I click the button, it will call this function. Will it duplicate the variable markers each time I click?
Use Array.push like so: markers.push('test')
. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.