Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Need help: Object oriented comments

Featured Replies

Hi everyone, i need help with making an object oriented javascript comment form, that can add and remove elements. I also need something else that you can do with OO in javascript?

To demonstrate objects in JavaScript you don't have to use Dom elements, you can create a simple object as follows:

 


var person = {
   'height' : '1m80',
   'weight' : '100kg'
   'name' : 'John Smith'
};

console.log(person.height);  // outputs this persons height attribute.

Definitely going to need to see some code. There are 3 main styles of writing object oriented code in JavaScript so it's tricky to advise without knowing your choice; although, at a guess, you're using the prototypal style. We don't really need a full object oriented architecture to add elements to a page, simple functions will do the same job and nodes can be cloned.

 

As for something else that you can do ... you can do as much in OO JavaScript as you can in any other aspect of JavaScript, likewise many other languages. If you're looking for basic inspiration, I'd recommend looking at JavaScript Pro Design Patterns although JavaScript Patterns covers many similar topics and is a lighter read.

Edited by Skateside

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.