What is the rationale behind requiring a semicolon specifically for IE11 in this function?

Currently, I am tackling some vuejs code to ensure compatibility with IE 11. Struggling with a persistent expected semicolon error in this particular function:

chemicalFilters: function (chemical) 
{            
  var max = 0;
  var min = 100;
  for (var component of this.components)
  {
     if(component.component_name == chemical)
     {
       if (max < component.component_value)
         max = component.component_value;
       if(component.component_value != 0 && min > component.component_value)
         min = component.component_value;
     }
  }

  if(max == 0 && min == 100)
    min = max;
  else
  {
    min = Math.round(min*100);
    max = Math.round(max*100);
  }

  this.component_filters.push({component_name: chemical, range:[min,max], min:min, max:max, originalRange:[min,max]});
},

Especially concerned about this line:

if(component.component_name == chemical)

Answer №1

The issue doesn't lie in the mentioned line, but rather in the line above it. The use of the for...of loop was introduced in ECMAScript 2015, which is not fully compatible with IE11. For more information, refer to MDN:

You can utilize a tool like Babel to transpile this code into backward-compatible code. For example:

for (var component of this.components) {
  //...
}

This would be transpiled to something similar to the following (based on your preferences):

var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;

try {
  for (var _iterator = this.components[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
    //...

    var component = _step.value;
  }
} catch (err) {
  _didIteratorError = true;
  _iteratorError = err;
} finally {
  try {
    if (!_iteratorNormalCompletion && _iterator.return != null) {
      _iterator.return();
    }
  } finally {
    if (_didIteratorError) {
      throw _iteratorError;
    }
  }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What sets apart the browser/tab close event from the refresh event?

Can you help me understand the difference between a browser/tab close event and a refresh event? I've been researching this on Stack Overflow, but I'm still having trouble with it. My goal is to be able to log out a user through a server call whe ...

How can one execute a function within an HTML attribute value using Angular?

I am currently attempting to use the weatherToFontAwesomeIcon(weatherDescription: string) function directly within the HTML file for this component. My goal is to showcase a specific FontAwesome icon based on the weather response from the API. import { Cur ...

Displaying a loading screen while a jQuery ajax request is in progress

Currently, I am attempting to display a loading div while waiting for an ajax call to finish. Despite experimenting with various methods, I have not been able to consistently achieve the desired outcome. In my present code, everything functions properly o ...

Unable to retrieve the value from an object (Javascript)

window.addEventListener('keydown', (e) => { let arrowsObj = { "ArrowUp": 1, "ArrowDown": 2, "ArrowLeft": 3, "ArrowRight": 4 } let eventKey = e.key; console.log(arrowsObj.eventKey); }); Despite p ...

Most efficient method for nesting child objects within an array of objects using JavaScript

Hey experts, I'm on the hunt for the most efficient method to transform this data: [ { "id": 1, "animal": "cat", "age": 6, "name": "loky" }, { "id": 2, "animal": &quo ...

Ways to access deeply nested data in Vuex store

I am facing an issue with my Vue project. I need to watch some Vuex store values and here is the code I have written: computed: { serverCategories: { get() { return this.$store.state[this.storeName].serverFilters.categories[0].value ...

Form Input Field with Real-Time JavaScript Validation

Is there a way to validate the content of a textarea using pure JavaScript, without using jQuery? I need assistance with this issue. <script> function validate() { // 1. Only allow alphanumeric characters, dash(-), comma(,) and no spaces ...

Troubleshooting problem with Laravel private channel authentication and Laravel Echo Server

In my current project, I am utilizing laravel-echo-server in conjunction with Redis and vuejs to broadcast events via websockets in Laravel 5.5. Everything runs smoothly when using public channels as the events are successfully broadcasted to the client-si ...

Why won't both routes for Sequelize model querying work simultaneously?

Currently, I am experimenting with different routes in Express while utilizing Sequelize to create my models. I have established two models that function independently of one another. However, I am aiming to have them both operational simultaneously. A sea ...

Steps for implementing a single proxy in JavaScript AJAX with SOAP, mirroring the functionality of the WCF Test Client

I am working with a WCF web Service and a javascript client that connects to this service via AJAX using SOAP 1.2. My goal is to pass a parameter to instruct the AJAX SOAP call to use only one proxy, similar to how it is done in the WCF Test Client by unch ...

Communicating PHP variables with JavaScript through AJAX in a chat application

Hello there! I am currently in the process of developing a chat application for my website that includes user registration and login. My backend server is built using NodeJS to leverage SocketIO capabilities. Within my index.php file, I have implemented ...

javascript implementing number formatting during keyup event

When I try to format a number in an input field on the keyup event, I receive a warning in my browser console that says "The specified value "5,545" cannot be parsed, or is out of range." The value in the input field also gets cleared. How can I solve this ...

Navigating external pages with Vue Router

Could really use some assistance. I've got a JSON file filled with various URL links, some internal and some external. This is what the JSON structure looks like: [ {stuff..., "Url":"https://www.google.com/", stuff..}, {stuff... ...

How to automatically open JQuery Accordion panels when the page loads

My Accordion loads with the 1st panel open upon page load, but I am looking for a way to have the entire Accordion closed by default. Any help or suggestions on how to achieve this would be highly appreciated. Thank you for your assistance. FIDDLE http:// ...

Amcharts does not display the percentage value

I've been working on creating a bar graph using amcharts and I'm trying to show the percentage on top of each bar. Here is the code snippet I have so far: $.ajax({ url: "https://daturl", contentType: "application/json; charset=utf-8", ...

What is the best way to ascertain the variance between two Immutable.js Maps?

I currently have two unchangeable maps: const initial_map = Map({x: 10, y: 20)} const updated_map = Map({x: 15, y: 20)} Can anyone advise on how to find the changes between the two maps? The expected outcome should be: Map({x: 15}) ...

Error Message: Namespace Invalid in Node.js Application Utilizing Mongoose Library with MongoDB Atlas Database

I've been working on a Node.js application similar to Twitter, utilizing Mongoose (version 8.0.2) to communicate with a MongoDB Atlas database. However, I'm stuck dealing with an error message that reads MongoServerError: Invalid namespace specif ...

Continuously monitor the condition in my function

I'm encountering an issue with my jQuery function where it animates a progress bar from 0 to 100 when it's visible on the screen. The problem arises when the progress bar is not initially visible upon page load, as the animation will never trigge ...

Concealing a column in a printed output on Internet Explorer 9

Our application features a webgrid with a hidden reference column that is concealed using CSS. While this method works seamlessly on most browsers, we encounter an issue when it comes to printing. In our print.css file, where the column is hidden similar t ...

Using JavaScript and Tampermonkey to convert strings from an HTML element into an array

I am trying to change the names of months into numbers and place them in a table cell on a website. I thought using an array would make it easier to reference the month names by their corresponding array numbers, allowing me to add table tags before and af ...