JavaScript -Zugriffs -PHP -Variable
//passing PHP variable to JavaScript
var myJSVar = <?php echo json_encode($myPHPVar); ?>;
Grepper
//passing PHP variable to JavaScript
var myJSVar = <?php echo json_encode($myPHPVar); ?>;
let cars = [
{
"id": 1,
"code": "C1",
"color": "purple",
"type": "minivan",
"registration": new Date('2017-01-03'),
"capacity": 7
},
{
"id": 2,
"code": "C2",
"color": "red",
"type": "station wagon",
"registration": new Date('2018-03-03'),
"capacity": 5
},
{
"id": 3,
"code": "C2",
"color": "black",
"type": "station",
"registration": new Date('2018-03-03'),
"capacity": 9
}
]
const s = new Set()
cars.forEach((element) => {
console.log(element.id)
console.log(s.has(element.code) ? 0 : element.code)
s.add(element.code)
console.log(element.color)
console.log(element.type)
console.log(element.capacity)
});