All Questions
Tagged with javascriptobject-oriented
394 questions
33votes
6answers
3kviews
To 'this' or not to 'this'?
I was given a homework and I have 2 solutions: one that uses this and other one that doesn't. I tested both solutions on jsPerf but sometimes it says the version ...
24votes
3answers
3kviews
Simple object-oriented calculator
After studying several ways of doing OOP in JavaScript I think I finally came up with one that seems OK to me. Is it okay? Do you see some problems I can face by using OOP in JavaScript like this? ...
16votes
1answer
4kviews
Should I put default values of attributes on the prototype to save space?
Suppose I've got a JavaScript function that I'm treating like a class - that is, I want to make many instances of it: ...
15votes
2answers
691views
JavaScript/ECMAscript 6 classes organization
I have been trying to wrap my head around all the new options in ECMAscript 6 and to do this I tried to develop a simple setup which would allow me to place absolutely positioned ...
14votes
3answers
2kviews
WebGL shader program management
I'm writing a tiny WebGL/JS framework to improve my knowledge of JavaScript and WebGL. Following is a class that wraps a Shader Program and provides methods for setting the shader parameters (AKA ...
12votes
1answer
276views
Data item prototype in a Javascript data structure where object instance functions see own data
I'm working on a complex Javascript application which includes its own data structure. The previous version's data structure was rather chaotic, and I'm looking to replace it with something where: ...
11votes
2answers
3kviews
Pokemon game in JavaScript
I'm practicing my JavaScript skills by trying to create a Pokemon game. So far, I've made the dataset and the functions required to work the game. Can someone help me optimize the code and tell me why ...
11votes
3answers
287views
Updating Grid on Webpage (new version)
Previous version: Updating Grid on Webpage Task: Draw a grid with a given number of rows and columns. Each cell can be any color. The same grid should also be updated at a predetermined time ...
11votes
1answer
1kviews
Recursive dragon on a canvas
I've been doing some JavaScript for fun again. This time I tried my hand at drawing the Dragon curve - a neat fractal that consists of one line traveling across the plane, never crossing itself, and ...
10votes
3answers
764views
JavaScript OOD: 2048
I wrote a 2048 game in JavaScript with an object-oriented paradigm. The game board is presented with a two-dimensional array and each tile holds an integer. Here is the implementation: ...
10votes
2answers
3kviews
OO design for Tic Tac Toe program
I am practicing object oriented design and have taken Tic Tac Toe as an example. I have written first all the requirements and then started writing code. I would like to get it reviewed so that I can ...
10votes
2answers
1kviews
Implement a Tetris game in JavaScript using HTML5 Canvas
I just wrote a Tetris game and I'd like to ask experienced people for a code review, especially in terms of code efficiency and bad coding habits, and if the code is easy to reason about. Here is the ...
10votes
2answers
273views
There Was an Old Lady - generate lyrics to a cumulation song
This is a problem from exercism.io. View the repo here (contains full example of song). Problem statement: Generate the lyrics of the song 'I Know an Old Lady Who Swallowed a Fly'. While you could ...
10votes
2answers
478views
"Stardust" 2D Gravity Simulator - Follow Up 1: The Planets
This is a follow up for the 2D Gravity Simulator-like Game question. Since then I have developed my javascript skills further, and now I'm using ES6 mainly. Note that even through this code uses the ...
9votes
1answer
1kviews
Multiple inheritance with JavaScript with support of calling of super() methods
I have just finished working on a Node.JS module that provides "multiple inheritance that works". I had some really specific requirements: Works in safe mode Auto-calling of parent constructors Makes ...