Chrome does not have the capability to perform array destructuring

Below is the function I am currently using:

function evaluateScroll(positions, width){
    var scale = width / (width - Math.abs(positions[0]) - Math.abs(positions[1]));
    var startLocation = positions[0] / width;

    return [scale, startLocation];
}

This function is utilized in the following manner:

[tscale, tstartLocation] = evaluateScroll(scrollPositions, scrollPlotWidth);

While Safari and Firefox execute this code correctly, Chrome seems to stall at this particular line.

If I modify it to:

var holder = evaluateScroll(scrollPositions, scrollPlotWidth);

it functions properly, but then I must extract the indexes of holder and assign them to the respective variables.

Why does Chrome have trouble with the array-style assignment? Is there a syntax that can be implemented which will work consistently across all browsers, without necessitating the use of the holder variable and reassigning values to the appropriate variables?

Answer №1

Currently, chrome 48 (the latest stable version) does not seem to support the destructuring assignment syntax yet. For more information, you can visit:

However, it seems that the functionality is available in versions 49 and above!

Answer №2

My recommendation is to utilize Babel for writing up-to-date ES6/7 JavaScript code.

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

Best Practices for Uploading Large Files in ASP.NET: how to do it right?

What are the current recommended methods for uploading large files using ASP.NET Web Forms and/or MVC without encountering timeouts? Adjust Server.ScriptTimeout for the specific POST request; Consider utilizing client-side flash uploaders such as swfup ...

Would it be feasible to activate internal routing for the displayed HTML content rather than having to refresh the entire page?

Receiving an HTML string from the server presents a challenge due to constraints in modifying its format, particularly in a legacy system. However, there is a need to display this HTML content in the DOM. To address this issue, the bypassSecurityTrustHtml ...

I encountered no response when attempting to trigger an alert using jQuery within the CodeIgniter framework

Jquery/Javascript seem to be causing issues in codeigniter. Here is what I have done so far: In my config.php file, I made the following additions: $config['javascript_location'] = 'libraries/javascript/jquery.js'; $config['javas ...

"Is it possible to disable the transition animation in mat-sidenav of Angular Material without affecting the animations of

My Angular application features a mat-sidenav that is organized like this: <mat-sidenav-container> <mat-sidenav [mode]="'side'"> <!-- Sidenav content --> </mat-sidenav> <mat-sidenav-content ...

The Position of the WebGL Globe Within the Environment

I've been experimenting with the WebGL Globe, and I have successfully made it rotate. However, I'm struggling to figure out how to adjust its position so that it's not centered in the scene. After making changes to the code found at https:/ ...

What is the solution to resolving a JavaScript error involving the insertBefore() method?

<body> <div class="container mt-4"> <h1 class="display-4 text-center"> <i class="fas fa-car text-success"></i> My<span class="text-success ">Car</span>List</h1> <form id="ca ...

Error message encountered when attempting to invoke a function in a TypeScript file due to an undefined module

Here is an example of code from my Index.ts file, which has a reference to sample.ts: /// <reference path="sample.ts" /> var s: sample.Calculate = new sample.Calculate(5, 5); -- encountering an error s.alertme(); This is the content of my Sample ...

Preventing dragging in Vis.js nodes after a double click: a definitive guide

Working with my Vis.js network, I have set up an event listener to capture double clicks on a node. ISSUE: After double-clicking a node, it unexpectedly starts dragging and remains attached to the mouse cursor until clicked again. How can I prevent this b ...

A guide to troubleshoot and resolve the 500 (Internal Server Error) encountered during an Ajax post request in Laravel

I am facing an issue in my project where I am trying to store data into a database using ajax. However, when I submit the post request, I get an error (500 Internal Server Error). I have tried searching on Google multiple times but the issue remains unreso ...

Polymer encountered styling limitations when trying to apply custom styles to a repeated template tag

When attempting to style the paper-button inside the template, I have tested various approaches and only one has worked. How can I correctly apply styling? In my index.html file, I am calling the iron-ajax element and on the last-response, I'm invokin ...

Is there a simple method in JavaScript to combine, structure, and join numerous multi-dimensional arrays in a specific manner (from right to left)?

Looking for a simple solution to merge, flatten, and concatenate multiple multi-dimensional arrays in JavaScript in a specific manner (from right to left) # Example [['.class1', '.class2'], ['.class3', ['.class4', & ...

Having trouble loading my webpage with Angular.js due to an error

I encountered an error message while trying to load my page using Angular.js. Error: angularjslatest.js:7 Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.6.5/$injector/modulerr?p0=bookingjini&p1=Error%3A%20%5B%24injector%3Amodule ...

Determining the existence of a file on a different domain using JavaScript

One of the key tasks I need to achieve from JavaScript on my HTML page is checking for the existence of specific files: http://www.example.com/media/files/file1.mp3 // exists http://www.example.com/media/files/file2.mp3 // doesn't exist Keep in mi ...

Is there a possibility for the code following the await call to be executed in a random order if an async Vuex action is triggered twice?

const actions = { search: debounce( async ({ commit, dispatch, getters, rootGetters }, { page = 1 }) => { commit("setLoading", true); commit("setPage", page); console.log("Starting...") const ...

Encountering a TypeError while trying to import grapesjs into a nextjs project, specifically receiving the error: "Cannot read properties of null (reading 'querySelector')

I encountered an issue while trying to integrate grapesjs into a nextjs project. The error I received was TypeError: Cannot read properties of null (reading 'querySelector') It appears that grapesjs is looking for the "#gjs" container by its id ...

The v-text-field within the activator slot of the v-menu mysteriously vanishes upon navigating to a new route within a

Working on my Nuxt project with Vuetify, I encountered an issue where the v-text-field would disappear before the page changed after a user inputs date and clicks save. This seems to be related to route changing, but I have yet to find a suitable solutio ...

Calling synchronous methods in Typescript

Hello Nativescript Team, I seem to be stuck with making method calls in my code. Could you please provide me with guidance on how to implement synchronous method calling in Nativescript + Angular? import { Component, OnInit, AfterContentInit } from " ...

Height of the div dynamically increases upwards

Just a quick question - is there a way to make position: fixed divs at the bottom of an element (such as the body) grow upwards as content is dynamically added? Maybe something like anchor: bottom or increase: up? I'm thinking that using JavaScript m ...

Tips for automatically scrolling up when a button is clicked and an error occurs in a lengthy message

My long scrollable form saves data when the button is clicked, but how can I automatically scroll up if an error occurs? I have created a form with 40 points to list, including dropdowns, textboxes, and checkboxes. There are mandatory fields as well. Howe ...

Exploring Istanbul and NYC with the inclusion of test files

While running tests with mocha and nyc, I discovered that some of my assert calls were not being executed. How can I ensure that all the asserts are covered by including my test files in nyc? I attempted: "nyc": { "include": ["**/*.js"] }, as a way to ...