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:

https://i.sstatic.net/3bPnh.png

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

Steps for adding vue.js to my ubuntu setup | Error: Package vue not found |

Currently running Ubuntu 18, I decided to install Vue.js. Node version 8.10 and npm version 3.5.2 are already installed on my system, but I encountered an error during the installation process. For reference, I have attached a screenshot here: Please also ...

Both if and else statements are carrying out code in JavaScript/jQuery

The second if statement is functioning correctly, but the first one always triggers the else statement and never stands alone. This jQuery function is enclosed within another function that is invoked under the "$(document).ready" command. I resorted to u ...

Could someone please explain how to obtain a compiled string within an AngularJS directive?

Check out the following code snippet for my custom directive: mymodule.directive("test", function($compile) { return { restrict: 'E', replace: true, template: '<div data-date="{{avail}}"></div>', ...

Challenges arise when using ui-select with both multiple selection and asynchronous options

I'm encountering an issue with the ui-select directive (using AngularJS 1.6.4 and Ui-select 0.19.8). You can find my created fiddle here. The dropdown is supposed to display contacts when I type more than 3 characters, without any filtering applied ...

Adjust the color of text as you scroll

Could you provide guidance on changing the color of fixed texts in specific sections of my portfolio website? Unfortunately, I can't share my lengthy code here, but would greatly appreciate it if you could illustrate with examples. Here's a refer ...

Attempting to insert a line break tag within the text using React

Having trouble inserting line breaks in text using React. Can anyone guide me on how to achieve this? I've attempted adding the br tag, but it is displaying as in the browser. Here's a snippet of my code. Appreciate any help or advice. let sp ...

Can you explain the key distinctions among Highland.js, Kefir.js, and Rx.js?

Given the emphasis on objective answers on SO, my inquiry is focused on understanding the distinct functional and performance characteristics of these three functional/reactive libraries. This knowledge will guide me in selecting the most suitable option ...

Utilizing Navigate and useState for Conditional Routing in React

Looking for assistance with a React app. Here's the code snippet: function App() { const [walletConnected, setWalletConnected] = useState("") async function checkConnection() { const accounts = await window.ethereum.request({ method: 'e ...

When attempting to access index.html, the Express Server responds with a "Page Not Found"

I have encountered a problem while trying to run my Index.html file through an Express server. Despite referring to previously asked questions, I couldn't resolve the issue. The error message 'Cannot GET /' keeps popping up. Below is the sn ...

Modify the names of the array variables

I am currently working with JSON data that consists of an array of blog categories, all represented by category id numbers. I am uncertain about how to create a new array that will translate these id numbers into their corresponding category names. Essen ...

Logging to the console using an If/Else statement, with the Else block containing code that

I'm encountering a peculiar issue with my If statement. I'm modifying the state (true/false) of an object based on onMouseEnter and onMouseLeave. I can execute the code when it's true, but if I include any code in the else statement, it ma ...

Conceal the parent element if there are no elements present within the child element

Look at the markup provided: <div class="careersIntegration__listing" id="careers-listing"> <div class="careersIntegration__accordion"> <div class="careersIntegration__accordion-header"> <span class="careersIntegrat ...

What is the best way to eliminate whitespaces and newlines when using "document.execCommand("copy")" function?

I'm currently working on a code that allows users to copy highlighted text without using the keyboard or right-clicking. I also need to remove any extra spaces or line breaks using regex after the text is selected. However, I am facing some issues wit ...

I'm experiencing unexpected behavior with the <form> element in React, it's not functioning as I

I have encountered a strange behavior while trying to implement a form element for user input. When I directly insert the form element, everything works perfectly fine as I type in the letters. However, if I insert the form element through the AddForm comp ...

Guide to Implementing Vue.js in a Website With Multiple Pages

In my Laravel project, I am importing my app.js file in the following way: require('./bootstrap'); window.Vue = require('vue'); const app = new Vue({ el: '#app', data: {}, methods: {}, }); This app.js file is include ...

What is the most effective method for fetching images from MongoDB?

I'm currently working on a web application that uses MongoDB's GridFS to store and retrieve images. However, I'm facing an issue where retrieving images from the database takes significantly longer than expected when a user makes a request. ...

I encountered a response error code 500 from the development server while using my emulator

As I embark on setting up the react-native environment for development, I encounter an error when executing the command react-native run-android. root@pc:~/l3/s2/DevMobMultipltm/Wakapp# ` A series of tasks are carried out including scanning folders for sy ...

Issues with jQuery Ajax Request Parsing JSON Data in Internet Explorer

My code is working perfectly with ajax jQuery call to json, except for IE. jQuery.ajax({ url: "/session/json.php", type: "GET", data: "", success: function(data) { var obj = jQuery.parseJSON( ...

"Techniques for incorporating a screen in Angular application (Switching between Edit and View modes) upon user interaction

We are currently working on a screen that requires the following development: This screen will have the following features: When clicking on a button, the fields should become editable. In the image provided, there is some repeated data, but in our case, ...

TensorflowJS Error: The property 'fetch' cannot be read as it is undefined

I am working on an Angular 7 application and attempting to load the mobilenet model by following the instructions in this example. To do this, I first installed tensorflowjs using the command npm install @tensorflow/tfjs (based on the steps provided in th ...