Skip to content
Advertisement

Tag: ecmascript-6

JSDoc: arrow function params

I’m trying to document my code with JSDoc (EcmaScript 2015, WebStorm 12 Build 144.3357.8). I have an arrow function which I want to document its parameters. This two examples work (I get auto-completion): But when I want to document an arrow function in forEach function, for example, the auto-completion isn’t working (all of the below): Has anyone managed to get

es2015 modules – how to name exports dynamically

I would like to create a module, h, which exports one function for every HTML element. Here’s how it might be used: Here’s how that module is defined: I don’t like that every export has to be listed explictly. How do I make these dynamic? Answer how to name exports dynamically You can’t. import and export statements are specifically designed

Can you bind ‘this’ in an arrow function?

I’ve been experimenting with ES6 for a while now, and I’ve just come to a slight problem. I really like using arrow functions, and whenever I can, I use them. However, it would appear that you can’t bind them! Here is the function: Here is the object I want to bind the function to: And here is how I would

TypeScript export vs. default export

What is the difference in TypeScript between export and default export? In all the tutorials, I see people exporting their classes and I cannot compile my code if I don’t add the default keyword before exporting. Also, I couldn’t find any trace of the default export keyword in the official TypeScript documentation. Does not compile. But: Does. The error is:

Square Brackets Javascript Object Key

Can anyone explain how the why/how the below method of assigning keys in JavaScript works? return: Answer It’s the new ES2015 (the EcmaScript spec formally known as ES6) computed property name syntax. It’s a shorthand for the someObject[someKey] assignment that you know from ES3/5: is syntactic sugar for:

Advertisement