This code works in chrome. However, it does not print the day value when run in IE. Can anyone please answer, why this is not working in IE and how is chrome interpreting 'day'(tenDates[0].day) as key.
<html>
<body>
<p id="demo"></p>
<script>
var tenDates = [];
day = "Monday";
date = "10/10/1976";
tenDates.push({
day, date
});
document.getElementById("demo").innerHTML =
tenDates[0].day
</script>
</body>
</html>
You are using ES6 shorthand for object literal.
{
day, date
}
According to ES6 compatibility table IE11 and below might be having problems with this syntax.
Here are some more examples of ES2015 Object Literal extensions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With