3 ms·
This is sweet. Also because I love what they are doing on javascript development. For example, 1. Destructuring references is not yet supported on Chrome [a
by altrego99 13y ago
This is sweet. Also because I love what they are doing on javascript development. For example,
1. Destructuring references is not yet supported on Chrome
[a,b,c]=[c,d,f]
[a,b]=[b,a+b]
2. Shorthand functions are sweet
[1,2,3,4].map(function(x) x*x)) // [1,4,9,16]
3. Chrome doesn't have an inbuilt shell (Shift+F4 in Firefox)
Granted CoffeeScript makes some of these easy, but they are too paranoid in my opinion to support new and useful syntaxes (e.g. yield keyword for generators, getters/setters).
- epidemian 13y agoI didn't know about that function syntax. Does it work just like the arrow function syntax? [1,2,3,4].map(x => x * x) // [1,4,9,16] I wonder why they included two new shorter function syntax alternatives. Is one of them recommended/deprecated?
- camus 13y agoone is standard the other is not.
- altrego99 13y agoThis doesn't seem to work on Firefox 21 shell. Does it work on FF 22?
- epidemian 13y agoYep, it seems it was added on Firefox 22: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/arrow_functions https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe.... It also seems it's the proposal for ES6: http://wiki.ecmascript.org/doku.php?id=harmony:arrow_function_syntax http://wiki.ecmascript.org/doku.php?id=harmony:arrow_functio.... This blog post explains the differences between these functions and current functions: http://javascriptweblog.wordpress.com/2012/04/09/javascript-fat-city/; http://javascriptweblog.wordpress.com/2012/04/09/javascript-... i wish the unbound "->" alternative is included, so that functions used as methods can also use the new syntax.
- altrego99 13y agoWhich Firefox version does this syntax work on? It's not working on my 21.0.
- ahoge 13y ago>Destructuring references is not yet supported on Chrome Eh. Yea, Firefox got support for that (and `let` and generators/iterators), because they added it in 2006 (Firefox 2.0) as an experimental feature. https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/1.7 https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_...
- blueveek 13y agoShorthand functions are not standard yet. You should bet on arrow function expressions in Harmony for now: [1,2,3,4].map(x => x*x)) // [1,4,9,16] (also note that |this| is lexically bound in the case of fat arrow functions) Also, destructuring objects: let obj = { foo: 42, bar: { baz: 32 } } let { foo, bar } = obj; foo // 42 bar.baz // 32 https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/1.7 https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_... List of all the goodies: https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_... edit: formatting
- skolor 13y agoI haven't used Firefox seriously in a while, but the shift+F4 shortcut looks fairly similarly to the Chrome developer console (F12, select the Console tab). It looks like the Firefox shell is more designed for making new pages though, while the Chrome one is more for debugging the current page.
- graue 13y agoI use Firefox, and I had no idea about Shift+F4 either. Firefox also has Ctrl-Shift-K (probably Cmd-Shift-K on Mac) which is much more similar to the Chrome console you're talking about, and is useful for debugging the page you're on.