This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.Controller.extend({ | |
| appName: 'Ember Twiddle', | |
| arraySet: Ember.A([ | |
| { | |
| name: 'foo', | |
| childArray: Ember.A([ | |
| { name: 'bar' }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.Component.extend({ | |
| tagName: 'a', | |
| click() { | |
| const selectedValue = Ember.get(this, 'selectedValue') || Ember.get(this, 'title'); | |
| this.onClick(selectedValue); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function average(...args) { | |
| var sum = args.reduce((x, y) => x + y, 0); | |
| return sum / args.length; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // silly method, just learning the reduce method | |
| function findBigOrSmall (a, l) { | |
| return a.reduce(function (x, y) { | |
| return l ? x > y ? x : y : x > y ? x : y; | |
| }); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // paste this in your Chrome's console to try it out, could be useful | |
| // big loop | |
| console.time( 'big-loop' ); | |
| var arrBig = []; | |
| for ( var i = 0; i < 1000; i++ ) | |
| arrBig.push( i ); | |
| console.timeEnd( 'big-loop' ); |