Click here to Skip to main content
15,881,455 members
Everything / Programming Languages / ECMAScript 6

ECMAScript 6

ES6

Great Reads

by Ehtesam Ahmed
This article discusses about one of the coolest features of ECMAScript 6, i.e., "Destructuring"
by Sacha Barber
A little demo app to try out OpenFin
by Modesty Zhang
A simple and practical unidirectional data flow implementation with Reactive Extensions RxJS for React components.
by Modesty Zhang
A simplified approach to enable an array of reducers in a React/Redux web application with existing reducers and selector pattern.

Latest Articles

by Jin Vincent Necesario
Discussion of different Array methods of ES6
by Jin Vincent Necesario
An in-depth interpretation of JavaScript functions
by Jin Vincent Necesario
Learning the drawbacks of different loop constructs and learn how to use the different iteration protocols
by Jin Vincent Necesario
A walkthrough to the different methods of what JavaScript Reflect API provides to developers

All Articles

Sort by Score

ECMAScript 6 

14 Aug 2017 by Ehtesam Ahmed
This article discusses about one of the coolest features of ECMAScript 6, i.e., "Destructuring"
6 Mar 2019 by Sacha Barber
A little demo app to try out OpenFin
10 Dec 2015 by Modesty Zhang
A simple and practical unidirectional data flow implementation with Reactive Extensions RxJS for React components.
31 Mar 2017 by Modesty Zhang
A simplified approach to enable an array of reducers in a React/Redux web application with existing reducers and selector pattern.
22 Aug 2020 by Jin Vincent Necesario
Learning the drawbacks of different loop constructs and learn how to use the different iteration protocols
11 Oct 2020 by Jin Vincent Necesario
Discussion of different Array methods of ES6
27 Nov 2015 by Modesty Zhang
A practical example of utilizing Reactive Extensions RxJS for autonomous states in React components with greater expressiveness and concise code.
8 Nov 2016 by slavik57
A library of notification based objects for TypeScript/JavaScript
21 Oct 2016 by Amgad Fahmi
An experimental tiny lib (3kb) to load any JS library from jsdelivr.com dynamically based on the lib name. Specific version also supported
24 May 2017 by Gerd Wagner
Already available from ES5.1 (and even supported by IE 9), JavaScript's set and get methods have not been used very widely. Their main use case is the implementation of a best practice in OOP.
8 Jan 2018 by Manjunath Matathamana
This tutorial teaches you how to build a React application from scratch. In addition, we will be using fetch API with React to make asynchronous calls to a mock server.
1 Sep 2015 by Christian_Heilmann
The ES6 conundrum
17 Feb 2017 by sameh obada
Implementation of mouse capturing for HTML5 Broswsers
26 Feb 2020 by Richard Deeming
No need for a plugin - filter is already built in to Javascript: Array.prototype.filter() - JavaScript | MDN[^] let filteredList = groupsList.filter(obj => moment(obj.lastModified).format('DD-MM-YYYY') === objectReady.lastModified ||...
28 Jun 2016 by Maxim Nielsen
The article is to have a closer look at the new features introduced by ECMAScript 6 and give examples of how they can be used by developers.
13 Jul 2017 by Andy Lanng
Ok - the ids of your dynamic buttons are all the same. You can't do that. It causes loads of issues. Try this script. It still has problems, but the id's are unique at least: const products = []; const carts = []; const inputs = { productId: document.getElementById("productID"), ...
18 Nov 2017 by rohit7209
How to change state of child from parent, state of parent from child and state of sibling from another sibling
26 Nov 2017 by Mehdi Gholam
Since Typescript is additive to javascript, using it is not obstructive to your development and you can use as little or as much as you like. The typed nature helps a lot in refactoring and changing things in large projects.
26 Mar 2020 by Richard Deeming
Regular expressions would be the easiest option: function addLetterBeforeFs(text, letterToAdd) { return text.replace(/f/gi, letterToAdd + "$&"); } Regular expressions - JavaScript | MDN[^] String.prototype.replace() - JavaScript | MDN[^]
11 May 2020 by Richard Deeming
Destructuring assignment - JavaScript | MDN[^] Based on the vague details of the question, you're missing the "rest" pattern from your assignment: let [Chennai, ...Chandigarh] = states; But that still won't do anything, since the states array...
8 Aug 2020 by Jin Vincent Necesario
A walkthrough to the different methods of what JavaScript Reflect API provides to developers
28 Oct 2020 by OriginalGriff
Ignoring that you don't show us the exact code you used to get the error, but if you get an error message you don't understand, google it: Uncaught RangeError: Incorrect locale information provided at String.toLocaleUpperCase - Google Search[^] ...
21 Jan 2021 by Richard Deeming
The find[^] method returns the first matching object. To return all matching objects, use the filter[^] method instead. You will also need to map the objects from your second and third arrays to extract the property you want, and specify a...
14 Apr 2021 by Richard Deeming
If you don't want to use a loop, then this should work: let newObj = { templates: obj.IDs.map((id, index) => ({ id, link: obj.links[index] })) }; Demo[^]
8 Jun 2022 by Dougy83
Have a look at the splice function. let arrnew = [0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 13, 14, 15, 17, 18, 20] ; let arr2 = []; for (let j = 0; j
24 Sep 2015 by Member 12009559
Hi everyone,I'm currently trying to implement a button long-press/hold for both mouse and touch events so that you can simply hold the button and have the component just keep increasing the element value until you let go. I'm not sure why, but even setting the state out of the loop logic, it...
16 Jun 2016 by Kyle Pennell
This post will explain why const and let are helpful and how they are used.
24 Jun 2016 by Kyle Pennell
Arrow functions are a new ES6 syntax for writing JavaScript functions. They will save developers time and simplify function scope.
8 Nov 2016 by Andy Lanng
Hi,Part of my application involved uploading datasheets via a web portal. The sheets can be in any spreadsheet format.My app uses predefined 'plugins' to translate these datasheets into a flat format that is easier to manipulate into our data structure.Some of these files can be...
9 Dec 2016 by OriginalGriff
The email would - understandably - be sent from the registered email address for the account: any other should be silly!To check this, you need to talk to the admins - only they have access to individuals email or other details. Post your question here: Bugs and Suggestions[^] and they will...
10 Jul 2017 by veena nair
I am new to nodejs. When i tried to run the below code, it not giving me the correct out put. according to me the below program will generate a 'tmp.torrent' file . But it is not happening. What I have tried: var Torrent = require('webseeded-torrent-generator'); var fs = require('fs'); var...
10 Jul 2017 by _m0n
Hi, seems you are not handling error, and probably there are some connectivity issues, I suppose torrent.getMetadata().then(function data (buf) { fs.writeFileSync('tmp.torrent', buf) }, function err (err) { console.log('ERR', err) }) see error, handle it...
11 Jul 2017 by Andy Lanng
Here it is in jsfiddle: Add cart not working - JSFiddle[^] But it works as expected. I made a couple of changes just to get it to run, such as populating the elements on doc.ready, just to get it to fit with jsfiddle. I also made the functions arrow functions. I guess I don't get when you...
13 Jul 2017 by James Min
I have a simple problem, the add to cart function isn't working as it should. When i click the delete button, it add something to the cart. But when i click the add to cart button, it doesn't output anything. const products = []; const carts = []; const inputs = { productId:...
26 Nov 2017 by Paulo Augusto Kunzel
I've been working if JavaScript for a while and it has been brought to me that I should try to "migrate" to typescript. The current project I'm working is a web app thing and there is one other front end developer. I'm not really pro or against typed style programming, I thinnk it has very...
26 Nov 2017 by Dave Kreskowiak
Typescript is just a wrapper around Javascript. TS compiles down to Javascript. It exists to make it easier to write far more consistent code in Javascript. If having an easier time writing Javascript doesn't appeal to you, don't use Typescript.
28 Feb 2018 by Member 13701429
I have been trying for hours to figure out what is going on with Babel. It is not outputting anything close to what it should. Shown here: I can provide any context/files that you may need to deduce a solution. Thanks. sample script.js function: var nameBuilder = function(firstName="John",...
18 Mar 2018 by OriginalGriff
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action. And working out how to do this is a...
6 Mar 2019 by Haris Ghauri
I am making a graphql api where I would be able to get car by id, filter cars by color or return all the cars when no paramater is provided. In the code below, getting a single object out of the array works i.e when I provide the id. However it does not return the objects when I return those...
25 Oct 2018 by MadMyche
You really should know what a libraries functions are before you use it. Many times in jQuery they are wrappers to existing which ALSO compensate for how browsers interpret various commands. You should be able to lookup all of the methods you have in that block, and while you are there read up...
13 Jan 2019 by Member 14065457
I want to add Error Message in my form. Currently i am working on ReactJs and i am absolute new new to reactJs i used ant-design form and form is already validated but did not show error message in text when someone leave empty fields . Please help me out because i am really stuck . Thank You...
13 Jan 2019 by Bohdan Stupak
A quick glance tells me that your import statement is wrong as you should also import Form from antd. And also looks like you should use Form.Item instead of FormItem There might be more errors so I suggest you to verify your code against this demo which has required functionality
6 Mar 2019 by Bohdan Stupak
How about type: new GraphQLList(CarType) and then always resolve your result to array?
26 Mar 2019 by i_syed2000
I'm trying to implement a demo application where I want to use some code written in ES6 Module syntax format in a CommonJS style module format. I have configured the babel-loader and presets, but can't seem to get it working. //ES6 code export default function(a) { console.log("The value...
25 Aug 2019 by Member 14568233
Hey there here is how you'd do it fetch(apiEndpoint).then(response => response.json())
17 Oct 2019 by #realJSOP
comparedTo is a function contained in the BigNumber object. You have to look at the source code for that object to find it.
17 Oct 2019 by RickZeeland
It's a Javascript library, see: GitHub - MikeMcl/bignumber.js: A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic[^]
11 Nov 2019 by Member 14652038
Hello there. I'm the CEO of a small company, I have about 25 people working in various places around the city. I want them to use a future application to exchange real time information ( for example, where they are, when they started/stopped working, pictures, videos, emails, and so on ... ). ...
12 Nov 2019 by pmdwise
Hi Without knowing exactly what you are doing it is hard to say. But.... You can do quite a bit with nodejs and html. So logging start and stop times is possible with a basic web interface. The issue comes when you say you want to take pictures, videos and link to emails etc. I am assuming...
5 Feb 2020 by ahmed_sa
problem How to give red color for rows on html table that have different values on same row ? I need when at least one cell from row different from each others then give red font to full row if you see below row that have same value on all cell not changed color . I need function give red...
5 Feb 2020 by Richard MacCutchan
javascript change row color - Google Search[^]
26 Feb 2020 by FireMonkey92
I am trying to filter an object from an array of objects. Below is the array of the object. const groupsList = [ { "groupId": 1234, "adminId": 52, "name": "HHLC Health co", "directorName": "Mr Daric", "fax": "5556565655",...
10 Mar 2020 by FireMonkey92
HI, I am facing an issue with the browser support in IE 11 of my reactjs project. Here is my code sample. package.json { "name": "my-project", "version": "0.1.0", "description": "", "scripts": { "start": "npm run dev", "dev":...
25 Mar 2020 by FireMonkey92
Hi, I am working on a react project. My requirement is to clear redux store when ever the use closes the browser. (Not on Refreshing the page.) i have done some research on it and found about EventListner events "beforeunload". Here what i have...
25 Mar 2020 by Richard Deeming
If you return a value from the beforeunload event, the browser will display a confirmation message to the user asking whether they want to leave the page. By the time the user clicks "cancel", your code has already run, and your state has been...
26 Mar 2020 by Member 14783910
I am trying to solve a problem in JavaScript. I have a string text consisting of English word. I need to find all the capital and lowercase F's in a word and need to insert T in front of that word. Please help me! Thank you. What I have tried: ...
30 Mar 2020 by FireMonkey92
const COLUMNS = [ { title: 'GROUP ID', dataIndex: 'groupId', key: 'groupId', rowKey: 'groupId', default: true, sorter: (a, b) => a.groupId - b.groupId, }, { title: 'ADMIN ID', dataIndex: 'adminId', key:...
16 Apr 2020 by Member 14804508
I am practicing classes in javascript, in java I can use getters and setters. Ive tried that in Javascript but I am sure if I am doing it right. Any advice ya could give me would be great. class Geolocation { constructor() {...
17 Apr 2020 by FireMonkey92
Hi i am getting an warning message on my react functional component. Warning : Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions...
9 Jun 2022 by Member 14828342
create an object employee with properties: --name as "rajesh" --phone as 9800000000, --symbol "email" as "rajesh@gmail.com". after creating the object, display: --all the keys of object "employee" --only private keys (symbols) --only public key...
14 May 2020 by Member 14832844
var states = [['Tamilnadu'], ['Punjab', 'Haryana']] let [Chennai, ...Chandigarh] = states; module.exports = {states}
18 May 2020 by Member 14833694
you have to install react-app-polyfill this is added in index.js import "react-app-polyfill/ie9"; import "react-app-polyfill/stable"; in package.js the following is added "browserslist": { "production": [ ">0.2%", "not...
22 May 2020 by Kolli Hari Chowdary
Hi Mate you can try this code hacker rank will pass :) let email =Symbol(); let Employee = { name : "rajesh", phone :9800000000, [email] : "rajesh@gmail.com" }; let allKeys = Reflect.ownKeys(Employee) let privateKeys =...
14 Jul 2020 by Andre Oosthuizen
You are calling your mysort function that must include 'a' and 'b' as identifiers, in your code it was not identified - mysort(a,b) versus datasort=data.sort(mysort(?, ?))
24 Aug 2020 by F-ES Sitecore
The difference is that in the first example "a" can only then go on to call "b" as the call to "b" is hard-coded in "a". In the second example the calling code decides what function "a" calls, so it could be "b", it could be "c", it could even...
24 Aug 2020 by Gomehere Blogger
The callback function is important to us, Its works as an argument passing in the function. Its something required asynchronous function called and think, you need to wait for that response and want to process that response ahead that could be...
23 Nov 2020 by W Balboos, GHB
You need to show us what you tried (you, personally). From my point of view you're trying to have someone solve your homework problem. This place is to help those who try to help themselves - so what did you do? What goes wrong? If you are...
3 Jan 2021 by Nishanth J
All The below codding snippets works perfectly. Need to make sure that the below snippets of code can be simplified using any of an advanced ECMA standards let pauseAllcount = 0, resumeAllcount = 0; this.xUserDetails.forEach((el, indx)...
12 Jan 2021 by sree Harish
I want to disable specific dates in the date picker using the props shouldDisableDates, but as it accepts only functions I have written a function but it is always return false. What I have tried: code
12 Jan 2021 by Sandeep Mewara
Quote: return dateInt.indluces(new Date(date)) Spelling of includes look incorrect Refer: JavaScript Array includes() Method[^] Quote: shouldDisableDate (day: DateIOType) => boolean => Disable specific date You can add like: import React...
21 Jan 2021 by omee_k
i have three array of objects like arr_1,arr_2 and arr_3 and i tried to merge all this three objects together but i am not getting what i try to want const arr_1 = [ {"user_id": "3","user_name": "Jack"}, {...
13 Apr 2021 by Parth Patel Apr2021
I am so confused that I have just moved two routers from my server file to controller file to follow the MVC format. Now I can not see logo image on that routers. I can see other pictures that are in view files(addMovies.handlebars) Logo(png...
14 Apr 2021 by Manan Sharma 2021
I have an object that has multiple arrays that looks something like this. let obj = { links: ["https://somelink.com/image.jpg", "https://somelink.com/image2.jpg"], IDs: ["yCmj", "4q1K"], } I want to make it so that it's turned into an...
14 Apr 2021 by W Balboos, GHB
Couldn't you just keep-it-simple and loop through the arrays and construct the new array as you go through them in parallel ? Don't over complicate your code: and array is an array. It is rare that the simplest solution isn't the best.
4 May 2021 by Manan Sharma 2021
So this is my code : let newTems = {} let IDs = ['xyz', 'abc'] let temRef = await db.collection("templates") For each id in IDs, I am checking if the id is equal to the documentID of any document in the "templates" collection and mapping name...
4 May 2021 by Manan Sharma 2021
I had two issues here. The first one is that I called the get() without awaiting it for the tempSnap and because that is a async call I can't use it in a forEach because forEach doesn't support async. To resolve the problem I first loop through...
24 Jun 2021 by Manan Sharma 2021
I have a Javascript module called out.js export default function out(str) { //Some Code console.log(str); } I ran the webpack bundler and created a bundle.js file. And now I am Importing it to my index.html using a tag.
24 Jun 2021 by Chris Copeland
It's likely you could be getting this error because your body > script tags are being processed before the entire document has had the chance to load it's required resources, especially since you've added the defer attribute (which tells a script...
30 Jul 2021 by sharky0914
const [cartItems, setCartItems] = useState([] as memePropsType[]); const handleAddToCart = (clickedItem: memePropsType) => { setCartItems((prev) => { // 1. Is the item already added in the cart? const...
7 Oct 2021 by Richard Deeming
Quote: I need it still to be a number Why? You're immediately appending a string to it, so even if it was still a number, it would be converted to a string at that point. If you want to round a number to an integer whilst keeping it as a...
7 Oct 2021 by Member 15341738
Hello, I have following code: state = { Baseline: 0, // NewContract: 0 } handleOTS(e) { e.preventDefault(); this.setState({Baseline: e.target.value}); } handleTSNC(e) { e.preventDefault(); this.setState({NewContract:...
26 Oct 2021 by Member 15341738
What am I trying to achieve is passing the state from this input: EBITDA ...
20 Apr 2022 by Member 15341738
Hello, I am trying to implement a loading spinner into my React app, but I have a problem with changing its state. It is supposed to appear when the data to display is being downloaded through Axios and then disappear. But right now it's just...
28 Feb 2022 by Richard Deeming
This is precisely as the documentation says it should be: Request.mode - Web APIs | MDN[^]: no-cors — Prevents the method from being anything other than HEAD, GET or POST, and the headers from being anything other than simple headers. ... In...
28 Feb 2022 by Richard MacCutchan
You may want to investigate using the YouTube Data API �|� Google Developers[^].
16 Mar 2022 by Apoorv 2021
I was trying to retrieve the duplicate array items using the for a loop. The loop was successful in giving the duplicates but it is giving multiple instances of the duplicates separately ?? How to get single instances of the duplicate array...
16 Mar 2022 by Patrice T
I would try if (arr.indexOf(arr[i]) !== arr.lastIndexOf(arr[i])) { // or if (i !== arr.lastIndexOf(arr[i])) { This way, array item shows only iit is not the last one.
16 Mar 2022 by Richard Deeming
Try: const arr = ['A', 'B', 'A', 'C', 'B']; const duplicateChars = arr.filter((char, index) => arr.indexOf(char)
2 Apr 2022 by Apoorv 2021
I want to use the "strong" tag while updating the state. But instead, it is directly printing the "strong" tag and not text in bold. I want my text in the state to be visible like text but instead it is directly pasting those HTML tags in DOM. ...
20 Apr 2022 by the headless nick
Use try catch and add this.setState({loading: false}); in catch block; Also you may add loader at the begining of your componentDidMount instead of initializing it in constructor, I would prefer setting loader at function level so when api is...
25 Apr 2022 by stackprogramer
For my express.js project, I use the migrate package to manage the Models of my Mongo database. I defined database object in db.js file.Then I used it in migrate file. //db.js file const mongoClient = require('mongodb').MongoClient; const...
8 May 2022 by Black Mamba Elapidae
function func(x, y){ return x.filter((i) => y.indexOf(i) != -1); } let x= ['a','b','c','b','a']; let y= ['a','b','z']; console.log(func(x, y)); What I have tried: My assumption is: Time complexity o(n^2) : As filter will be o(n) and...
7 May 2022 by OriginalGriff
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for...
8 Jun 2022 by Apoorv 2021
How to divide this array:- [0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 13, 14, 15] into two different arrays with one set of consecutive sequences in one array and another set of consecutive in another array. for eg : array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 12,...
9 Jun 2022 by Member 15668221
let email = Symbol(); let Employee = { name:'rajesh', phone:9800000000, [email]:'rajesh@gmail.com' }; let allKeys = Reflect.ownKeys(Employee) let privateKeys = Object.getOwnPropertySymbols(Employee) let publicKeys = ...
12 Jun 2022 by PoVVeR1
I have a dynamic form like this => Please Take a look at my form I'm using Material UI autocomplete and textfield and Ant Design [Dynamic Form]. I'm having a issues in collecting data and updating the state dynamically and I have no idea what...
17 Apr 2023 by Ankan Chanda 2023
Hi, I need help with this ReactJS application in making a Pie chart. So there are three components namely: Devdropdown , the main one and two child ones are Tables.jsx and Chart.jsx. So, the table got displayed while passing props from the...
31 Jul 2020 by Jin Vincent Necesario
An introduction to JavaScript Symbol type
23 Sep 2016 by bob.bumsuk.lee
Building Angular 2 attribute directive and two components in model-driven and template-driven way to capture and validate bank account number across multiple input fields