Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var N = 100,
- i;
- var FirstWay = function() {
- this.doSomeCalculations = function() {
- // some calculations here
- };
- window.addEventListener( 'scroll', this.doSomeCalculations );
- };
- for ( i = 0; i < N; i++ ) {
- new FirstWay();
- }
- var N = 100,
- i,
- instances = [];
- var SecondWay = function() {
- this.doSomeCalculations = function() {
- // some calculations here
- };
- };
- var doCommonCalculations = function() {
- var i;
- for ( i = 0; i < N; i++ ) {
- instances[ i ].doSomeCalculations();
- }
- };
- for ( i = 0; i < N; i++ ) {
- instances.push( new SecondWay() );
- }
- window.addEventListener( 'scroll', doCommonCalculations );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement