All Questions
Tagged with object-oriented javascript
394 questions
33
votes
6
answers
3k
views
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 ...
24
votes
3
answers
3k
views
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?
...
16
votes
1
answer
4k
views
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:
...
15
votes
2
answers
691
views
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 ...
14
votes
3
answers
2k
views
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 ...
12
votes
1
answer
276
views
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:
...
11
votes
2
answers
3k
views
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 ...
11
votes
3
answers
287
views
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 ...
11
votes
1
answer
1k
views
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 ...
10
votes
3
answers
764
views
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:
...
10
votes
2
answers
3k
views
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 ...
10
votes
2
answers
1k
views
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 ...
10
votes
2
answers
273
views
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 ...
10
votes
2
answers
478
views
"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 ...
9
votes
1
answer
1k
views
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 ...